Skip to content

Commit

Permalink
fix(files): encoded source path on actions requests
Browse files Browse the repository at this point in the history
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
  • Loading branch information
skjnldsv committed Oct 3, 2023
1 parent 8f30f97 commit 264eadd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion apps/files/src/actions/deleteAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const action = new FileAction({

async exec(node: Node) {
try {
await axios.delete(node.source)
await axios.delete(node.encodedSource)

// Let's delete even if it's moved to the trashbin
// since it has been removed from the current view
Expand Down
7 changes: 4 additions & 3 deletions apps/files/src/components/FileEntry.vue
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,7 @@ export default Vue.extend({
// Rename and move the file
async onRename() {
const oldName = this.source.basename
const oldSource = this.source.source
const oldEncodedSource = this.source.encodedSource
const newName = this.newName.trim?.() || ''
if (newName === '') {
showError(this.t('files', 'Name cannot be empty'))
Expand All @@ -870,12 +870,13 @@ export default Vue.extend({
// Update node
this.source.rename(newName)
logger.debug('Moving file to', { destination: this.source.encodedSource, oldEncodedSource })
try {
await axios({
method: 'MOVE',
url: oldSource,
url: oldEncodedSource,
headers: {
Destination: encodeURI(this.source.source),
Destination: this.source.encodedSource,
},
})
Expand Down
3 changes: 1 addition & 2 deletions apps/files/src/services/Files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import { getCurrentUser } from '@nextcloud/auth'
import { getClient, rootPath } from './WebdavClient'
import { hashCode } from '../utils/hashUtils'
import logger from '../logger'
import { encodePath } from '@nextcloud/paths'

const client = getClient()

Expand All @@ -45,7 +44,7 @@ export const resultToNode = function(node: FileStat): File | Folder {
const permissions = davParsePermissions(props?.permissions)
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
? hashCode(source)
: props?.fileid as number || 0
Expand Down

0 comments on commit 264eadd

Please sign in to comment.