summaryrefslogtreecommitdiff
path: root/client/gdaemonfile.c
diff options
context:
space:
mode:
authorRoss Lagerwall <rosslagerwall@gmail.com>2013-10-17 07:26:05 +0200
committerRoss Lagerwall <rosslagerwall@gmail.com>2013-12-05 23:51:30 +0000
commitc3b6615e95bd213beab32d90a8bf38f1b221a8b4 (patch)
treeb18ec470be6377b527e603d58ca274bb5c48074d /client/gdaemonfile.c
parent444a63d09fdaf4db8124801ec6f4ff26ca3c7c0e (diff)
downloadgvfs-c3b6615e95bd213beab32d90a8bf38f1b221a8b4.tar.gz
Implement truncate support for output streams
Backends receive a TRUNCATE message which contains a size parameter. Truncation is signaled with a TRUNCATED message (which contains no other useful information). In more detail: Add a new dbus method, OpenForWriteFlags, which has a flags parameter to implement can_seek and can_truncate. These flags are used in GDaemonFileOutputStream. Compatability with old clients is maintained. Implement the can_truncate and truncate_fn GDaemonFileOutputStream methods. Add two new message types to the daemon socket protocol: G_VFS_DAEMON_SOCKET_PROTOCOL_REQUEST_TRUNCATE G_VFS_DAEMON_SOCKET_PROTOCOL_REPLY_TRUNCATED Add a new job type, GVfsJobTruncate. Add two new methods to GVfsBackend which backend classes can implement: truncate and try_truncate https://bugzilla.gnome.org/show_bug.cgi?id=573837
Diffstat (limited to 'client/gdaemonfile.c')
-rw-r--r--client/gdaemonfile.c66
1 files changed, 36 insertions, 30 deletions
diff --git a/client/gdaemonfile.c b/client/gdaemonfile.c
index 267ceaa3..445c9195 100644
--- a/client/gdaemonfile.c
+++ b/client/gdaemonfile.c
@@ -1238,7 +1238,7 @@ file_open_write (GFile *file,
GVfsDBusMount *proxy;
char *path;
gboolean res;
- gboolean can_seek;
+ guint32 ret_flags;
GUnixFDList *fd_list;
int fd;
GVariant *fd_id_val = NULL;
@@ -1255,20 +1255,20 @@ file_open_write (GFile *file,
if (proxy == NULL)
return NULL;
- res = gvfs_dbus_mount_call_open_for_write_sync (proxy,
- path,
- mode,
- etag,
- make_backup,
- flags,
- pid,
- NULL,
- &fd_id_val,
- &can_seek,
- &initial_offset,
- &fd_list,
- cancellable,
- &local_error);
+ res = gvfs_dbus_mount_call_open_for_write_flags_sync (proxy,
+ path,
+ mode,
+ etag,
+ make_backup,
+ flags,
+ pid,
+ NULL,
+ &fd_id_val,
+ &ret_flags,
+ &initial_offset,
+ &fd_list,
+ cancellable,
+ &local_error);
if (! res)
{
@@ -1295,7 +1295,7 @@ file_open_write (GFile *file,
g_variant_unref (fd_id_val);
g_object_unref (fd_list);
- return g_daemon_file_output_stream_new (fd, can_seek, initial_offset);
+ return g_daemon_file_output_stream_new (fd, ret_flags, initial_offset);
}
static GFileOutputStream *
@@ -3144,7 +3144,7 @@ file_open_write_async_cb (GVfsDBusMount *proxy,
AsyncCallFileReadWrite *data = user_data;
GError *error = NULL;
GSimpleAsyncResult *orig_result;
- gboolean can_seek;
+ guint32 flags;
GUnixFDList *fd_list;
int fd;
GVariant *fd_id_val;
@@ -3154,7 +3154,13 @@ file_open_write_async_cb (GVfsDBusMount *proxy,
orig_result = data->result;
- if (! gvfs_dbus_mount_call_open_for_write_finish (proxy, &fd_id_val, &can_seek, &initial_offset, &fd_list, res, &error))
+ if (! gvfs_dbus_mount_call_open_for_write_flags_finish (proxy,
+ &fd_id_val,
+ &flags,
+ &initial_offset,
+ &fd_list,
+ res,
+ &error))
{
_g_simple_async_result_take_error_stripped (orig_result, error);
goto out;
@@ -3172,7 +3178,7 @@ file_open_write_async_cb (GVfsDBusMount *proxy,
}
else
{
- output_stream = g_daemon_file_output_stream_new (fd, can_seek, initial_offset);
+ output_stream = g_daemon_file_output_stream_new (fd, flags, initial_offset);
g_simple_async_result_set_op_res_gpointer (orig_result, output_stream, g_object_unref);
g_object_unref (fd_list);
}
@@ -3201,17 +3207,17 @@ file_open_write_async_get_proxy_cb (GVfsDBusMount *proxy,
data->result = g_object_ref (result);
- gvfs_dbus_mount_call_open_for_write (proxy,
- path,
- data->mode,
- data->etag,
- data->make_backup,
- data->flags,
- pid,
- NULL,
- cancellable,
- (GAsyncReadyCallback) file_open_write_async_cb,
- data);
+ gvfs_dbus_mount_call_open_for_write_flags (proxy,
+ path,
+ data->mode,
+ data->etag,
+ data->make_backup,
+ data->flags,
+ pid,
+ NULL,
+ cancellable,
+ (GAsyncReadyCallback) file_open_write_async_cb,
+ data);
data->cancelled_tag = _g_dbus_async_subscribe_cancellable (connection, cancellable);
}