fix(filesDrop): drag-and-drop folder upload directories

Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
This commit is contained in:
Git'Fellow 2026-03-29 15:53:59 +02:00 committed by Ferdinand Thiessen
parent 4e97fe9d66
commit 57b07a673f
No known key found for this signature in database
GPG key ID: 7E849AE05218500F
2 changed files with 10 additions and 6 deletions

View file

@ -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 }))

View file

@ -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))
}
}