From bc7bfeef6fc2f49c19ed94e91b903b0b454820b5 Mon Sep 17 00:00:00 2001 From: Tristan Van Berkom Date: Wed, 27 Apr 2016 00:32:31 +0100 Subject: [PATCH] BuilderSourceFile: Delete destination file Sometimes you want to replace an existing file, like a config.sub, and sometimes that existing config.sub does not have the writable bits set. Just delete the file if we intend to replace it anyway. --- builder/builder-source-file.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/builder/builder-source-file.c b/builder/builder-source-file.c index 688dfe62..960810f0 100644 --- a/builder/builder-source-file.c +++ b/builder/builder-source-file.c @@ -366,6 +366,12 @@ builder_source_file_extract (BuilderSource *source, dest_file = g_file_get_child (dest, dest_filename); + /* If the destination file exists, just delete it. We can encounter errors when + * trying to overwrite files that are not writable. + */ + if (g_file_query_exists (dest_file, NULL) && !g_file_delete (dest_file, NULL, error)) + return FALSE; + if (is_inline) { g_autoptr(GBytes) content = NULL;