/[gentoo-x86]/net-misc/sitecopy/files/sitecopy-0.16.6-10-bts410703-preserve-storage-files-sigint.patch
Gentoo

Contents of /net-misc/sitecopy/files/sitecopy-0.16.6-10-bts410703-preserve-storage-files-sigint.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations) (download) (as text)
Sat Jan 31 00:21:27 2015 UTC (5 years ago) by idella4
Branch: MAIN
CVS Tags: HEAD
File MIME type: text/x-diff
bump subsequent to bug #500070, new patches to match, bump EAPI, removed -0.16.6_p3, all wrt bug #500070

(Portage version: 2.2.14/cvs/Linux x86_64, signed Manifest commit with key 0xB8072B0D)

1 From: Andreas Henriksson <andreas@fatal.se>
2 Subject: Preserve storage files it SIGINT (Ctrl+C) is sent
3
4 --- sitecopy-0.16.3/src/sitestore.c 2006-02-04 11:18:08.000000000 +0100
5 +++ sitecopy-0.16.3-pending/src/sitestore.c 2008-06-08 21:56:23.000000000 +0200
6 @@ -60,17 +60,42 @@
7 /* Opens the storage file for writing */
8 FILE *site_open_storage_file(struct site *site)
9 {
10 + char filebuf[PATH_MAX];
11 +
12 + /* open a temporary "pending" file, to not corrupt the site file in case
13 + * the program aborts while we are updating it.
14 + * The site_close_storage_file() function will rename it to it's proper
15 + * name.
16 + * FIXME: something should clean up old *.pending files,
17 + * which never got properly closed.
18 + */
19 + snprintf(filebuf, sizeof(filebuf), "%s.pending", site->infofile);
20 +
21 if (site->storage_file == NULL) {
22 - site->storage_file = fopen(site->infofile, "w" FOPEN_BINARY_FLAGS);
23 + site->storage_file = fopen(filebuf, "w" FOPEN_BINARY_FLAGS);
24 }
25 return site->storage_file;
26 }
27
28 int site_close_storage_file(struct site *site)
29 {
30 - int ret = fclose(site->storage_file);
31 + char filebuf[PATH_MAX];
32 + int err;
33 +
34 + /* close filehandle */
35 + err = fclose(site->storage_file);
36 site->storage_file = NULL;
37 - return ret;
38 + if (err) {
39 + perror("fclose");
40 + return err;
41 + }
42 +
43 + /* rename pending file to real filename (overwriting existing file). */
44 + snprintf(filebuf, sizeof(filebuf), "%s.pending", site->infofile);
45 + err = rename(filebuf, site->infofile);
46 + if (err)
47 + perror("rename");
48 + return err;
49 }
50
51 /* Return escaped form of 'filename'; any XML-unsafe characters are
52

  ViewVC Help
Powered by ViewVC 1.1.20