summaryrefslogtreecommitdiff
path: root/daemon
diff options
context:
space:
mode:
authorOndrej Holy <oholy@redhat.com>2020-12-07 12:13:39 +0100
committerOndrej Holy <oholy@redhat.com>2020-12-09 07:58:43 +0000
commit87e8188af60d335582c2c69d23ace2cdc59fa656 (patch)
treec4f4eda09274eb30abfcde884b9b1827240cc187 /daemon
parent4f87e27f8a67e0c87ce8648b1d2ed9f6094af6a4 (diff)
downloadgvfs-87e8188af60d335582c2c69d23ace2cdc59fa656.tar.gz
admin: Add push implementation for better performance
Copying file from file:// to admin:// is slow. This is because push vfunc is not implemented and thus read-write fallback is used. Let's implement push to improve performance in this case as well. https://gitlab.gnome.org/GNOME/gvfs/-/issues/530
Diffstat (limited to 'daemon')
-rw-r--r--daemon/gvfsbackendadmin.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/daemon/gvfsbackendadmin.c b/daemon/gvfsbackendadmin.c
index 0bb6f9f1..a56e2bd3 100644
--- a/daemon/gvfsbackendadmin.c
+++ b/daemon/gvfsbackendadmin.c
@@ -883,6 +883,40 @@ do_pull (GVfsBackend *backend,
}
static void
+do_push (GVfsBackend *backend,
+ GVfsJobPush *push_job,
+ const char *destination,
+ const char *local_path,
+ GFileCopyFlags flags,
+ gboolean remove_source,
+ GFileProgressCallback progress_callback,
+ gpointer progress_callback_data)
+{
+ GVfsBackendAdmin *self = G_VFS_BACKEND_ADMIN (backend);
+ GVfsJob *job = G_VFS_JOB (push_job);
+ GError *error = NULL;
+ GFile *src_file, *dst_file;
+
+ if (!check_permission (self, job))
+ return;
+
+ src_file = g_file_new_for_path (local_path);
+ dst_file = g_file_new_for_path (destination);
+
+ if (remove_source)
+ g_file_move (src_file, dst_file, flags, job->cancellable,
+ progress_callback, progress_callback_data, &error);
+ else
+ 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_query_settable_attributes (GVfsBackend *backend,
GVfsJobQueryAttributes *query_job,
const char *filename)
@@ -1004,6 +1038,7 @@ g_vfs_backend_admin_class_init (GVfsBackendAdminClass * klass)
backend_class->move = do_move;
backend_class->copy = do_copy;
backend_class->pull = do_pull;
+ backend_class->push = do_push;
backend_class->query_settable_attributes = do_query_settable_attributes;
backend_class->query_writable_namespaces = do_query_writable_namespaces;
}