Skip to content

Commit

Permalink
perf: speed up folder tree creation during upload
Browse files Browse the repository at this point in the history
Speeds up the folder tree creation during upload by effectively saving up PROPFIND requests on nested folders. Those are only necessary for the root folders.
  • Loading branch information
JammingBen committed Nov 23, 2023
1 parent 59d4f36 commit bc75ca9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
6 changes: 6 additions & 0 deletions changelog/unreleased/enhancement-upload-folder-tree-creation
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Enhancement: Folder tree creation during upload

The performance of the folder tree creation during upload has been improved.

https://github.com/owncloud/web/pull/10057
https://github.com/owncloud/web/issues/9817
5 changes: 4 additions & 1 deletion packages/web-app-files/src/HandleUpload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ export class HandleUpload extends BasePlugin {
const folders = directory.split('/')
let createdSubFolders = ''
for (const subFolder of folders) {
const isRoot = !createdSubFolders
if (!subFolder) {
continue
}
Expand Down Expand Up @@ -326,8 +327,10 @@ export class HandleUpload extends BasePlugin {

try {
const folder = await webdav.createFolder(space, {
path: join(currentFolderPath, folderToCreate)
path: join(currentFolderPath, folderToCreate),
fetchFolder: isRoot
})

this.uppyService.publish('uploadSuccess', {
...uppyResource,
meta: { ...uppyResource.meta, fileId: folder?.fileId }
Expand Down
9 changes: 7 additions & 2 deletions packages/web-client/src/webdav/createFolder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,16 @@ export const CreateFolderFactory = (
{ accessToken }: WebDavOptions
) => {
return {
async createFolder(space: SpaceResource, { path }: { path?: string }): Promise<FolderResource> {
async createFolder(
space: SpaceResource,
{ path, fetchFolder = true }: { path?: string; fetchFolder?: boolean }
): Promise<FolderResource> {
const headers = buildAuthHeader(unref(accessToken), space)
await dav.mkcol(urlJoin(space.webDavPath, path, { leadingSlash: true }), { headers })

return getFileInfoFactory.getFileInfo(space, { path })
if (fetchFolder) {
return getFileInfoFactory.getFileInfo(space, { path })
}
}
}
}

0 comments on commit bc75ca9

Please sign in to comment.