diff options
author | Antony Riakiotakis <kalast@gmail.com> | 2015-01-30 18:00:30 +0300 |
---|---|---|
committer | Antony Riakiotakis <kalast@gmail.com> | 2015-01-30 18:00:30 +0300 |
commit | b58b182753e50aa10a1e5c7d152d5787aae433e0 (patch) | |
tree | c51a8c3c13691f684b2c823f021a5518b2959abd /source/blender/imbuf/intern/indexer.c | |
parent | f7e8da6f5a5353c20a229e74d768384b5b1e5794 (diff) |
Get rid of the file touch hack.
If user cancels, there's an issue with leftover files.
Instead use a hash to record files that have akready been registered for
generation and skip them if so.
That should guarantee things will go smoothly and when a file exists it
is assumed to be valid.
Diffstat (limited to 'source/blender/imbuf/intern/indexer.c')
-rw-r--r-- | source/blender/imbuf/intern/indexer.c | 40 |
1 files changed, 23 insertions, 17 deletions
diff --git a/source/blender/imbuf/intern/indexer.c b/source/blender/imbuf/intern/indexer.c index 8b62555a05c..d0281744830 100644 --- a/source/blender/imbuf/intern/indexer.c +++ b/source/blender/imbuf/intern/indexer.c @@ -35,6 +35,7 @@ #include "BLI_path_util.h" #include "BLI_string.h" #include "BLI_fileops.h" +#include "BLI_ghash.h" #include "IMB_indexer.h" #include "IMB_anim.h" @@ -1149,11 +1150,30 @@ static void index_rebuild_fallback(FallbackIndexBuilderContext *context, IndexBuildContext *IMB_anim_index_rebuild_context(struct anim *anim, IMB_Timecode_Type tcs_in_use, IMB_Proxy_Size proxy_sizes_in_use, int quality, - const bool overwrite) + const bool overwrite, GSet *file_list) { IndexBuildContext *context = NULL; IMB_Proxy_Size proxy_sizes_to_build = proxy_sizes_in_use; int i; + + /* Don't generate the same file twice! */ + if (file_list) { + for (i = 0; i < IMB_PROXY_MAX_SLOT; ++i) { + IMB_Proxy_Size proxy_size = proxy_sizes[i]; + if (proxy_size & proxy_sizes_to_build) { + char filename[FILE_MAX]; + get_proxy_filename(anim, proxy_size, filename, false); + + if (BLI_gset_haskey(file_list, filename)) { + proxy_sizes_to_build &= ~proxy_size; + printf("Proxy: %s already registered for generation, skipping\n", filename); + } + else { + BLI_gset_insert(file_list, BLI_strdup(filename)); + } + } + } + } if (!overwrite) { IMB_Proxy_Size built_proxies = IMB_anim_proxy_get_existing(anim); @@ -1166,26 +1186,12 @@ IndexBuildContext *IMB_anim_index_rebuild_context(struct anim *anim, IMB_Timecod get_proxy_filename(anim, proxy_size, filename, false); printf("Skipping proxy: %s\n", filename); } - /* if file doesn't exist, create it here so subsequent runs won't re-add it for generation */ - else if (proxy_size & proxy_sizes_to_build) { - char filename[FILE_MAX]; - get_proxy_filename(anim, proxy_size, filename, false); - BLI_file_touch(filename); - } - } - } - else { - for (i = 0; i < IMB_PROXY_MAX_SLOT; ++i) { - IMB_Proxy_Size proxy_size = proxy_sizes[i]; - if (proxy_size & proxy_sizes_to_build) { - char filename[FILE_MAX]; - get_proxy_filename(anim, proxy_size, filename, false); - BLI_file_touch(filename); - } } } proxy_sizes_to_build &= ~built_proxies; } + + fflush(stdout); if (proxy_sizes_to_build == 0) { return NULL; |