Workaround for GLib's recursive moving error, e.g. with bound mounts
authorTsu Jan <tsujan2000@gmail.com>
Sun, 21 Apr 2019 19:37:07 +0000 (00:07 +0430)
committerAlf Gaida <agaida@siduction.org>
Sat, 8 Jun 2019 14:39:11 +0000 (15:39 +0100)
`g_file_move()` may not work recursively on the same filesystem, especially
with bound mounts (to `/mnt`, for example) and give the `G_IO_ERROR_WOULD_RECURSE`
error. This patch ignores the error and tries our `FileTransferJob::copyFile()`.

Closes https://github.com/lxqt/pcmanfm-qt/issues/943

Gbp-Pq: Name workaround-glib-recursive-moving-error.patch

src/core/filetransferjob.cpp

index 6b4457663da5f923db447aca887b29c6187a3b4a..52cd23c91e8010e0f0e12acfbc1abee42e588c97 100644 (file)
@@ -83,6 +83,13 @@ bool FileTransferJob::moveFileSameFs(const FilePath& srcPath, const GFileInfoPtr
         // do the file operation
         if(!g_file_move(srcPath.gfile().get(), destPath.gfile().get(), GFileCopyFlags(flags), cancellable().get(),
                        nullptr, this, &err)) {
+            // Specially with mounts bound to /mnt, g_file_move() may give the recursive error
+            // and fail, in which case, we ignore the error and try copying and deleting.
+            if(err.code() == G_IO_ERROR_WOULD_RECURSE) {
+              if(auto parent = destPath.parent()) {
+                  return copyFile(srcPath, srcInfo, parent, destPath.baseName().get());
+              }
+            }
             retry = handleError(err, srcPath, srcInfo, destPath, flags);
         }
         else {