Merge pull request #59294 from nextcloud/dragDropDirCreate

fix(filesDrop): drag-and-drop folder upload
This commit is contained in:
Ferdinand Thiessen 2026-04-01 01:30:48 +02:00 committed by GitHub
commit f6379da3a1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 13 additions and 9 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))
}
}

4
dist/files-main.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long