summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar bunnei2021-01-24 13:42:51 -0800
committerGravatar GitHub2021-01-24 13:42:51 -0800
commit44c5ea3639b648dbb3db8f6bcb06bff88436177b (patch)
tree0b35f01c4d0f9ec260a91e1273f069b5cd8ba143
parentMerge pull request #5814 from ReinUsesLisp/remove-rdna-dynstate (diff)
parentvfs_real: When moving files or directories, don't assume file opening will su... (diff)
downloadyuzu-44c5ea3639b648dbb3db8f6bcb06bff88436177b.tar.gz
yuzu-44c5ea3639b648dbb3db8f6bcb06bff88436177b.tar.xz
yuzu-44c5ea3639b648dbb3db8f6bcb06bff88436177b.zip
Merge pull request #5151 from comex/xx-vfs
vfs_real: When moving files or directories, don't assume file opening will succeed
-rw-r--r--src/core/file_sys/vfs_real.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/core/file_sys/vfs_real.cpp b/src/core/file_sys/vfs_real.cpp
index a287eebe3..a44ce6288 100644
--- a/src/core/file_sys/vfs_real.cpp
+++ b/src/core/file_sys/vfs_real.cpp
@@ -133,8 +133,11 @@ VirtualFile RealVfsFilesystem::MoveFile(std::string_view old_path_, std::string_
133 } 133 }
134 134
135 cache.erase(old_path); 135 cache.erase(old_path);
136 file->Open(new_path, "r+b"); 136 if (file->Open(new_path, "r+b")) {
137 cache.insert_or_assign(new_path, std::move(file)); 137 cache.insert_or_assign(new_path, std::move(file));
138 } else {
139 LOG_ERROR(Service_FS, "Failed to open path {} in order to re-cache it", new_path);
140 }
138 } else { 141 } else {
139 UNREACHABLE(); 142 UNREACHABLE();
140 return nullptr; 143 return nullptr;
@@ -214,9 +217,12 @@ VirtualDir RealVfsFilesystem::MoveDirectory(std::string_view old_path_,
214 } 217 }
215 218
216 auto file = cached.lock(); 219 auto file = cached.lock();
217 file->Open(file_new_path, "r+b");
218 cache.erase(file_old_path); 220 cache.erase(file_old_path);
219 cache.insert_or_assign(std::move(file_new_path), std::move(file)); 221 if (file->Open(file_new_path, "r+b")) {
222 cache.insert_or_assign(std::move(file_new_path), std::move(file));
223 } else {
224 LOG_ERROR(Service_FS, "Failed to open path {} in order to re-cache it", file_new_path);
225 }
220 } 226 }
221 227
222 return OpenDirectory(new_path, Mode::ReadWrite); 228 return OpenDirectory(new_path, Mode::ReadWrite);