Skip to content

Commit f94077c

Browse files
Merge pull request #59366 from nextcloud/backport/59294/stable31
[stable31] fix(filesDrop): drag-and-drop folder upload
2 parents f95011b + 89b1d0a commit f94077c

File tree

4 files changed

+13
-9
lines changed

4 files changed

+13
-9
lines changed

apps/files/src/services/DropService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ export async function onDropExternalFiles(root: RootDirectory, destination: IFol
127127
if (file instanceof Directory) {
128128
try {
129129
logger.debug('Processing directory', { relativePath })
130-
await createDirectoryIfNotExists(relativePath)
130+
await createDirectoryIfNotExists(relativePath, destination)
131131
await uploadDirectoryContents(file, relativePath)
132132
} catch (error) {
133133
showError(t('files', 'Unable to create the directory {directory}', { directory: file.name }))

apps/files/src/services/DropServiceUtils.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,17 +133,21 @@ const readDirectory = (directory: FileSystemDirectoryEntry): Promise<FileSystemE
133133
}
134134

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

dist/files-main.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/files-main.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)