Skip to content

Commit

Permalink
fixed bug in cache handling
Browse files Browse the repository at this point in the history
changed files stayed in cache, but they were reported as not found,
this caused leaks and crashes
bug introduced by change of notification function,
commit 78cde69
  • Loading branch information
nadvornik committed Jul 27, 2012
1 parent d17c428 commit 3e0e566
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/exif-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,7 @@ ExifData *exif_read_fd(FileData *fd)
if (!fd || !is_readable_file(fd->path)) return NULL;

if (file_cache_get(exif_cache, fd)) return fd->exif;
g_assert(fd->exif == NULL);

/* CACHE_TYPE_XMP_METADATA file should exist only if the metadata are
* not writable directly, thus it should contain the most up-to-date version */
Expand Down
7 changes: 5 additions & 2 deletions src/filecache.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ struct _FileCacheEntry {
};

static void file_cache_notify_cb(FileData *fd, NotifyType type, gpointer data);
static void file_cache_remove_fd(FileCacheData *fc, FileData *fd);

FileCacheData *file_cache_new(FileCacheReleaseFunc release, gulong max_size)
{
Expand Down Expand Up @@ -67,9 +68,11 @@ gboolean file_cache_get(FileCacheData *fc, FileData *fd)
fc->list = g_list_remove_link(fc->list, work);
fc->list = g_list_concat(work, fc->list);

if (file_data_check_changed_files(fd)) /* this will eventually remove changed files from cache via file_cache_notify_cb */
if (file_data_check_changed_files(fd)) {
/* file has been changed, cance entry is no longer valid */
file_cache_remove_fd(fc, fd);
return FALSE;
}
if (debug_file_cache) file_cache_dump(fc);
return TRUE;
}
Expand Down

0 comments on commit 3e0e566

Please sign in to comment.