diff --git a/src/builder-cache.c b/src/builder-cache.c index 1cec86fa..7f09f161 100644 --- a/src/builder-cache.c +++ b/src/builder-cache.c @@ -309,7 +309,7 @@ builder_cache_checkout (BuilderCache *self, const char *commit, gboolean delete_ if (delete_dir) { - if (!g_file_delete (self->app_dir, NULL, &my_error) && + if (!flatpak_rm_rf_children (self->app_dir, NULL, &my_error) && !g_error_matches (my_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND)) { g_propagate_error (error, g_steal_pointer (&my_error)); diff --git a/src/builder-flatpak-utils.c b/src/builder-flatpak-utils.c index ef45e89d..e270bdbf 100644 --- a/src/builder-flatpak-utils.c +++ b/src/builder-flatpak-utils.c @@ -980,6 +980,16 @@ flatpak_rm_rf (GFile *dir, cancellable, error); } +gboolean +flatpak_rm_rf_children (GFile *dir, + GCancellable *cancellable, + GError **error) +{ + return glnx_shutil_rm_rf_children_at (AT_FDCWD, + flatpak_file_get_path_cached (dir), + cancellable, error); +} + gboolean flatpak_file_rename (GFile *from, GFile *to, GCancellable *cancellable, diff --git a/src/builder-flatpak-utils.h b/src/builder-flatpak-utils.h index eba6d715..a12823ed 100644 --- a/src/builder-flatpak-utils.h +++ b/src/builder-flatpak-utils.h @@ -237,6 +237,10 @@ gboolean flatpak_rm_rf (GFile *dir, GCancellable *cancellable, GError **error); +gboolean flatpak_rm_rf_children (GFile *dir, + GCancellable *cancellable, + GError **error); + static inline void flatpak_temp_dir_destroy (void *p) { diff --git a/src/builder-main.c b/src/builder-main.c index 42f4784e..1fc7e133 100644 --- a/src/builder-main.c +++ b/src/builder-main.c @@ -782,7 +782,7 @@ main (int argc, if (opt_force_clean) { g_print ("Emptying app dir '%s'\n", app_dir_path); - if (!flatpak_rm_rf (app_dir, NULL, &error)) + if (!flatpak_rm_rf_children (app_dir, NULL, &error)) { g_printerr ("Couldn't empty app dir '%s': %s\n", app_dir_path, error->message); @@ -802,15 +802,14 @@ main (int argc, if (!opt_download_only) { g_autofree char *state_path = g_file_get_path (builder_context_get_state_dir (build_context)); - g_autoptr(GFile) app_parent = g_file_get_parent (builder_context_get_app_dir (build_context)); - g_autofree char *app_parent_path = g_file_get_path (app_parent); + g_autofree char *app_path = g_file_get_path (builder_context_get_app_dir (build_context)); struct stat buf1, buf2; - if (stat (app_parent_path, &buf1) == 0 && stat (state_path, &buf2) == 0 && + if (stat (app_path, &buf1) == 0 && stat (state_path, &buf2) == 0 && buf1.st_dev != buf2.st_dev) { g_printerr ("The state dir (%s) is not on the same filesystem as the target dir (%s)\n", - state_path, app_parent_path); + state_path, app_path); return 1; } } diff --git a/subprojects/libglnx b/subprojects/libglnx index 07e3e49d..1a503dcc 160000 --- a/subprojects/libglnx +++ b/subprojects/libglnx @@ -1 +1 @@ -Subproject commit 07e3e49d3e47dfd4265ffb5495111439131715ca +Subproject commit 1a503dcc07d57a8b7112d7991501595794397a10