[tracker] libtracker-common: Report total free space if running as root



commit bc714ea7ed34207482be2faf1d3e2babc0fcbae7
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sun Jan 17 19:26:46 2016 +0100

    libtracker-common: Report total free space if running as root
    
    For the people that want to run Tracker as a system-wide service.
    There's no "unprivileged user" limitations to obey here, so just
    report st.f_bfree instead of st.f_bavail.

 src/libtracker-common/tracker-file-utils.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
---
diff --git a/src/libtracker-common/tracker-file-utils.c b/src/libtracker-common/tracker-file-utils.c
index 123d347..0cf6cd1 100644
--- a/src/libtracker-common/tracker-file-utils.c
+++ b/src/libtracker-common/tracker-file-utils.c
@@ -290,9 +290,11 @@ guint64
 tracker_file_system_get_remaining_space (const gchar *path)
 {
        struct __statvfs st;
+       gsize available;
 
        if (statvfs_helper (path, &st)) {
-               return st.f_bsize * st.f_bavail;
+               available = (geteuid () == 0) ? st.f_bfree : st.f_bavail;
+               return st.f_bsize * available;
        } else {
                return 0;
        }
@@ -302,9 +304,11 @@ gdouble
 tracker_file_system_get_remaining_space_percentage (const gchar *path)
 {
        struct __statvfs st;
+       gsize available;
 
        if (statvfs_helper (path, &st)) {
-               return (st.f_bavail * 100.0 / st.f_blocks);
+               available = (geteuid () == 0) ? st.f_bfree : st.f_bavail;
+               return (available * 100.0 / st.f_blocks);
        } else {
                return 0.0;
        }


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