Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/files/src/services/DropService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export async function onDropExternalFiles(root: RootDirectory, destination: IFol
if (file instanceof Directory) {
try {
logger.debug('Processing directory', { relativePath })
await createDirectoryIfNotExists(relativePath)
await createDirectoryIfNotExists(relativePath, destination)
await uploadDirectoryContents(file, relativePath)
} catch (error) {
showError(t('files', 'Unable to create the directory {directory}', { directory: file.name }))
Expand Down
14 changes: 9 additions & 5 deletions apps/files/src/services/DropServiceUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,17 +133,21 @@ function readDirectory(directory: FileSystemDirectoryEntry): Promise<FileSystemE
}

/**
* @param path - The path relative to the dav root
* @param path - The path relative to the destination root
* @param destination - The destination folder. When provided, directories are created relative
* to its source URL instead of the default user root. This is needed for uploads into
* non-default locations like team folders.
*/
export async function createDirectoryIfNotExists(path: string) {
const davUrl = join(defaultRemoteURL, defaultRootPath)
export async function createDirectoryIfNotExists(path: string, destination?: IFolder) {
const davUrl = destination?.source ?? join(defaultRemoteURL, defaultRootPath)
const davRoot = destination?.root ?? defaultRootPath
const davClient = getClient(davUrl)
const dirExists = await davClient.exists(path)
if (!dirExists) {
logger.debug('Directory does not exist, creating it', { path })
logger.debug('Directory does not exist, creating it', { path, davUrl })
await davClient.createDirectory(path, { recursive: true })
const stat = await davClient.stat(path, { details: true, data: getDefaultPropfind() }) as ResponseDataDetailed<FileStat>
emit('files:node:created', resultToNode(stat.data, defaultRootPath, davUrl))
emit('files:node:created', resultToNode(stat.data, davRoot, davUrl))
}
}

Expand Down
Loading