From d1533174b075bbc8f20756e30dc6f6d7c2208def Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Fri, 25 Aug 2023 16:21:21 +0200 Subject: [PATCH] Try to send files and folders to the bin before trying to delete them --- CHANGELOG.md | 1 + YACReaderLibrary/comics_remover.cpp | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 183ce8f8..135b434b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 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.) +* 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 diff --git a/YACReaderLibrary/comics_remover.cpp b/YACReaderLibrary/comics_remover.cpp index 7cf0aa77..7d11e928 100644 --- a/YACReaderLibrary/comics_remover.cpp +++ b/YACReaderLibrary/comics_remover.cpp @@ -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();