[gvfs] afp: Report number of bytes used on the filesystem



commit 2965194d8479e83dfa6e2ef0b0302aea2762dae3
Author: Ross Lagerwall <rosslagerwall gmail com>
Date:   Mon Nov 11 20:51:12 2013 +0200

    afp: Report number of bytes used on the filesystem
    
    Calculate the number of bytes used by subtracting the size from the
    number of bytes free, as done with local files.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=711859

 daemon/gvfsafpvolume.c  |   11 +++++++----
 daemon/gvfsbackendafp.c |    6 ++++++
 2 files changed, 13 insertions(+), 4 deletions(-)
---
diff --git a/daemon/gvfsafpvolume.c b/daemon/gvfsafpvolume.c
index 1ad8cd7..e5f08e2 100644
--- a/daemon/gvfsafpvolume.c
+++ b/daemon/gvfsafpvolume.c
@@ -183,6 +183,8 @@ get_vol_parms_cb (GObject *source_object, GAsyncResult *res, gpointer user_data)
   guint16 vol_bitmap;
   GFileInfo *info;
 
+  guint64 bytes_free, bytes_total;
+
   reply = g_vfs_afp_connection_send_command_finish (connection, res, &err);
   if (!reply)
   {
@@ -239,8 +241,6 @@ get_vol_parms_cb (GObject *source_object, GAsyncResult *res, gpointer user_data)
 
   if (vol_bitmap & AFP_VOLUME_BITMAP_EXT_BYTES_FREE_BIT)
   {
-    guint64 bytes_free;
-
     g_vfs_afp_reply_read_uint64 (reply, &bytes_free);
     g_file_info_set_attribute_uint64 (info, G_FILE_ATTRIBUTE_FILESYSTEM_FREE,
                                       bytes_free);
@@ -248,13 +248,16 @@ get_vol_parms_cb (GObject *source_object, GAsyncResult *res, gpointer user_data)
 
   if (vol_bitmap & AFP_VOLUME_BITMAP_EXT_BYTES_TOTAL_BIT)
   {
-    guint64 bytes_total;
-
     g_vfs_afp_reply_read_uint64 (reply, &bytes_total);
     g_file_info_set_attribute_uint64 (info, G_FILE_ATTRIBUTE_FILESYSTEM_SIZE,
                                       bytes_total);
   }
 
+  if (vol_bitmap & AFP_VOLUME_BITMAP_EXT_BYTES_FREE_BIT &&
+      vol_bitmap & AFP_VOLUME_BITMAP_EXT_BYTES_TOTAL_BIT)
+    g_file_info_set_attribute_uint64 (info, G_FILE_ATTRIBUTE_FILESYSTEM_USED,
+                                      bytes_total - bytes_free);
+
   g_object_unref (reply);
   
   g_simple_async_result_set_op_res_gpointer (simple, info, g_object_unref);
diff --git a/daemon/gvfsbackendafp.c b/daemon/gvfsbackendafp.c
index 510ce87..2ab2663 100644
--- a/daemon/gvfsbackendafp.c
+++ b/daemon/gvfsbackendafp.c
@@ -1788,6 +1788,12 @@ try_query_fs_info (GVfsBackend *backend,
   if (g_file_attribute_matcher_matches (matcher, G_FILE_ATTRIBUTE_FILESYSTEM_FREE))
     vol_bitmap |= AFP_VOLUME_BITMAP_EXT_BYTES_FREE_BIT;
 
+  if (g_file_attribute_matcher_matches (matcher, G_FILE_ATTRIBUTE_FILESYSTEM_USED))
+  {
+    vol_bitmap |= AFP_VOLUME_BITMAP_EXT_BYTES_TOTAL_BIT;
+    vol_bitmap |= AFP_VOLUME_BITMAP_EXT_BYTES_FREE_BIT;
+  }
+
   if (g_file_attribute_matcher_matches (matcher, G_FILE_ATTRIBUTE_FILESYSTEM_READONLY))
     vol_bitmap |= AFP_VOLUME_BITMAP_ATTRIBUTE_BIT;
 


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