Skip to content

Commit b8841de

Browse files
committed
builder-main: Prevent deleting cwd or its parents with force-clean
Building in the current directory does not make sense and cwd usually contains the manifest, files referenced in the manifest and other files. Deleting all of them is destructive. Also since state dir defaults to cwd/.flatpak-builder by default, a deletion leads to the hung state described in the previous commit. Fixes #475
1 parent 4054e73 commit b8841de

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/builder-main.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -865,10 +865,12 @@ main (int argc,
865865
g_autoptr(GFile) state_dir = builder_context_get_state_dir (build_context);
866866

867867
if (g_file_equal (app_dir, state_dir) ||
868+
g_file_equal (app_dir, cwd_dir) ||
869+
g_file_has_prefix (cwd_dir, app_dir) ||
868870
g_file_has_prefix (state_dir, app_dir))
869871
{
870-
g_printerr ("Refusing to delete state directory "
871-
"or its parents\n");
872+
g_printerr ("Refusing to delete current working directory, state directory "
873+
"or their parents\n");
872874
return 1;
873875
}
874876

0 commit comments

Comments
 (0)