~ubuntu-branches/ubuntu/saucy/xchat/saucy-proposed

« back to all changes in this revision

Viewing changes to debian/patches/58_save_notify.patch

  • Committer: Package Import Robot
  • Author(s): Lorenzo De Liso
  • Date: 2012-12-03 14:57:07 UTC
  • mfrom: (2.1.13 sid)
  • Revision ID: package-import@ubuntu.com-20121203145707-h273d4aesxkvn8q9
Tags: 2.8.8-7ubuntu1
* Merge from debian unstable, remaining changes:
  - debian/patches:
    + 01_serverlist.patch: Numerous changes to default serverlist.
    + 02_ubuntu_default_server.patch: select "Ubuntu servers" by
      default.
    + 45_brand_ctcp_version.patch: Add Ubuntu brand to CTCP version
      response.
    + 70_notification_strings_shorten.patch: Shorten notification
      strings.
    + 71_fix_nick_not_to_highlight.patch: Fix "nicks not to hightlight" 
      for privmsg
    + 72_fix_accelerator_menubar_toggle.patch: correctly show F9 as 
      shortcut to toggle the menubar.
    + 73_libnotify07.patch: Cherrypick patch from upstream to quell excess 
      notifications from xchat under Gnome Shell.
    + 75_apturl-support.dpatch: Add support for linkifying apturls.
    + 76_fix_gfvs_mime_handler.patch: Make it possible to open
      irc:// URI's via gvfs.
  - debian/control:
    + Build-depend on libgtk2.0-dev (>= 2.10.0).
    + Remove conflict/replaces on xchat-gnome.
    + Drop NBS "libnotify1" dependency, just keep libnotify-bin alternative.
    + Use standards version 3.9.3
  - debian/rules: Make build independent of the python version.
* Added description to patch 76_fix_gfvs_mime_handler.patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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.
 
4
 
 
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
 
7
@@ -121,25 +121,47 @@
 
8
 notify_save (void)
 
9
 {
 
10
        int fh;
 
11
+       ssize_t nb;
 
12
        struct notify *notify;
 
13
        GSList *list = notify_list;
 
14
 
 
15
-       fh = xchat_open_file ("notify.conf", O_TRUNC | O_WRONLY | O_CREAT, 0600, XOF_DOMODE);
 
16
-       if (fh != -1)
 
17
+       fh = xchat_open_file ("notify.conf.bug147832", O_TRUNC | O_WRONLY | O_CREAT, 0600, XOF_DOMODE);
 
18
+       if( fh == -1 )
 
19
        {
 
20
+               perror( "notify_save: xchat_open_file failed" );
 
21
+               return;
 
22
+       }
 
23
+       else
 
24
+       {
 
25
+               nb = 1;
 
26
                while (list)
 
27
                {
 
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));
 
31
                        if (notify->networks)
 
32
                        {
 
33
-                               write (fh, " ", 1);
 
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));
 
37
                        }
 
38
-                       write (fh, "\n", 1);
 
39
+                       if( nb > 0 ) nb = write (fh, "\n", 1);
 
40
                        list = list->next;
 
41
                }
 
42
-               close (fh);
 
43
+               if( nb <= 0 )
 
44
+               {
 
45
+                       fprintf( stderr, "notify_save: fprintf() failed\n" );
 
46
+                       close( fh );
 
47
+                       return;
 
48
+               }
 
49
+               if( close (fh) != 0 )
 
50
+               {
 
51
+                       perror( "notify_save: close failed" );
 
52
+                       return;
 
53
+               }
 
54
+               if( xchat_rename_file( "notify.conf.bug147832", "notify.conf", XOF_DOMODE ) != 0 )
 
55
+               {
 
56
+                       perror( "notify_save: xchat_rename_file() failed" );
 
57
+                       return;
 
58
+               }
 
59
        }
 
60
 }
 
61