diff options
author | B Stack <bgstack15@gmail.com> | 2020-09-01 00:24:17 +0000 |
---|---|---|
committer | B Stack <bgstack15@gmail.com> | 2020-09-01 00:24:17 +0000 |
commit | 5a3f52b016581a6a0cb4513614b6c620d365dde2 (patch) | |
tree | acfdfb3e1046db87040477033fda0df76d92916a /zen/recycler.cpp | |
parent | Merge branch '11.0' into 'master' (diff) | |
parent | add upstream 11.1 (diff) | |
download | FreeFileSync-5a3f52b016581a6a0cb4513614b6c620d365dde2.tar.gz FreeFileSync-5a3f52b016581a6a0cb4513614b6c620d365dde2.tar.bz2 FreeFileSync-5a3f52b016581a6a0cb4513614b6c620d365dde2.zip |
Merge branch '11.1' into 'master'11.1
add upstream 11.1
See merge request opensource-tracking/FreeFileSync!25
Diffstat (limited to 'zen/recycler.cpp')
-rw-r--r-- | zen/recycler.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/zen/recycler.cpp b/zen/recycler.cpp index 9c463546..b1f2c0fd 100644 --- a/zen/recycler.cpp +++ b/zen/recycler.cpp @@ -11,7 +11,6 @@ #include <gio/gio.h> #include "scope_guard.h" - using namespace zen; @@ -31,8 +30,15 @@ bool zen::recycleOrDeleteIfExists(const Zstring& itemPath) //throw FileError if (!type) return false; - //implement same behavior as in Windows: if recycler is not existing, delete permanently - if (error && error->code == G_IO_ERROR_NOT_SUPPORTED) + /* g_file_trash() can fail with different error codes/messages when trash is unavailable: + Debian 8 (GLib 2.42): G_IO_ERROR_NOT_SUPPORTED: Unable to find or create trash directory + CentOS 7 (GLib 2.56): G_IO_ERROR_FAILED: Unable to find or create trash directory for file.txt + master (GLib 2.64): G_IO_ERROR_NOT_SUPPORTED: Trashing on system internal mounts is not supported + https://gitlab.gnome.org/GNOME/glib/blob/master/gio/glocalfile.c#L2042 */ + const bool trashUnavailable = error && + ((error->domain == G_IO_ERROR && error->code == G_IO_ERROR_NOT_SUPPORTED) || + startsWith(error->message, "Unable to find or create trash directory")); + if (trashUnavailable) //implement same behavior as on Windows: if recycler is not existing, delete permanently { if (*type == ItemType::folder) removeDirectoryPlainRecursion(itemPath); //throw FileError @@ -42,13 +48,9 @@ bool zen::recycleOrDeleteIfExists(const Zstring& itemPath) //throw FileError } throw FileError(replaceCpy(_("Unable to move %x to the recycle bin."), L"%x", fmtPath(itemPath)), - formatSystemError("g_file_trash", - error ? replaceCpy(_("Error code %x"), L"%x", numberTo<std::wstring>(error->code)) : L"", - error ? utfTo<std::wstring>(error->message) : L"Unknown error.")); - //g_quark_to_string(error->domain) + formatGlibError("g_file_trash", error)); } return true; - } |