[gvfs/gnome-3-12] smb: Fail properly if set_attribute type is wrong



commit 41ee38734dcc39ecbc3783a12b813ce7081229c0
Author: Ross Lagerwall <rosslagerwall gmail com>
Date:   Tue May 27 18:44:20 2014 +0100

    smb: Fail properly if set_attribute type is wrong
    
    If given an invalid type when setting time::modified in
    do_set_attribute, don't try and change the mtime after failing the job.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=730844

 daemon/gvfsbackendsmb.c |   20 +++++++++++---------
 1 files changed, 11 insertions(+), 9 deletions(-)
---
diff --git a/daemon/gvfsbackendsmb.c b/daemon/gvfsbackendsmb.c
index af9df90..07b1ead 100644
--- a/daemon/gvfsbackendsmb.c
+++ b/daemon/gvfsbackendsmb.c
@@ -1864,7 +1864,17 @@ do_set_attribute (GVfsBackend *backend,
 
   if (strcmp (attribute, G_FILE_ATTRIBUTE_TIME_MODIFIED) == 0)
     {
-      if (type != G_FILE_ATTRIBUTE_TYPE_UINT64) 
+      if (type == G_FILE_ATTRIBUTE_TYPE_UINT64)
+        {
+         smbc_utimes = smbc_getFunctionUtimes (op_backend->smb_context);
+         tbuf[1].tv_sec = (*(guint64 *)value_p);  /* mtime */
+         tbuf[1].tv_usec = 0;
+         /* atime = mtime (atimes are usually disabled on desktop systems) */
+         tbuf[0].tv_sec = tbuf[1].tv_sec;
+         tbuf[0].tv_usec = 0;
+         res = smbc_utimes (op_backend->smb_context, uri, &tbuf[0]);
+       }
+      else
         {
           g_vfs_job_failed (G_VFS_JOB (job),
                             G_IO_ERROR,
@@ -1872,14 +1882,6 @@ do_set_attribute (GVfsBackend *backend,
                             "%s",
                             _("Invalid attribute type (uint64 expected)"));
         }
-
-      smbc_utimes = smbc_getFunctionUtimes (op_backend->smb_context);
-      tbuf[1].tv_sec = (*(guint64 *)value_p);  /* mtime */
-      tbuf[1].tv_usec = 0;
-      /* atime = mtime (atimes are usually disabled on desktop systems) */
-      tbuf[0].tv_sec = tbuf[1].tv_sec;  
-      tbuf[0].tv_usec = 0;
-      res = smbc_utimes (op_backend->smb_context, uri, &tbuf[0]);
     }
 #if 0
   else


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]