Check for same file before pasting (#3034)

This commit is contained in:
Felix Häusler 2022-02-18 11:09:11 +01:00 committed by GitHub
parent fed1dac48f
commit 34e4a22857
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -142,7 +142,7 @@ const actions = {
const { pathname } = state.activeItem
shell.trashItem(pathname).catch(err => {
notice.notify({
title: 'Deletion Error',
title: 'Error while deleting',
type: 'error',
message: err.message
})
@ -156,15 +156,25 @@ const actions = {
const { clipboard } = state
const { pathname, isDirectory } = state.activeItem
const dirname = isDirectory ? pathname : path.dirname(pathname)
if (clipboard) {
if (clipboard && clipboard.src) {
clipboard.dest = dirname + PATH_SEPARATOR + path.basename(clipboard.src)
if (path.normalize(clipboard.src) === path.normalize(clipboard.dest)) {
notice.notify({
title: 'Paste Forbidden',
type: 'warning',
message: 'Source and destination must not be the same.'
})
return
}
paste(clipboard)
.then(() => {
commit('SET_CLIPBOARD', null)
})
.catch(err => {
notice.notify({
title: 'Paste Error',
title: 'Error while pasting',
type: 'error',
message: err.message
})