Mercurial > pidgin
diff src/account.c @ 11303:10066662176a
[gaim-migrate @ 13503]
For accounts, store only the basename of a buddy icon cache file. Everyone please make sure buddy icons still work for you.
committer: Tailor Script <tailor@pidgin.im>
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Thu, 18 Aug 2005 20:49:58 +0000 |
parents | e26b3f52b6f2 |
children | d3b567926e8f |
line wrap: on
line diff
--- a/src/account.c Thu Aug 18 20:05:20 2005 +0000 +++ b/src/account.c Thu Aug 18 20:49:58 2005 +0000 @@ -1210,6 +1210,31 @@ { g_return_if_fail(account != NULL); + /* Delete an existing icon from the cache. */ + if (account->buddy_icon != NULL && (icon == NULL || strcmp(account->buddy_icon, icon))) + { + const char *dirname = gaim_buddy_icons_get_cache_dir(); + struct stat st; + + if (g_stat(account->buddy_icon, &st) == 0) + { + /* The file exists. This is a full path. */ + + /* XXX: This is a hack so we only delete the file if it's + * in the cache dir. Otherwise, people who upgrade (who + * may have buddy icon filenames set outside of the cache + * dir) could lose files. */ + if (!strncmp(dirname, account->buddy_icon, strlen(dirname))) + g_unlink(account->buddy_icon); + } + else + { + char *filename = g_build_filename(dirname, account->buddy_icon, NULL); + g_unlink(filename); + g_free(filename); + } + } + g_free(account->buddy_icon); account->buddy_icon = (icon == NULL ? NULL : g_strdup(icon)); if (gaim_account_is_connected(account)) @@ -1940,6 +1965,9 @@ /* Remove this account's pounces */ gaim_pounce_destroy_all_by_account(account); + /* This will cause the deletion of an old buddy icon. */ + gaim_account_set_buddy_icon(account, NULL); + gaim_account_destroy(account); }