]> git.seodisparate.com - SimpleArchiver/commitdiff
Fix case when archiving from read-only directory
authorStephen Seo <seo.disparate@gmail.com>
Wed, 25 Dec 2024 12:16:52 +0000 (21:16 +0900)
committerStephen Seo <seo.disparate@gmail.com>
Wed, 25 Dec 2024 12:16:52 +0000 (21:16 +0900)
A temporary file is usually created to store compressed archive
chunks/files which is located where the files are. This commit
falls-back to using `tmpfile()` if the first attempt to create a
temporary file fails.

src/archiver.c

index 4534ca651d27fa334cf5590256cb4ed5f809976f..c0c9aafba018c031ef327215bbdbc529f33c4e21 100644 (file)
@@ -3602,7 +3602,10 @@ int simple_archiver_write_v2(FILE *out_f, SDArchiverState *state,
       }
 
       if (!temp_fd) {
-        return SDAS_INTERNAL_ERROR;
+        temp_fd = tmpfile();
+        if (!temp_fd) {
+          return SDAS_INTERNAL_ERROR;
+        }
       }
 
       // Handle SIGPIPE.