Skip to content

Commit

Permalink
Merge pull request #86177 from KoBeWi/depren_never_forgets
Browse files Browse the repository at this point in the history
Fix file disappearing when renaming dependencies
  • Loading branch information
YuriSizov committed Dec 16, 2023
2 parents 9c425c5 + 397f0b3 commit df9be54
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions core/io/resource_format_binary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1454,8 +1454,10 @@ Error ResourceFormatLoaderBinary::rename_dependencies(const String &p_path, cons
fw.unref();

Ref<DirAccess> 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;
}

Expand Down
4 changes: 2 additions & 2 deletions scene/resources/resource_format_text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<DirAccess> da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
Ref<DirAccess> 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);
}
Expand Down

0 comments on commit df9be54

Please sign in to comment.