Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve handling of a symlinked application directory #557

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/builder-cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
10 changes: 10 additions & 0 deletions src/builder-flatpak-utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions src/builder-flatpak-utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
9 changes: 4 additions & 5 deletions src/builder-main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
}
}
Expand Down
2 changes: 1 addition & 1 deletion subprojects/libglnx
Submodule libglnx updated from 07e3e4 to 1a503d
Loading