1
Write to temporary file and then rename.
2
Same approach like I did for bug 463072.
3
Fixes loss of data when disk is full.
5
--- ../orig/xchat-2.8.8/./src/common/notify.c 2009-08-16 09:40:16.000000000 +0000
6
+++ ./src/common/notify.c 2012-09-30 12:53:27.000000000 +0000
12
struct notify *notify;
13
GSList *list = notify_list;
15
- fh = xchat_open_file ("notify.conf", O_TRUNC | O_WRONLY | O_CREAT, 0600, XOF_DOMODE);
17
+ fh = xchat_open_file ("notify.conf.bug147832", O_TRUNC | O_WRONLY | O_CREAT, 0600, XOF_DOMODE);
20
+ perror( "notify_save: xchat_open_file failed" );
28
notify = (struct notify *) list->data;
29
- write (fh, notify->name, strlen (notify->name));
30
+ if( nb > 0 ) nb = write (fh, notify->name, strlen (notify->name));
34
- write (fh, notify->networks, strlen (notify->networks));
35
+ if( nb > 0 ) nb = write (fh, " ", 1);
36
+ if( nb > 0 ) nb = write (fh, notify->networks, strlen (notify->networks));
38
- write (fh, "\n", 1);
39
+ if( nb > 0 ) nb = write (fh, "\n", 1);
45
+ fprintf( stderr, "notify_save: fprintf() failed\n" );
49
+ if( close (fh) != 0 )
51
+ perror( "notify_save: close failed" );
54
+ if( xchat_rename_file( "notify.conf.bug147832", "notify.conf", XOF_DOMODE ) != 0 )
56
+ perror( "notify_save: xchat_rename_file() failed" );