changeset 2014:b3bc1aa2d666

fixed bug in cache handling 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 78cde6934008f79fe498e4adc64d187b0ed47417
author Vladimir Nadvornik <nadvornik@suse.cz>
date Fri, 27 Jul 2012 15:03:58 +0200
parents 512ff8b8f325
children cb2fb10d84b3
files src/exif-common.c src/filecache.c
diffstat 2 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/exif-common.c	Thu Jul 26 16:02:52 2012 +0200
+++ b/src/exif-common.c	Fri Jul 27 15:03:58 2012 +0200
@@ -652,6 +652,7 @@
 	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 */
--- a/src/filecache.c	Thu Jul 26 16:02:52 2012 +0200
+++ b/src/filecache.c	Fri Jul 27 15:03:58 2012 +0200
@@ -32,6 +32,7 @@
 };
 
 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)
 {
@@ -67,9 +68,11 @@
 			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;
 			}