diff options
author | Ross Lagerwall <rosslagerwall@gmail.com> | 2013-12-08 16:54:52 +0200 |
---|---|---|
committer | Ross Lagerwall <rosslagerwall@gmail.com> | 2014-01-10 15:27:19 +0200 |
commit | 336aae5e9c9cb718ac83df0938f7563a33d7f063 (patch) | |
tree | f72c074722121ba53243bf30589444aed68cddc7 /daemon | |
parent | 052682c8a22bf8d7c86fb0f086a119dd7fec4c6b (diff) | |
download | gvfs-336aae5e9c9cb718ac83df0938f7563a33d7f063.tar.gz |
dav: Implement seek for output streams
https://bugzilla.gnome.org/show_bug.cgi?id=720062
Diffstat (limited to 'daemon')
-rw-r--r-- | daemon/gvfsbackenddav.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/daemon/gvfsbackenddav.c b/daemon/gvfsbackenddav.c index cd92625c..aed86033 100644 --- a/daemon/gvfsbackenddav.c +++ b/daemon/gvfsbackenddav.c @@ -2319,6 +2319,8 @@ try_create_tested_existence (SoupSession *session, SoupMessage *msg, g_object_set_data_full (G_OBJECT (stream), "-gvfs-stream-msg", put_msg, g_object_unref); g_vfs_job_open_for_write_set_handle (G_VFS_JOB_OPEN_FOR_WRITE (job), stream); + g_vfs_job_open_for_write_set_can_seek (G_VFS_JOB_OPEN_FOR_WRITE (job), + g_seekable_can_seek (G_SEEKABLE (stream))); g_vfs_job_succeeded (job); } @@ -2361,6 +2363,8 @@ open_for_replace_succeeded (GVfsBackendHttp *op_backend, GVfsJob *job, g_object_set_data_full (G_OBJECT (stream), "-gvfs-stream-msg", put_msg, g_object_unref); g_vfs_job_open_for_write_set_handle (G_VFS_JOB_OPEN_FOR_WRITE (job), stream); + g_vfs_job_open_for_write_set_can_seek (G_VFS_JOB_OPEN_FOR_WRITE (job), + g_seekable_can_seek (G_SEEKABLE (stream))); g_vfs_job_succeeded (job); } @@ -2487,6 +2491,28 @@ try_write (GVfsBackend *backend, return TRUE; } +static void +do_seek_on_write (GVfsBackend *backend, + GVfsJobSeekWrite *job, + GVfsBackendHandle handle, + goffset offset, + GSeekType type) +{ + GSeekable *stream = G_SEEKABLE (handle); + GError *error = NULL; + + if (g_seekable_seek (stream, offset, type, G_VFS_JOB (job)->cancellable, &error)) + { + g_vfs_job_seek_write_set_offset (job, g_seekable_tell (stream)); + g_vfs_job_succeeded (G_VFS_JOB (job)); + } + else + { + g_vfs_job_failed_from_error (G_VFS_JOB (job), error); + g_error_free (error); + } +} + /* *** close_write () *** */ static void try_close_write_sent (SoupSession *session, @@ -2690,6 +2716,7 @@ g_vfs_backend_dav_class_init (GVfsBackendDavClass *klass) backend_class->try_create = try_create; backend_class->try_replace = try_replace; backend_class->try_write = try_write; + backend_class->seek_on_write = do_seek_on_write; backend_class->try_close_write = try_close_write; backend_class->make_directory = do_make_directory; backend_class->delete = do_delete; |