summaryrefslogtreecommitdiff
path: root/tests/ephy-file-helpers-test.c
diff options
context:
space:
mode:
authorCarlos Garcia Campos <cgarcia@igalia.com>2014-12-01 11:17:12 +0100
committerCarlos Garcia Campos <carlosgc@gnome.org>2014-12-01 17:52:21 +0100
commit331e681810d9b0af3ed66318f6c11e52e069616e (patch)
tree8d51332a5cbb149ca38a846cf5def69a230097dd /tests/ephy-file-helpers-test.c
parent947c026218fd687722035b9cf39063b92c9f5239 (diff)
downloadepiphany-331e681810d9b0af3ed66318f6c11e52e069616e.tar.gz
file-helpers: Fix ephy_file_delete_dir_recursively when an error is given
The implementation is checking the given error pointer to check if an error ocurred, instead of checking the pointer pointed by the passed in error. This means that it is always failing when an error is passed, but it works in most of the cases when NULL is passed because the return value of functions is checked too. There's still a problem when g_file_enumerator_next_file() returns NULL, because in case of error we are considering it as end of enumeration. We can simplify the implementation and the caller code, by using the stdio API instead of GIO, since we know we are dealing with local files anyway and we are using the synchronous API.
Diffstat (limited to 'tests/ephy-file-helpers-test.c')
-rw-r--r--tests/ephy-file-helpers-test.c17
1 files changed, 5 insertions, 12 deletions
diff --git a/tests/ephy-file-helpers-test.c b/tests/ephy-file-helpers-test.c
index c33c1da82..43d000917 100644
--- a/tests/ephy-file-helpers-test.c
+++ b/tests/ephy-file-helpers-test.c
@@ -89,17 +89,12 @@ test_ephy_file_helpers_init (void)
/* Cleanup dir left behind. */
if (keep_dir) {
- GFile *file;
-
- file = g_file_new_for_path (tmp_dir);
/* As a safety measure, only try recursive delete on paths
* prefixed with /tmp. */
if (g_str_has_prefix (tmp_dir, "/tmp"))
- g_assert (ephy_file_delete_dir_recursively (file, NULL));
+ g_assert (ephy_file_delete_dir_recursively (tmp_dir, NULL));
else
g_warning ("INIT: dangerous path returned as tmp_dir: %s", tmp_dir);
-
- g_object_unref (file);
}
g_free (tmp_dir);
@@ -184,8 +179,8 @@ test_ephy_file_create_delete_dir (void)
ephy_file_helpers_init (NULL, EPHY_FILE_HELPERS_PRIVATE_PROFILE, NULL);
for (i = 0; i < G_N_ELEMENTS (dir_tests); i++) {
- GFile *file = NULL;
DirTest test;
+ GError *error = NULL;
test = dir_tests[i];
@@ -195,14 +190,12 @@ test_ephy_file_create_delete_dir (void)
g_assert (ephy_ensure_dir_exists (test.dir, NULL) == (test.exists || test.can_create));
g_assert (g_file_test (test.dir, G_FILE_TEST_EXISTS) == (test.exists || test.can_create));
- file = g_file_new_for_path (test.dir);
-
- g_assert (ephy_file_delete_dir_recursively (file, NULL) == test.can_delete);
+ g_assert (ephy_file_delete_dir_recursively (test.dir, &error) == test.can_delete);
+ if (error)
+ g_error_free (error);
if (test.exists)
g_assert (g_file_test (test.dir, G_FILE_TEST_EXISTS) != test.can_delete);
-
- g_object_unref (file);
}
ephy_file_helpers_shutdown ();