summaryrefslogtreecommitdiff
path: root/net-misc/sitecopy/files/sitecopy-0.16.6-10-bts410703-preserve-storage-files-sigint.patch
diff options
context:
space:
mode:
authorV3n3RiX <venerix@redcorelinux.org>2017-10-09 18:53:29 +0100
committerV3n3RiX <venerix@redcorelinux.org>2017-10-09 18:53:29 +0100
commit4f2d7949f03e1c198bc888f2d05f421d35c57e21 (patch)
treeba5f07bf3f9d22d82e54a462313f5d244036c768 /net-misc/sitecopy/files/sitecopy-0.16.6-10-bts410703-preserve-storage-files-sigint.patch
reinit the tree, so we can have metadata
Diffstat (limited to 'net-misc/sitecopy/files/sitecopy-0.16.6-10-bts410703-preserve-storage-files-sigint.patch')
-rw-r--r--net-misc/sitecopy/files/sitecopy-0.16.6-10-bts410703-preserve-storage-files-sigint.patch52
1 files changed, 52 insertions, 0 deletions
diff --git a/net-misc/sitecopy/files/sitecopy-0.16.6-10-bts410703-preserve-storage-files-sigint.patch b/net-misc/sitecopy/files/sitecopy-0.16.6-10-bts410703-preserve-storage-files-sigint.patch
new file mode 100644
index 000000000000..5902282357c5
--- /dev/null
+++ b/net-misc/sitecopy/files/sitecopy-0.16.6-10-bts410703-preserve-storage-files-sigint.patch
@@ -0,0 +1,52 @@
+From: Andreas Henriksson <andreas@fatal.se>
+Subject: Preserve storage files it SIGINT (Ctrl+C) is sent
+
+--- sitecopy-0.16.3/src/sitestore.c 2006-02-04 11:18:08.000000000 +0100
++++ sitecopy-0.16.3-pending/src/sitestore.c 2008-06-08 21:56:23.000000000 +0200
+@@ -60,17 +60,42 @@
+ /* Opens the storage file for writing */
+ FILE *site_open_storage_file(struct site *site)
+ {
++ char filebuf[PATH_MAX];
++
++ /* open a temporary "pending" file, to not corrupt the site file in case
++ * the program aborts while we are updating it.
++ * The site_close_storage_file() function will rename it to it's proper
++ * name.
++ * FIXME: something should clean up old *.pending files,
++ * which never got properly closed.
++ */
++ snprintf(filebuf, sizeof(filebuf), "%s.pending", site->infofile);
++
+ if (site->storage_file == NULL) {
+- site->storage_file = fopen(site->infofile, "w" FOPEN_BINARY_FLAGS);
++ site->storage_file = fopen(filebuf, "w" FOPEN_BINARY_FLAGS);
+ }
+ return site->storage_file;
+ }
+
+ int site_close_storage_file(struct site *site)
+ {
+- int ret = fclose(site->storage_file);
++ char filebuf[PATH_MAX];
++ int err;
++
++ /* close filehandle */
++ err = fclose(site->storage_file);
+ site->storage_file = NULL;
+- return ret;
++ if (err) {
++ perror("fclose");
++ return err;
++ }
++
++ /* rename pending file to real filename (overwriting existing file). */
++ snprintf(filebuf, sizeof(filebuf), "%s.pending", site->infofile);
++ err = rename(filebuf, site->infofile);
++ if (err)
++ perror("rename");
++ return err;
+ }
+
+ /* Return escaped form of 'filename'; any XML-unsafe characters are
+