summaryrefslogtreecommitdiff
path: root/daemon
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2007-09-14 08:36:31 +0000
committerAlexander Larsson <alexl@src.gnome.org>2007-09-14 08:36:31 +0000
commit27656a00e4c988249ae1f3d6b51e4525c9ae799f (patch)
tree0978bc8d9a73282a9b6e22b50ac5c150791b15bd /daemon
parent398abcd97b4c4ef35ad68c84baf9a81354762821 (diff)
downloadgvfs-27656a00e4c988249ae1f3d6b51e4525c9ae799f.tar.gz
Add etag support for close on write
2007-09-14 Alexander Larsson <alexl@redhat.com> * daemon/gvfsbackendsftp.c: Add etag support for close on write svn path=/trunk/; revision=952
Diffstat (limited to 'daemon')
-rw-r--r--daemon/gvfsbackendsftp.c93
1 files changed, 71 insertions, 22 deletions
diff --git a/daemon/gvfsbackendsftp.c b/daemon/gvfsbackendsftp.c
index d417fdac..5d246891 100644
--- a/daemon/gvfsbackendsftp.c
+++ b/daemon/gvfsbackendsftp.c
@@ -27,6 +27,7 @@
#include "gvfsjobseekread.h"
#include "gvfsjobopenforwrite.h"
#include "gvfsjobwrite.h"
+#include "gvfsjobclosewrite.h"
#include "gvfsjobseekwrite.h"
#include "gvfsjobsetdisplayname.h"
#include "gvfsjobgetinfo.h"
@@ -1814,12 +1815,12 @@ close_deleted_backup (GVfsBackendSftp *backend,
}
static void
-close_reply (GVfsBackendSftp *backend,
- int reply_type,
- GDataInputStream *reply,
- guint32 len,
- GVfsJob *job,
- gpointer user_data)
+close_write_reply (GVfsBackendSftp *backend,
+ int reply_type,
+ GDataInputStream *reply,
+ guint32 len,
+ GVfsJob *job,
+ gpointer user_data)
{
GDataOutputStream *command;
guint32 id;
@@ -1881,42 +1882,90 @@ close_reply (GVfsBackendSftp *backend,
}
}
+static void
+close_write_fstat_reply (GVfsBackendSftp *backend,
+ int reply_type,
+ GDataInputStream *reply,
+ guint32 len,
+ GVfsJob *job,
+ gpointer user_data)
+{
+ SftpHandle *handle = user_data;
+ GDataOutputStream *command;
+ GFileInfo *info;
+ const char *etag;
+ guint32 id;
+
+ if (reply_type == SSH_FXP_ATTRS)
+ {
+ info = g_file_info_new ();
+ parse_attributes (backend, info, NULL,
+ reply, NULL);
+ etag = g_file_info_get_etag (info);
+ if (etag)
+ g_vfs_job_close_write_set_etag (G_VFS_JOB_CLOSE_WRITE (job), etag);
+ g_object_unref (info);
+ }
+
+ command = new_command_stream (backend, SSH_FXP_CLOSE, &id);
+ put_data_buffer (command, handle->raw_handle);
+
+ queue_command_stream_and_free (backend, command, id, close_write_reply, G_VFS_JOB (job), handle);
+}
+
static gboolean
-try_close_read (GVfsBackend *backend,
- GVfsJobCloseRead *job,
- GVfsBackendHandle _handle)
+try_close_write (GVfsBackend *backend,
+ GVfsJobCloseWrite *job,
+ GVfsBackendHandle _handle)
{
SftpHandle *handle = _handle;
GVfsBackendSftp *op_backend = G_VFS_BACKEND_SFTP (backend);
- GDataOutputStream *command;
guint32 id;
+ GDataOutputStream *command;
- command = new_command_stream (op_backend,
- SSH_FXP_CLOSE,
- &id);
+ command = new_command_stream (op_backend, SSH_FXP_FSTAT, &id);
put_data_buffer (command, handle->raw_handle);
- queue_command_stream_and_free (op_backend, command, id, close_reply, G_VFS_JOB (job), handle);
+ queue_command_stream_and_free (op_backend, command, id, close_write_fstat_reply, G_VFS_JOB (job), handle);
return TRUE;
}
+
+static void
+close_read_reply (GVfsBackendSftp *backend,
+ int reply_type,
+ GDataInputStream *reply,
+ guint32 len,
+ GVfsJob *job,
+ gpointer user_data)
+{
+ SftpHandle *handle;
+
+ handle = user_data;
+
+ if (reply_type == SSH_FXP_STATUS)
+ result_from_status (job, reply, -1);
+ else
+ g_vfs_job_failed (job, G_IO_ERROR, G_IO_ERROR_FAILED,
+ _("Invalid reply recieved"));
+ sftp_handle_free (handle);
+}
+
static gboolean
-try_close_write (GVfsBackend *backend,
- GVfsJobCloseWrite *job,
- GVfsBackendHandle _handle)
+try_close_read (GVfsBackend *backend,
+ GVfsJobCloseRead *job,
+ GVfsBackendHandle _handle)
{
SftpHandle *handle = _handle;
GVfsBackendSftp *op_backend = G_VFS_BACKEND_SFTP (backend);
- guint32 id;
GDataOutputStream *command;
+ guint32 id;
- command = new_command_stream (op_backend,
- SSH_FXP_CLOSE,
- &id);
+ command = new_command_stream (op_backend, SSH_FXP_CLOSE, &id);
put_data_buffer (command, handle->raw_handle);
- queue_command_stream_and_free (op_backend, command, id, close_reply, G_VFS_JOB (job), handle);
+ queue_command_stream_and_free (op_backend, command, id, close_read_reply, G_VFS_JOB (job), handle);
return TRUE;
}