mirror of
https://github.com/nextcloud/server.git
synced 2026-04-21 14:23:17 -04:00
fix(filesDrop): drag-and-drop folder upload directories
Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
This commit is contained in:
parent
4e97fe9d66
commit
57b07a673f
2 changed files with 10 additions and 6 deletions
|
|
@ -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 }))
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue