summaryrefslogtreecommitdiff
path: root/daemon
diff options
context:
space:
mode:
authorOndrej Holy <oholy@redhat.com>2020-12-07 12:09:01 +0100
committerOndrej Holy <oholy@redhat.com>2020-12-09 07:58:43 +0000
commit4f87e27f8a67e0c87ce8648b1d2ed9f6094af6a4 (patch)
treef5710fa49a9572324c590be359b90123c1c59ec4 /daemon
parent906450614326b6d785b0ab5391b6c3b7d73571a3 (diff)
downloadgvfs-4f87e27f8a67e0c87ce8648b1d2ed9f6094af6a4.tar.gz
admin: Add copy implementation for better performance
Copying file within admin backend is slow in comparison to file://. This is because copy vfunc is not implemented and thus read-write fallback is used. Let's implement native copy to improve performance. Fixes: https://gitlab.gnome.org/GNOME/gvfs/-/issues/530
Diffstat (limited to 'daemon')
-rw-r--r--daemon/gvfsbackendadmin.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/daemon/gvfsbackendadmin.c b/daemon/gvfsbackendadmin.c
index 9a7e8295..0bb6f9f1 100644
--- a/daemon/gvfsbackendadmin.c
+++ b/daemon/gvfsbackendadmin.c
@@ -808,6 +808,36 @@ do_move (GVfsBackend *backend,
}
static void
+do_copy (GVfsBackend *backend,
+ GVfsJobCopy *copy_job,
+ const char *source,
+ const char *destination,
+ GFileCopyFlags flags,
+ GFileProgressCallback progress_callback,
+ gpointer progress_callback_data)
+{
+ GVfsBackendAdmin *self = G_VFS_BACKEND_ADMIN (backend);
+ GVfsJob *job = G_VFS_JOB (copy_job);
+ GError *error = NULL;
+ GFile *src_file, *dst_file;
+
+ if (!check_permission (self, job))
+ return;
+
+ src_file = g_file_new_for_path (source);
+ dst_file = g_file_new_for_path (destination);
+ g_file_copy (src_file, dst_file, flags,
+ job->cancellable,
+ progress_callback, progress_callback_data,
+ &error);
+
+ g_object_unref (src_file);
+ g_object_unref (dst_file);
+
+ complete_job (job, error);
+}
+
+static void
do_pull (GVfsBackend *backend,
GVfsJobPull *pull_job,
const char *source,
@@ -972,6 +1002,7 @@ g_vfs_backend_admin_class_init (GVfsBackendAdminClass * klass)
backend_class->set_attribute = do_set_attribute;
backend_class->delete = do_delete;
backend_class->move = do_move;
+ backend_class->copy = do_copy;
backend_class->pull = do_pull;
backend_class->query_settable_attributes = do_query_settable_attributes;
backend_class->query_writable_namespaces = do_query_writable_namespaces;