[gvfs/wip/oholy/trash-performance] trash: Do not fail when G_FILE_COPY_NO_FALLBACK_FOR_MOVE is used
- From: Ondrej Holy <oholy src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gvfs/wip/oholy/trash-performance] trash: Do not fail when G_FILE_COPY_NO_FALLBACK_FOR_MOVE is used
- Date: Thu, 24 Sep 2020 09:09:25 +0000 (UTC)
commit 5c0bc82e7c22fd1fa88b243c53d6c677ed19541f
Author: Ondrej Holy <oholy redhat com>
Date: Thu Sep 24 10:19:22 2020 +0200
trash: Do not fail when G_FILE_COPY_NO_FALLBACK_FOR_MOVE is used
Restoring files from the trash folder is slow in Nautilus as it attempts
to do it recursively. This is because G_IO_ERROR_NOT_SUPPORTED is
returned from g_file_move when G_FILE_COPY_NO_FALLBACK_FOR_MOVE flag is
used. The error is returned from client-side for pull/push operations
after commit 2e765449 as in the most cases the copy-and-delete approach
is really used there. But the problem is that it is not in all
cases, like in the trash backend case, where the native move operation
is used in fact. Let's handle the G_FILE_COPY_NO_FALLBACK_FOR_MOVE flag
directly in the backends, but not in the trash backend.
Fixes: https://gitlab.gnome.org/GNOME/nautilus/-/issues/1589
client/gdaemonfile.c | 8 --------
daemon/gvfsbackenddav.c | 7 +++++++
daemon/gvfsbackendftp.c | 9 +++++++++
daemon/gvfsbackendgoogle.c | 6 ++++++
daemon/gvfsbackendgphoto2.c | 8 ++++++++
daemon/gvfsbackendmtp.c | 14 ++++++++++++++
daemon/gvfsbackendsftp.c | 16 ++++++++++++++++
7 files changed, 60 insertions(+), 8 deletions(-)
---
diff --git a/client/gdaemonfile.c b/client/gdaemonfile.c
index 2a8c1511..f11cf91c 100644
--- a/client/gdaemonfile.c
+++ b/client/gdaemonfile.c
@@ -2689,14 +2689,6 @@ file_transfer (GFile *source,
return FALSE;
}
- if (!native_transfer && remove_source &&
- (flags & G_FILE_COPY_NO_FALLBACK_FOR_MOVE))
- {
- g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
- _("Operation not supported"));
- return FALSE;
- }
-
if (!native_transfer && local_path == NULL)
{
/* This will cause the fallback code to be involved */
diff --git a/daemon/gvfsbackenddav.c b/daemon/gvfsbackenddav.c
index 5929ab6a..d5c6516d 100644
--- a/daemon/gvfsbackenddav.c
+++ b/daemon/gvfsbackenddav.c
@@ -3477,6 +3477,13 @@ try_push (GVfsBackend *backend,
GFile *source;
PushHandle *handle;
+ if (remove_source && (flags & G_FILE_COPY_NO_FALLBACK_FOR_MOVE))
+ {
+ g_vfs_job_failed (G_VFS_JOB (job), G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
+ _("Operation not supported"));
+ return TRUE;
+ }
+
handle = g_slice_new0 (PushHandle);
handle->backend = g_object_ref (backend);
handle->job = g_object_ref (G_VFS_JOB (job));
diff --git a/daemon/gvfsbackendftp.c b/daemon/gvfsbackendftp.c
index 1d9de93a..e86f5e91 100644
--- a/daemon/gvfsbackendftp.c
+++ b/daemon/gvfsbackendftp.c
@@ -1657,6 +1657,15 @@ do_pull (GVfsBackend * backend,
src = g_vfs_ftp_file_new_from_gvfs (ftp, source);
dest = g_file_new_for_path (local_path);
+ if (remove_source && (flags & G_FILE_COPY_NO_FALLBACK_FOR_MOVE))
+ {
+ g_set_error_literal (&task.error,
+ G_IO_ERROR,
+ G_IO_ERROR_NOT_SUPPORTED,
+ _("Operation not supported"));
+ goto out;
+ }
+
/* If the source is a symlink, then it needs to be handled specially. */
if (flags & G_FILE_COPY_NOFOLLOW_SYMLINKS)
{
diff --git a/daemon/gvfsbackendgoogle.c b/daemon/gvfsbackendgoogle.c
index d4b074e2..27c9eba0 100644
--- a/daemon/gvfsbackendgoogle.c
+++ b/daemon/gvfsbackendgoogle.c
@@ -2777,6 +2777,12 @@ g_vfs_backend_google_push (GVfsBackend *_self,
g_rec_mutex_lock (&self->mutex);
g_debug ("+ push: %s -> %s, %d\n", local_path, destination, flags);
+ if (remove_source && (flags & G_FILE_COPY_NO_FALLBACK_FOR_MOVE))
+ {
+ g_vfs_job_failed (G_VFS_JOB (job), G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, _("Operation not supported"));
+ goto out;
+ }
+
if (flags & G_FILE_COPY_BACKUP)
{
/* Return G_IO_ERROR_NOT_SUPPORTED instead of
diff --git a/daemon/gvfsbackendgphoto2.c b/daemon/gvfsbackendgphoto2.c
index 3120b389..71139b6c 100644
--- a/daemon/gvfsbackendgphoto2.c
+++ b/daemon/gvfsbackendgphoto2.c
@@ -3243,6 +3243,14 @@ do_pull (GVfsBackend *backend,
split_filename_with_ignore_prefix (gphoto2_backend, source, &dir, &name);
+ if (remove_source && (flags & G_FILE_COPY_NO_FALLBACK_FOR_MOVE))
+ {
+ g_vfs_job_failed (G_VFS_JOB (job), G_IO_ERROR,
+ G_IO_ERROR_NOT_SUPPORTED,
+ _("Operation not supported"));
+ goto out;
+ }
+
if (remove_source && !gphoto2_backend->can_delete)
{
g_vfs_job_failed (G_VFS_JOB (job), G_IO_ERROR,
diff --git a/daemon/gvfsbackendmtp.c b/daemon/gvfsbackendmtp.c
index 7777c66b..42c2955e 100644
--- a/daemon/gvfsbackendmtp.c
+++ b/daemon/gvfsbackendmtp.c
@@ -1711,6 +1711,13 @@ do_pull (GVfsBackend *backend,
GFileInfo *info = NULL;
guint64 mtime;
+ if (remove_source && (flags & G_FILE_COPY_NO_FALLBACK_FOR_MOVE)) {
+ g_vfs_job_failed (G_VFS_JOB (job),
+ G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
+ _("Operation not supported"));
+ goto exit;
+ }
+
CacheEntry *entry = get_cache_entry (G_VFS_BACKEND_MTP (backend), source);
if (entry == NULL) {
g_vfs_job_failed_literal (G_VFS_JOB (job),
@@ -2005,6 +2012,13 @@ do_push (GVfsBackend *backend,
gchar **elements = g_strsplit_set (destination, "/", -1);
unsigned int ne = g_strv_length (elements);
+ if (remove_source && (flags & G_FILE_COPY_NO_FALLBACK_FOR_MOVE)) {
+ g_vfs_job_failed (G_VFS_JOB (job),
+ G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
+ _("Operation not supported"));
+ goto exit;
+ }
+
if (ne < 3) {
g_vfs_job_failed_literal (G_VFS_JOB (job),
G_IO_ERROR, G_IO_ERROR_PERMISSION_DENIED,
diff --git a/daemon/gvfsbackendsftp.c b/daemon/gvfsbackendsftp.c
index 1bb4a673..f843dec4 100644
--- a/daemon/gvfsbackendsftp.c
+++ b/daemon/gvfsbackendsftp.c
@@ -6216,6 +6216,14 @@ try_push (GVfsBackend *backend,
GFile *source;
SftpPushHandle *handle;
+ if (remove_source && (flags & G_FILE_COPY_NO_FALLBACK_FOR_MOVE))
+ {
+ g_vfs_job_failed (G_VFS_JOB (op_job),
+ G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
+ _("Operation not supported"));
+ return TRUE;
+ }
+
if (!connection_is_usable (&op_backend->data_connection))
{
g_vfs_job_failed (G_VFS_JOB (op_job),
@@ -6765,6 +6773,14 @@ try_pull (GVfsBackend *backend,
SftpPullHandle *handle;
Command commands[2];
+ if (remove_source && (flags & G_FILE_COPY_NO_FALLBACK_FOR_MOVE))
+ {
+ g_vfs_job_failed (G_VFS_JOB (job),
+ G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
+ _("Operation not supported"));
+ return TRUE;
+ }
+
if (!connection_is_usable (&op_backend->data_connection))
{
g_vfs_job_failed (G_VFS_JOB (job),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]