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

@ -9,6 +9,7 @@ Version counting is based on semantic versioning (Major.Feature.Patch)
* Add a different versioning strategy for databases. DBs version will change only when the structure changes and not when YACReader version changes. * Add a different versioning strategy for databases. DBs version will change only when the structure changes and not when YACReader version changes.
* Add support for updating libraries automatically with various settings to chose from. During automatic library updates most actions are disabled, you can stop an update by clicking on the busy indicator next to the Libraries title. * Add support for updating libraries automatically with various settings to chose from. During automatic library updates most actions are disabled, you can stop an update by clicking on the busy indicator next to the Libraries title.
* Improve content reloading. Navigation and selection state is no longer reseted after content changes (e.g. library updates, tags edits, etc.) * Improve content reloading. Navigation and selection state is no longer reseted after content changes (e.g. library updates, tags edits, etc.)
* The app will try to move comics and folders to the trash bin when deletions are requested, if the file system used doesn't support trash bin the files will be removed permanetly.
## 9.13.1 ## 9.13.1

View File

@ -21,7 +21,9 @@ void ComicsRemover::process()
while (i.hasPrevious() && i2.hasPrevious()) { while (i.hasPrevious() && i2.hasPrevious()) {
QModelIndex mi = i.previous(); QModelIndex mi = i.previous();
currentComicPath = i2.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()); emit remove(mi.row());
else else
emit removeError(); emit removeError();
@ -50,7 +52,9 @@ void FoldersRemover::process()
QModelIndex mi = i.previous(); QModelIndex mi = i.previous();
currentFolderPath = i2.previous(); currentFolderPath = i2.previous();
QDir d(currentFolderPath); 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); emit remove(mi);
else else
emit removeError(); emit removeError();