From d5114746a5466809f48c96856a4ff46f9942c626 Mon Sep 17 00:00:00 2001 From: vanadiae Date: Tue, 25 Apr 2023 21:29:48 +0200 Subject: [PATCH] context: Create CACHEDIR.TAG file in state dir This makes it possible for backup software to detect and ignore the whole folder. Fixes #360 --- src/builder-context.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/builder-context.c b/src/builder-context.c index 32f8be7b..121156dd 100644 --- a/src/builder-context.c +++ b/src/builder-context.c @@ -524,11 +524,21 @@ builder_context_allocate_build_subdir (BuilderContext *self, { g_autoptr(GError) my_error = NULL; int count; + g_autoptr (GFile) cachedir_tag = g_file_get_child (self->state_dir, "CACHEDIR.TAG"); if (!flatpak_mkdir_p (self->build_dir, NULL, error)) return NULL; + const char *cachedir_tag_content = "Signature: 8a477f597d28d172789f06886806bc55\n" + "# This file is a cache directory tag created by flatpak-builder.\n" + "# For information about cache directory tags see https://bford.info/cachedir/"; + if (!g_file_replace_contents (cachedir_tag, cachedir_tag_content, + strlen (cachedir_tag_content), NULL, FALSE, + G_FILE_CREATE_REPLACE_DESTINATION, + NULL, NULL, error)) + return NULL; + for (count = 1; count < 1000; count++) { g_autofree char *buildname = NULL;