gvfs r1867 - in trunk: . daemon
- From: jessevdk svn gnome org
- To: svn-commits-list gnome org
- Subject: gvfs r1867 - in trunk: . daemon
- Date: Tue, 5 Aug 2008 20:54:21 +0000 (UTC)
Author: jessevdk
Date: Tue Aug 5 20:54:21 2008
New Revision: 1867
URL: http://svn.gnome.org/viewvc/gvfs?rev=1867&view=rev
Log:
Added restoring file permissions when replacing a file.
Modified:
trunk/ChangeLog
trunk/daemon/gvfsbackendsftp.c
Modified: trunk/daemon/gvfsbackendsftp.c
==============================================================================
--- trunk/daemon/gvfsbackendsftp.c (original)
+++ trunk/daemon/gvfsbackendsftp.c Tue Aug 5 20:54:21 2008
@@ -119,6 +119,7 @@
goffset offset;
char *filename;
char *tempname;
+ guint32 permissions;
gboolean make_backup;
} SftpHandle;
@@ -2237,6 +2238,28 @@
sftp_handle_free (handle);
}
+static void
+close_restore_permissions (GVfsBackendSftp *backend,
+ int reply_type,
+ GDataInputStream *reply,
+ guint32 len,
+ GVfsJob *job,
+ gpointer user_data)
+{
+ GDataOutputStream *command;
+ SftpHandle *handle;
+
+ handle = user_data;
+
+ /* Here we don't really care whether or not setting the permissions succeeded
+ or not. We just take the last step and rename the temp file to the
+ actual file */
+ command = new_command_stream (backend,
+ SSH_FXP_RENAME);
+ put_string (command, handle->tempname);
+ put_string (command, handle->filename);
+ queue_command_stream_and_free (backend, command, close_moved_tempfile, G_VFS_JOB (job), handle);
+}
static void
close_deleted_file (GVfsBackendSftp *backend,
@@ -2263,13 +2286,13 @@
if (res)
{
- /* Removed original file, now move new file in place */
-
+ /* Removed original file, now first try to restore permissions */
command = new_command_stream (backend,
- SSH_FXP_RENAME);
+ SSH_FXP_SETSTAT);
put_string (command, handle->tempname);
- put_string (command, handle->filename);
- queue_command_stream_and_free (backend, command, close_moved_tempfile, G_VFS_JOB (job), handle);
+ g_data_output_stream_put_uint32 (command, SSH_FILEXFER_ATTR_PERMISSIONS, NULL, NULL);
+ g_data_output_stream_put_uint32 (command, handle->permissions, NULL, NULL);
+ queue_command_stream_and_free (backend, command, close_restore_permissions, G_VFS_JOB (job), handle);
}
else
{
@@ -2673,6 +2696,7 @@
handle = sftp_handle_new (reply);
handle->filename = g_strdup (op_job->filename);
handle->tempname = g_strdup (data->tempname);
+ handle->permissions = data->permissions;
handle->make_backup = op_job->make_backup;
g_vfs_job_open_for_write_set_handle (op_job, handle);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]