im.pidgin.pidgin: cec0c280a13375cdc15bb2644fceafc4f4181e8a
seanegan at pidgin.im
seanegan at pidgin.im
Mon Dec 17 02:50:55 EST 2007
-----------------------------------------------------------------
Revision: cec0c280a13375cdc15bb2644fceafc4f4181e8a
Ancestor: 5f896091e0d9891541784e7724b9ec0a313f7f01
Author: seanegan at pidgin.im
Date: 2007-12-17T07:29:39
Branch: im.pidgin.pidgin
Modified files:
libpurple/buddyicon.c
ChangeLog:
Patch from eperez to make writing to buddy icon files atomic. Fixes #3528.
-------------- next part --------------
============================================================
--- libpurple/buddyicon.c 5012ea05ae0c7f6c75ffcd988467cf4181ee728c
+++ libpurple/buddyicon.c bb7903618e427e16ddb48b5e26c527576d12010b
@@ -98,8 +98,7 @@ purple_buddy_icon_data_cache(PurpleStore
{
const char *dirname;
char *path;
- FILE *file = NULL;
-
+
g_return_if_fail(img != NULL);
if (!purple_buddy_icons_is_caching())
@@ -120,24 +119,12 @@ purple_buddy_icon_data_cache(PurpleStore
}
}
- if ((file = g_fopen(path, "wb")) != NULL)
- {
- if (!fwrite(purple_imgstore_get_data(img), purple_imgstore_get_size(img), 1, file))
- {
- purple_debug_error("buddyicon", "Error writing %s: %s\n",
- path, g_strerror(errno));
- }
- else
- purple_debug_info("buddyicon", "Wrote cache file: %s\n", path);
-
- fclose(file);
- }
- else
- {
+ if (!g_file_test(path, G_FILE_TEST_EXISTS)) {
+ purple_util_write_data_to_file_absolute(path, purple_imgstore_get_data(img),
+ purple_imgstore_get_size(img));
+ } else {
purple_debug_error("buddyicon", "Unable to create file %s: %s\n",
path, g_strerror(errno));
- g_free(path);
- return;
}
g_free(path);
}
More information about the Commits
mailing list