mirror of
https://github.com/nextcloud/server.git
synced 2026-06-06 07:13:23 -04:00
fix(files): ensure creating folders in public shares work
The root of the webdav client needs to be the public share root, as accessing the `/files` folder is not possible for public shares. Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
This commit is contained in:
parent
5f33fee58f
commit
8c93d4a9e1
2 changed files with 13 additions and 15 deletions
|
|
@ -9,7 +9,6 @@ import type { RootDirectory } from './DropServiceUtils.ts'
|
|||
|
||||
import { showError, showInfo, showSuccess, showWarning } from '@nextcloud/dialogs'
|
||||
import { NodeStatus } from '@nextcloud/files'
|
||||
import { getRootPath } from '@nextcloud/files/dav'
|
||||
import { t } from '@nextcloud/l10n'
|
||||
import { join } from '@nextcloud/paths'
|
||||
import { getUploader, hasConflict } from '@nextcloud/upload'
|
||||
|
|
@ -125,14 +124,13 @@ export async function onDropExternalFiles(root: RootDirectory, destination: IFol
|
|||
// If the file is a directory, we need to create it first
|
||||
// then browse its tree and upload its contents.
|
||||
if (file instanceof Directory) {
|
||||
const absolutePath = join(getRootPath(), destination.path, relativePath)
|
||||
try {
|
||||
logger.debug('Processing directory', { relativePath })
|
||||
await createDirectoryIfNotExists(absolutePath)
|
||||
await createDirectoryIfNotExists(relativePath)
|
||||
await uploadDirectoryContents(file, relativePath)
|
||||
} catch (error) {
|
||||
showError(t('files', 'Unable to create the directory {directory}', { directory: file.name }))
|
||||
logger.error('', { error, absolutePath, directory: file })
|
||||
logger.error('Unable to create the directory', { error, relativePath, directory: file })
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,8 +8,9 @@ import type { FileStat, ResponseDataDetailed } from 'webdav'
|
|||
|
||||
import { showInfo, showWarning } from '@nextcloud/dialogs'
|
||||
import { emit } from '@nextcloud/event-bus'
|
||||
import { getClient, getDefaultPropfind, resultToNode } from '@nextcloud/files/dav'
|
||||
import { defaultRemoteURL, defaultRootPath, getClient, getDefaultPropfind, resultToNode } from '@nextcloud/files/dav'
|
||||
import { t } from '@nextcloud/l10n'
|
||||
import { join } from '@nextcloud/paths'
|
||||
import { openConflictPicker } from '@nextcloud/upload'
|
||||
import logger from '../logger.ts'
|
||||
|
||||
|
|
@ -132,18 +133,17 @@ function readDirectory(directory: FileSystemDirectoryEntry): Promise<FileSystemE
|
|||
}
|
||||
|
||||
/**
|
||||
* Create a directory if it does not exist
|
||||
*
|
||||
* @param absolutePath - the absolute path of the directory to create
|
||||
* @param path - The path relative to the dav root
|
||||
*/
|
||||
export async function createDirectoryIfNotExists(absolutePath: string) {
|
||||
const davClient = getClient()
|
||||
const dirExists = await davClient.exists(absolutePath)
|
||||
export async function createDirectoryIfNotExists(path: string) {
|
||||
const davUrl = join(defaultRemoteURL, defaultRootPath)
|
||||
const davClient = getClient(davUrl)
|
||||
const dirExists = await davClient.exists(path)
|
||||
if (!dirExists) {
|
||||
logger.debug('Directory does not exist, creating it', { absolutePath })
|
||||
await davClient.createDirectory(absolutePath, { recursive: true })
|
||||
const stat = await davClient.stat(absolutePath, { details: true, data: getDefaultPropfind() }) as ResponseDataDetailed<FileStat>
|
||||
emit('files:node:created', resultToNode(stat.data))
|
||||
logger.debug('Directory does not exist, creating it', { path })
|
||||
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))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue