[tracker-miners/wip/carlosg/ci-updates] libtracker-miners-common: Drop unneeded function




commit 74000770363a46314fdc6802b497a25884696eed
Author: Carlos Garnacho <carlosg gnome org>
Date:   Thu Aug 12 12:52:06 2021 +0200

    libtracker-miners-common: Drop unneeded function
    
    It's a bit awkward already as it's just used by the test that
    ensures its behavior. Even more with that function failing out
    of the blue after moving to ci-fairy generated images.

 src/libtracker-miners-common/tracker-file-utils.c  | 81 ----------------------
 .../tracker-file-utils-test.c                      | 29 --------
 2 files changed, 110 deletions(-)
---
diff --git a/src/libtracker-miners-common/tracker-file-utils.c 
b/src/libtracker-miners-common/tracker-file-utils.c
index 1fdae2726..778df49aa 100644
--- a/src/libtracker-miners-common/tracker-file-utils.c
+++ b/src/libtracker-miners-common/tracker-file-utils.c
@@ -611,87 +611,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/tests/libtracker-miners-common/tracker-file-utils-test.c 
b/tests/libtracker-miners-common/tracker-file-utils-test.c
index 24551941a..d3a8bdd3e 100644
--- a/tests/libtracker-miners-common/tracker-file-utils-test.c
+++ b/tests/libtracker-miners-common/tracker-file-utils-test.c
@@ -364,33 +364,6 @@ test_file_system_get_remaining_space_percentage ()
         //space = tracker_file_system_get_remaining_space_percentage ("/unlikely/to/have/this/folder");
 }
 
-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_true (tracker_path_has_write_access_or_was_created (path));
-        g_assert_true (g_file_test (path, G_FILE_TEST_EXISTS));
-
-        /* This time exists and has write access */
-        g_assert_true (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_true (!tracker_path_has_write_access_or_was_created (path));
-
-        /* Doesn't exist and cannot be created */
-        g_assert_true (!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 ()
 {
@@ -455,8 +428,6 @@ main (int argc, char **argv)
                          test_file_system_get_remaining_space);
         g_test_add_func ("/libtracker-common/file-utils/get_remaining_space_percentage",
                          test_file_system_get_remaining_space_percentage);
-        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]