From a5d86c132710b5cdf05fce971cca845be17a175a Mon Sep 17 00:00:00 2001 From: kobewi Date: Sun, 14 Jul 2024 19:51:29 +0200 Subject: [PATCH] Don't attempt to re-import broken files if they didn't change --- editor/editor_file_system.cpp | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp index 4664defa59..18caf3b21f 100644 --- a/editor/editor_file_system.cpp +++ b/editor/editor_file_system.cpp @@ -435,11 +435,6 @@ bool EditorFileSystem::_test_for_reimport(const String &p_path, bool p_only_impo return true; } - if (!ResourceFormatImporter::get_singleton()->are_import_settings_valid(p_path)) { - //reimport settings are not valid, reimport - return true; - } - Error err; Ref f = FileAccess::open(p_path + ".import", FileAccess::READ, &err); @@ -2445,16 +2440,14 @@ Error EditorFileSystem::_reimport_file(const String &p_file, const HashMapimport(p_file, base_path, params, &import_variants, &gen_files, &meta); - ERR_FAIL_COND_V_MSG(err != OK, ERR_FILE_UNRECOGNIZED, "Error importing '" + p_file + "'."); - - //as import is complete, save the .import file + // As import is complete, save the .import file. Vector dest_paths; { Ref f = FileAccess::open(p_file + ".import", FileAccess::WRITE); ERR_FAIL_COND_V_MSG(f.is_null(), ERR_FILE_CANT_OPEN, "Cannot open file from path '" + p_file + ".import'."); - //write manually, as order matters ([remap] has to go first for performance). + // Write manually, as order matters ([remap] has to go first for performance). f->store_line("[remap]"); f->store_line(""); f->store_line("importer=\"" + importer->get_importer_name() + "\""); @@ -2470,7 +2463,7 @@ Error EditorFileSystem::_reimport_file(const String &p_file, const HashMapcreate_id(); } - f->store_line("uid=\"" + ResourceUID::get_singleton()->id_to_text(uid) + "\""); //store in readable format + f->store_line("uid=\"" + ResourceUID::get_singleton()->id_to_text(uid) + "\""); // Store in readable format. if (err == OK) { if (importer->get_save_extension().is_empty()) { @@ -2525,13 +2518,14 @@ Error EditorFileSystem::_reimport_file(const String &p_file, const HashMapstore_line("dest_files=" + Variant(dp).get_construct_string() + "\n"); + f->store_line("dest_files=" + Variant(dp).get_construct_string()); } + f->store_line(""); f->store_line("[params]"); f->store_line(""); - //store options in provided order, to avoid file changing. Order is also important because first match is accepted first. + // Store options in provided order, to avoid file changing. Order is also important because first match is accepted first. for (const ResourceImporter::ImportOption &E : opts) { String base = E.option.name; @@ -2555,7 +2549,7 @@ Error EditorFileSystem::_reimport_file(const String &p_file, const HashMapfiles[cpos]->modified_time = FileAccess::get_modified_time(p_file); fs->files[cpos]->import_modified_time = FileAccess::get_modified_time(p_file + ".import"); fs->files[cpos]->deps = _get_dependencies(p_file); @@ -2569,8 +2563,8 @@ Error EditorFileSystem::_reimport_file(const String &p_file, const HashMapadd_id(uid, p_file); } - //if file is currently up, maybe the source it was loaded from changed, so import math must be updated for it - //to reload properly + // If file is currently up, maybe the source it was loaded from changed, so import math must be updated for it + // to reload properly. Ref r = ResourceCache::get_ref(p_file); if (r.is_valid()) { if (!r->get_import_path().is_empty()) { @@ -2584,6 +2578,7 @@ Error EditorFileSystem::_reimport_file(const String &p_file, const HashMapget_ticks_msec() - start_time)); + ERR_FAIL_COND_V_MSG(err != OK, ERR_FILE_UNRECOGNIZED, "Error importing '" + p_file + "'."); return OK; }