diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp index 2a33f723dc8..20c494516be 100644 --- a/core/io/resource_format_binary.cpp +++ b/core/io/resource_format_binary.cpp @@ -1454,8 +1454,10 @@ Error ResourceFormatLoaderBinary::rename_dependencies(const String &p_path, cons fw.unref(); Ref da = DirAccess::create(DirAccess::ACCESS_RESOURCES); - da->remove(p_path); - da->rename(p_path + ".depren", p_path); + if (da->exists(p_path + ".depren")) { + da->remove(p_path); + da->rename(p_path + ".depren", p_path); + } return OK; } diff --git a/scene/resources/resource_format_text.cpp b/scene/resources/resource_format_text.cpp index 3dc920c4be4..037cd32f10f 100644 --- a/scene/resources/resource_format_text.cpp +++ b/scene/resources/resource_format_text.cpp @@ -1790,8 +1790,8 @@ Error ResourceFormatLoaderText::rename_dependencies(const String &p_path, const err = loader.rename_dependencies(f, p_path, p_map); } - if (err == OK) { - Ref da = DirAccess::create(DirAccess::ACCESS_RESOURCES); + Ref da = DirAccess::create(DirAccess::ACCESS_RESOURCES); + if (err == OK && da->file_exists(p_path + ".depren")) { da->remove(p_path); da->rename(p_path + ".depren", p_path); }