Try to send files and folders to the bin before trying to delete them

This commit is contained in:
Luis Ángel San Martín
2023-08-25 16:21:21 +02:00
parent 094d7ec5a3
commit d1533174b0
2 changed files with 7 additions and 2 deletions

View File

@ -21,7 +21,9 @@ void ComicsRemover::process()
while (i.hasPrevious() && i2.hasPrevious()) {
QModelIndex mi = i.previous();
currentComicPath = i2.previous();
if (QFile::remove(currentComicPath))
if (QFile::moveToTrash(currentComicPath))
emit remove(mi.row());
else if (QFile::remove(currentComicPath))
emit remove(mi.row());
else
emit removeError();
@ -50,7 +52,9 @@ void FoldersRemover::process()
QModelIndex mi = i.previous();
currentFolderPath = i2.previous();
QDir d(currentFolderPath);
if (d.removeRecursively() || !d.exists()) // the folder is in the DB but no in the drive...
if (QFile::moveToTrash(currentFolderPath))
emit remove(mi);
else if (d.removeRecursively() || !d.exists()) // the folder is in the DB but no in the drive...
emit remove(mi);
else
emit removeError();