Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>tags/v28.0.0beta1
async exec(node: Node) { | async exec(node: Node) { | ||||
try { | try { | ||||
await axios.delete(node.source) | |||||
await axios.delete(node.encodedSource) | |||||
// Let's delete even if it's moved to the trashbin | // Let's delete even if it's moved to the trashbin | ||||
// since it has been removed from the current view | // since it has been removed from the current view |
} | } | ||||
const relativePath = join(destination.path, node.basename) | const relativePath = join(destination.path, node.basename) | ||||
const destinationUrl = generateRemoteUrl(`dav/files/${getCurrentUser()?.uid}${relativePath}`) | |||||
const destinationUrl = generateRemoteUrl(encodePath(`dav/files/${getCurrentUser()?.uid}${relativePath}`)) | |||||
logger.debug(`${method} ${node.basename} to ${destinationUrl}`) | logger.debug(`${method} ${node.basename} to ${destinationUrl}`) | ||||
// Set loading state | // Set loading state | ||||
try { | try { | ||||
await axios({ | await axios({ | ||||
method: method === MoveCopyAction.COPY ? 'COPY' : 'MOVE', | method: method === MoveCopyAction.COPY ? 'COPY' : 'MOVE', | ||||
url: encodeURI(node.source), | |||||
url: node.encodedSource, | |||||
headers: { | headers: { | ||||
Destination: encodeURI(destinationUrl), | Destination: encodeURI(destinationUrl), | ||||
Overwrite: overwrite ? undefined : 'F', | Overwrite: overwrite ? undefined : 'F', |
// Rename and move the file | // Rename and move the file | ||||
async onRename() { | async onRename() { | ||||
const oldName = this.source.basename | const oldName = this.source.basename | ||||
const oldSource = this.source.source | |||||
const oldEncodedSource = this.source.encodedSource | |||||
const newName = this.newName.trim?.() || '' | const newName = this.newName.trim?.() || '' | ||||
if (newName === '') { | if (newName === '') { | ||||
showError(this.t('files', 'Name cannot be empty')) | showError(this.t('files', 'Name cannot be empty')) | ||||
// Update node | // Update node | ||||
this.source.rename(newName) | this.source.rename(newName) | ||||
logger.debug('Moving file to', { destination: this.source.encodedSource, oldEncodedSource }) | |||||
try { | try { | ||||
await axios({ | await axios({ | ||||
method: 'MOVE', | method: 'MOVE', | ||||
url: oldSource, | |||||
url: oldEncodedSource, | |||||
headers: { | headers: { | ||||
Destination: encodeURI(this.source.source), | |||||
Destination: this.source.encodedSource, | |||||
}, | }, | ||||
}) | }) | ||||
async handler(context: Folder, content: Node[]) { | async handler(context: Folder, content: Node[]) { | ||||
const contentNames = content.map((node: Node) => node.basename) | const contentNames = content.map((node: Node) => node.basename) | ||||
const name = getUniqueName(t('files', 'New folder'), contentNames) | const name = getUniqueName(t('files', 'New folder'), contentNames) | ||||
const { fileid, source } = await createNewFolder(context.source, name) | |||||
const { fileid, source } = await createNewFolder(context.encodedSource, encodeURIComponent(name)) | |||||
// Create the folder in the store | // Create the folder in the store | ||||
const folder = new Folder({ | const folder = new Folder({ |
import { getClient, rootPath } from './WebdavClient' | import { getClient, rootPath } from './WebdavClient' | ||||
import { hashCode } from '../utils/hashUtils' | import { hashCode } from '../utils/hashUtils' | ||||
import logger from '../logger' | import logger from '../logger' | ||||
import { encodePath } from '@nextcloud/paths' | |||||
const client = getClient() | const client = getClient() | ||||
const permissions = davParsePermissions(props?.permissions) | const permissions = davParsePermissions(props?.permissions) | ||||
const owner = getCurrentUser()?.uid as string | const owner = getCurrentUser()?.uid as string | ||||
const source = generateRemoteUrl(encodePath('dav' + rootPath + node.filename)) | |||||
const source = generateRemoteUrl('dav' + rootPath + node.filename) | |||||
const id = props?.fileid < 0 | const id = props?.fileid < 0 | ||||
? hashCode(source) | ? hashCode(source) | ||||
: props?.fileid as number || 0 | : props?.fileid as number || 0 |
const destination = generateRemoteUrl(encodePath(`dav/trashbin/${getCurrentUser()?.uid}/restore/${node.basename}`)) | const destination = generateRemoteUrl(encodePath(`dav/trashbin/${getCurrentUser()?.uid}/restore/${node.basename}`)) | ||||
await axios({ | await axios({ | ||||
method: 'MOVE', | method: 'MOVE', | ||||
url: node.source, | |||||
url: node.encodedSource, | |||||
headers: { | headers: { | ||||
destination, | destination, | ||||
}, | }, |
const nodeData = { | const nodeData = { | ||||
id: node.props?.fileid as number || 0, | id: node.props?.fileid as number || 0, | ||||
source: generateRemoteUrl(encodePath('dav' + rootPath + node.filename)), | |||||
source: generateRemoteUrl('dav' + rootPath + node.filename), | |||||
// do not show the mtime column | // do not show the mtime column | ||||
// mtime: new Date(node.lastmod), | // mtime: new Date(node.lastmod), | ||||
mime: node.mime as string, | mime: node.mime as string, |
"@nextcloud/capabilities": "^1.0.4", | "@nextcloud/capabilities": "^1.0.4", | ||||
"@nextcloud/dialogs": "^5.0.0-beta.4", | "@nextcloud/dialogs": "^5.0.0-beta.4", | ||||
"@nextcloud/event-bus": "^3.1.0", | "@nextcloud/event-bus": "^3.1.0", | ||||
"@nextcloud/files": "^3.0.0-beta.22", | |||||
"@nextcloud/files": "^3.0.0-beta.25", | |||||
"@nextcloud/initial-state": "^2.0.0", | "@nextcloud/initial-state": "^2.0.0", | ||||
"@nextcloud/l10n": "^2.1.0", | "@nextcloud/l10n": "^2.1.0", | ||||
"@nextcloud/logger": "^2.5.0", | "@nextcloud/logger": "^2.5.0", | ||||
"integrity": "sha512-rxzuSL2RSt/pWWnFnUFQi5GJArm2tHMhx20Gee3Ydn+xT2bqbR4syfgdPrq2b+j+n5LjC7C8Fb1QDM6LKeF0cA==" | "integrity": "sha512-rxzuSL2RSt/pWWnFnUFQi5GJArm2tHMhx20Gee3Ydn+xT2bqbR4syfgdPrq2b+j+n5LjC7C8Fb1QDM6LKeF0cA==" | ||||
}, | }, | ||||
"node_modules/@nextcloud/auth": { | "node_modules/@nextcloud/auth": { | ||||
"version": "2.1.0", | |||||
"resolved": "https://registry.npmjs.org/@nextcloud/auth/-/auth-2.1.0.tgz", | |||||
"integrity": "sha512-wf5xQrWQu6fkl3MGegVdyR5mh/EdSQKJByH3m2Url2K2xbML9Y4Y7LAff9jjJAcMt2MkzzJEM463ZBbgTqs0lg==", | |||||
"version": "2.2.1", | |||||
"resolved": "https://registry.npmjs.org/@nextcloud/auth/-/auth-2.2.1.tgz", | |||||
"integrity": "sha512-zYtgrg9NMZfN8kmL5JPCsh5jDhpTCEslhnZWMvbhTiQ7hrOnji/67ok6VMK0CTJ1a92Vr67Ow72lW7YRX69zEA==", | |||||
"dependencies": { | "dependencies": { | ||||
"@nextcloud/event-bus": "^3.1.0" | "@nextcloud/event-bus": "^3.1.0" | ||||
}, | }, | ||||
"engines": { | "engines": { | ||||
"node": "^16.0.0", | |||||
"npm": "^7.0.0 || ^8.0.0" | |||||
"node": "^20.0.0", | |||||
"npm": "^9.0.0" | |||||
} | } | ||||
}, | }, | ||||
"node_modules/@nextcloud/axios": { | "node_modules/@nextcloud/axios": { | ||||
"integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" | "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" | ||||
}, | }, | ||||
"node_modules/@nextcloud/files": { | "node_modules/@nextcloud/files": { | ||||
"version": "3.0.0-beta.22", | |||||
"resolved": "https://registry.npmjs.org/@nextcloud/files/-/files-3.0.0-beta.22.tgz", | |||||
"integrity": "sha512-Y/F3d3sigGJf/2HOTy8PLMgyQnVtMsQVUM+ul7GXgfdMPEVOpQViU9t6K37UjDAVu5v4CvKA++BVKt09KSGxwA==", | |||||
"version": "3.0.0-beta.25", | |||||
"resolved": "https://registry.npmjs.org/@nextcloud/files/-/files-3.0.0-beta.25.tgz", | |||||
"integrity": "sha512-Bw0PRxb3P4wAEybhubFWmlnVihDi2CTc/tQXayWvAz3cAUh8zBK2drnhsF7UQgJGJTZ4l2sdBhgXONUwab75kw==", | |||||
"dependencies": { | "dependencies": { | ||||
"@nextcloud/auth": "^2.1.0", | |||||
"@nextcloud/auth": "^2.2.1", | |||||
"@nextcloud/l10n": "^2.2.0", | "@nextcloud/l10n": "^2.2.0", | ||||
"@nextcloud/logger": "^2.5.0", | |||||
"@nextcloud/logger": "^2.7.0", | |||||
"@nextcloud/paths": "^2.1.0", | |||||
"@nextcloud/router": "^2.1.2", | "@nextcloud/router": "^2.1.2", | ||||
"is-svg": "^5.0.0", | "is-svg": "^5.0.0", | ||||
"webdav": "^5.3.0" | "webdav": "^5.3.0" | ||||
} | } | ||||
}, | }, | ||||
"node_modules/@nextcloud/logger": { | "node_modules/@nextcloud/logger": { | ||||
"version": "2.5.0", | |||||
"resolved": "https://registry.npmjs.org/@nextcloud/logger/-/logger-2.5.0.tgz", | |||||
"integrity": "sha512-vJx5YxPyS9/tg3YoqA8CBN7YTZFHfuhMKJIIWFV28phxXqKhGwKVKh+/Ir8ZIPweIM5n8VNT6JOJq1JjGiMg2w==", | |||||
"version": "2.7.0", | |||||
"resolved": "https://registry.npmjs.org/@nextcloud/logger/-/logger-2.7.0.tgz", | |||||
"integrity": "sha512-DSJg9H1jT2zfr7uoP4tL5hKncyY+LOuxJzLauj0M/f6gnpoXU5WG1Zw8EFPOrRWjkC0ZE+NCqrMnITgdRRpXJQ==", | |||||
"dependencies": { | "dependencies": { | ||||
"@nextcloud/auth": "^2.0.0", | "@nextcloud/auth": "^2.0.0", | ||||
"core-js": "^3.6.4" | "core-js": "^3.6.4" | ||||
}, | }, | ||||
"engines": { | "engines": { | ||||
"node": "^16.0.0", | |||||
"npm": "^7.0.0 || ^8.0.0" | |||||
"node": "^20.0.0", | |||||
"npm": "^9.0.0" | |||||
} | } | ||||
}, | }, | ||||
"node_modules/@nextcloud/moment": { | "node_modules/@nextcloud/moment": { |
"@nextcloud/capabilities": "^1.0.4", | "@nextcloud/capabilities": "^1.0.4", | ||||
"@nextcloud/dialogs": "^5.0.0-beta.4", | "@nextcloud/dialogs": "^5.0.0-beta.4", | ||||
"@nextcloud/event-bus": "^3.1.0", | "@nextcloud/event-bus": "^3.1.0", | ||||
"@nextcloud/files": "^3.0.0-beta.22", | |||||
"@nextcloud/files": "^3.0.0-beta.25", | |||||
"@nextcloud/initial-state": "^2.0.0", | "@nextcloud/initial-state": "^2.0.0", | ||||
"@nextcloud/l10n": "^2.1.0", | "@nextcloud/l10n": "^2.1.0", | ||||
"@nextcloud/logger": "^2.5.0", | "@nextcloud/logger": "^2.5.0", |