[tracker/wip/carlosg/test: 2/4] libtracker-common: Drop unused function and its test



commit c850c0dfbe11121877f8963896ee013158912731
Author: Carlos Garnacho <carlosg gnome org>
Date:   Tue Nov 6 10:55:02 2018 +0100

    libtracker-common: Drop unused function and its test
    
    This function is no longer used, so makes no sense to test for
    it. This test used to break on CI with the default docker images
    because of user permissions, so this obstacle is removed.

 src/libtracker-common/tracker-file-utils.c        | 81 -----------------------
 src/libtracker-common/tracker-file-utils.h        |  1 -
 tests/libtracker-common/tracker-file-utils-test.c | 29 --------
 3 files changed, 111 deletions(-)
---
diff --git a/src/libtracker-common/tracker-file-utils.c b/src/libtracker-common/tracker-file-utils.c
index ce9b7e98d..57ced9142 100644
--- a/src/libtracker-common/tracker-file-utils.c
+++ b/src/libtracker-common/tracker-file-utils.c
@@ -650,87 +650,6 @@ tracker_path_evaluate_name (const gchar *path)
        return final_path;
 }
 
-static gboolean
-path_has_write_access (const gchar *path,
-                       gboolean    *exists)
-{
-       GFile     *file;
-       GFileInfo *info;
-       GError    *error = NULL;
-       gboolean   writable;
-
-       g_return_val_if_fail (path != NULL, FALSE);
-       g_return_val_if_fail (path[0] != '\0', FALSE);
-
-       file = g_file_new_for_path (path);
-       info = g_file_query_info (file,
-                                 G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE,
-                                 0,
-                                 NULL,
-                                 &error);
-
-       if (G_UNLIKELY (error)) {
-               if (error->code == G_IO_ERROR_NOT_FOUND) {
-                       if (exists) {
-                               *exists = FALSE;
-                       }
-               } else {
-                       gchar *uri;
-
-                       uri = g_file_get_uri (file);
-                       g_warning ("Could not check if we have write access for "
-                                  "'%s': %s",
-                                  uri,
-                                  error->message);
-                       g_free (uri);
-               }
-
-               g_error_free (error);
-
-               writable = FALSE;
-       } else {
-               if (exists) {
-                       *exists = TRUE;
-               }
-
-               writable = g_file_info_get_attribute_boolean (info, G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE);
-
-               g_object_unref (info);
-       }
-
-       g_object_unref (file);
-
-       return writable;
-}
-
-gboolean
-tracker_path_has_write_access_or_was_created (const gchar *path)
-{
-       gboolean writable;
-       gboolean exists = FALSE;
-
-       writable = path_has_write_access (path, &exists);
-       if (exists) {
-               if (writable) {
-                       g_message ("  Path is OK");
-                       return TRUE;
-               }
-
-               g_message ("  Path can not be written to");
-       } else {
-               g_message ("  Path does not exist, attempting to create...");
-
-               if (g_mkdir_with_parents (path, 0700) == 0) {
-                       g_message ("  Path was created");
-                       return TRUE;
-               }
-
-               g_message ("  Path could not be created");
-       }
-
-       return FALSE;
-}
-
 gboolean
 tracker_file_is_hidden (GFile *file)
 {
diff --git a/src/libtracker-common/tracker-file-utils.h b/src/libtracker-common/tracker-file-utils.h
index 2b6beabde..45c5f9374 100644
--- a/src/libtracker-common/tracker-file-utils.h
+++ b/src/libtracker-common/tracker-file-utils.h
@@ -52,7 +52,6 @@ GSList * tracker_path_list_filter_duplicates                (GSList      *roots,
                                                              const gchar *basename_exception_prefix,
                                                              gboolean     is_recursive);
 gchar *  tracker_path_evaluate_name                         (const gchar *uri);
-gboolean tracker_path_has_write_access_or_was_created       (const gchar *path);
 gboolean tracker_filename_casecmp_without_extension         (const gchar *a,
                                                              const gchar *b);
 
diff --git a/tests/libtracker-common/tracker-file-utils-test.c 
b/tests/libtracker-common/tracker-file-utils-test.c
index d1ddf3004..93a409b37 100644
--- a/tests/libtracker-common/tracker-file-utils-test.c
+++ b/tests/libtracker-common/tracker-file-utils-test.c
@@ -367,33 +367,6 @@ test_file_system_has_enough_space ()
         //g_assert (!tracker_file_system_has_enough_space ("/home", G_MAXULONG, FALSE));
 }
 
-static void
-test_file_exists_and_writable ()
-{
-        const gchar *path = "./test-dir-remove-afterwards";
-
-        if (g_file_test (path, G_FILE_TEST_EXISTS)) {
-               g_assert_cmpint (g_remove (path), ==, 0);
-        }
-
-        /* This should create the directory with write access*/
-        g_assert (tracker_path_has_write_access_or_was_created (path));
-        g_assert (g_file_test (path, G_FILE_TEST_EXISTS));
-
-        /* This time exists and has write access */
-        g_assert (tracker_path_has_write_access_or_was_created (path));
-
-        g_assert_cmpint (chmod (path, S_IRUSR & S_IRGRP), ==, 0);
-
-        /* Exists but is not writable */
-        g_assert (!tracker_path_has_write_access_or_was_created (path));
-
-        /* Doesn't exist and cannot be created */
-        g_assert (!tracker_path_has_write_access_or_was_created ("/var/log/tracker-test"));
-
-        g_assert_cmpint (g_remove (path), ==, 0);
-}
-
 static void
 test_file_utils_is_hidden ()
 {
@@ -460,8 +433,6 @@ main (int argc, char **argv)
                          test_file_system_get_remaining_space_percentage);
         g_test_add_func ("/libtracker-common/file-utils/has_enough_space",
                          test_file_system_has_enough_space);
-        g_test_add_func ("/libtracker-common/file-utils/has_write_access_or_was_created",
-                         test_file_exists_and_writable);
         g_test_add_func ("/libtracker-common/file-utils/is_hidden",
                          test_file_utils_is_hidden);
         g_test_add_func ("/libtracker-common/file-utils/cmp",


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