Changeset View
Changeset View
Standalone View
Standalone View
source/blender/sequencer/intern/image_cache.c
| Show First 20 Lines • Show All 279 Lines • ▼ Show 20 Lines | for (DiskCacheFile *cache_file = oldest_file->next; cache_file; cache_file = cache_file->next) { | ||||
| if (cache_file->fstat.st_mtime < oldest_file->fstat.st_mtime) { | if (cache_file->fstat.st_mtime < oldest_file->fstat.st_mtime) { | ||||
| oldest_file = cache_file; | oldest_file = cache_file; | ||||
| } | } | ||||
| } | } | ||||
| return oldest_file; | return oldest_file; | ||||
| } | } | ||||
| /* Remove all empty directories after deleting file up to disk cache base path. */ | |||||
| static void seq_disk_cache_cleanup_path(SeqDiskCache *disk_cache, DiskCacheFile *file) | |||||
| { | |||||
| char path[FILE_MAXDIR]; | |||||
| STRNCPY(path, file->dir); | |||||
| int path_level = 0; | |||||
| struct direntry *filelist; | |||||
| int file_count = BLI_filelist_dir_contents(path, &filelist); | |||||
| BLI_filelist_free(filelist, file_count); | |||||
| do { | |||||
| /* Remove "base dir" where version file is expected to be found. */ | |||||
| if (path_level == 2) { | |||||
| struct direntry *filelist; | |||||
| int file_count = BLI_filelist_dir_contents(path, &filelist); | |||||
| if (file_count == 1 && STREQ(filelist->path, "cache_version")) { | |||||
| BLI_delete(filelist->path, false, false); | |||||
| } | |||||
| BLI_filelist_free(filelist, file_count); | |||||
| } | |||||
| /* Remove lower level directories. */ | |||||
| if (BLI_dir_is_empty(path)) { | |||||
| BLI_delete(path, true, false); | |||||
| } | |||||
| path_level++; | |||||
| } while (BLI_path_parent_dir(path) && !STREQ(path, seq_disk_cache_base_dir())); | |||||
| } | |||||
| static void seq_disk_cache_delete_file(SeqDiskCache *disk_cache, DiskCacheFile *file) | static void seq_disk_cache_delete_file(SeqDiskCache *disk_cache, DiskCacheFile *file) | ||||
| { | { | ||||
| disk_cache->size_total -= file->fstat.st_size; | disk_cache->size_total -= file->fstat.st_size; | ||||
| BLI_delete(file->path, false, false); | BLI_delete(file->path, false, false); | ||||
| BLI_remlink(&disk_cache->files, file); | BLI_remlink(&disk_cache->files, file); | ||||
| seq_disk_cache_cleanup_path(disk_cache, file); | |||||
| MEM_freeN(file); | MEM_freeN(file); | ||||
| } | } | ||||
| static bool seq_disk_cache_enforce_limits(SeqDiskCache *disk_cache) | static bool seq_disk_cache_enforce_limits(SeqDiskCache *disk_cache) | ||||
| { | { | ||||
| BLI_mutex_lock(&disk_cache->read_write_mutex); | BLI_mutex_lock(&disk_cache->read_write_mutex); | ||||
| while (disk_cache->size_total > seq_disk_cache_size_limit()) { | while (disk_cache->size_total > seq_disk_cache_size_limit()) { | ||||
| DiskCacheFile *oldest_file = seq_disk_cache_get_oldest_file(disk_cache); | DiskCacheFile *oldest_file = seq_disk_cache_get_oldest_file(disk_cache); | ||||
| ▲ Show 20 Lines • Show All 1,204 Lines • Show Last 20 Lines | |||||