mirror of
https://github.com/nextcloud/server.git
synced 2026-05-22 10:06:37 -04:00
fix(files): fix custom client-side error messages on move/copy actions
move/copy actions don't use axios these days. Signed-off-by: Jonas <jonas@freesources.org>
This commit is contained in:
parent
6afd7bfcf6
commit
fb22644cfb
1 changed files with 13 additions and 16 deletions
|
|
@ -10,7 +10,6 @@ import type { MoveCopyResult } from './moveOrCopyActionUtils.ts'
|
|||
|
||||
import FolderMoveSvg from '@mdi/svg/svg/folder-move-outline.svg?raw'
|
||||
import CopyIconSvg from '@mdi/svg/svg/folder-multiple-outline.svg?raw'
|
||||
import { isAxiosError } from '@nextcloud/axios'
|
||||
import { FilePickerClosed, getFilePickerBuilder, openConflictPicker, showError, showLoading } from '@nextcloud/dialogs'
|
||||
import { emit } from '@nextcloud/event-bus'
|
||||
import { FileType, getUniqueName, NodeStatus, Permission } from '@nextcloud/files'
|
||||
|
|
@ -191,21 +190,19 @@ export async function* handleCopyMoveNodesTo(nodes: INode[], destination: IFolde
|
|||
}
|
||||
} catch (error) {
|
||||
logger.debug(`Error while trying to ${method === MoveCopyAction.COPY ? 'copy' : 'move'} node`, { node, error })
|
||||
if (isAxiosError(error)) {
|
||||
if (error.response?.status === 412) {
|
||||
throw new HintException(t('files', 'A file or folder with that name already exists in this folder'))
|
||||
} else if (error.response?.status === 423) {
|
||||
throw new HintException(t('files', 'The files are locked'))
|
||||
} else if (error.response?.status === 404) {
|
||||
throw new HintException(t('files', 'The file does not exist anymore'))
|
||||
} else if ('response' in error && error.response) {
|
||||
const parser = new DOMParser()
|
||||
const text = await (error as WebDAVClientError).response!.text()
|
||||
const message = parser.parseFromString(text ?? '', 'text/xml')
|
||||
.querySelector('message')?.textContent
|
||||
if (message) {
|
||||
throw new HintException(message)
|
||||
}
|
||||
if (error.response?.status === 412) {
|
||||
throw new HintException(t('files', 'A file or folder with that name already exists in this folder'))
|
||||
} else if (error.response?.status === 423) {
|
||||
throw new HintException(t('files', 'The files are locked'))
|
||||
} else if (error.response?.status === 404) {
|
||||
throw new HintException(t('files', 'The file does not exist anymore'))
|
||||
} else if ('response' in error && error.response) {
|
||||
const parser = new DOMParser()
|
||||
const text = await (error as WebDAVClientError).response!.text()
|
||||
const message = parser.parseFromString(text ?? '', 'text/xml')
|
||||
.querySelector('message')?.textContent
|
||||
if (message) {
|
||||
throw new HintException(message)
|
||||
}
|
||||
}
|
||||
throw error
|
||||
|
|
|
|||
Loading…
Reference in a new issue