mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-23 07:12:46 +01:00
Merge pull request #5151 from comex/xx-vfs
vfs_real: When moving files or directories, don't assume file opening will succeed
This commit is contained in:
commit
44c5ea3639
1 changed files with 10 additions and 4 deletions
|
@ -133,8 +133,11 @@ VirtualFile RealVfsFilesystem::MoveFile(std::string_view old_path_, std::string_
|
||||||
}
|
}
|
||||||
|
|
||||||
cache.erase(old_path);
|
cache.erase(old_path);
|
||||||
file->Open(new_path, "r+b");
|
if (file->Open(new_path, "r+b")) {
|
||||||
cache.insert_or_assign(new_path, std::move(file));
|
cache.insert_or_assign(new_path, std::move(file));
|
||||||
|
} else {
|
||||||
|
LOG_ERROR(Service_FS, "Failed to open path {} in order to re-cache it", new_path);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -214,9 +217,12 @@ VirtualDir RealVfsFilesystem::MoveDirectory(std::string_view old_path_,
|
||||||
}
|
}
|
||||||
|
|
||||||
auto file = cached.lock();
|
auto file = cached.lock();
|
||||||
file->Open(file_new_path, "r+b");
|
|
||||||
cache.erase(file_old_path);
|
cache.erase(file_old_path);
|
||||||
cache.insert_or_assign(std::move(file_new_path), std::move(file));
|
if (file->Open(file_new_path, "r+b")) {
|
||||||
|
cache.insert_or_assign(std::move(file_new_path), std::move(file));
|
||||||
|
} else {
|
||||||
|
LOG_ERROR(Service_FS, "Failed to open path {} in order to re-cache it", file_new_path);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return OpenDirectory(new_path, Mode::ReadWrite);
|
return OpenDirectory(new_path, Mode::ReadWrite);
|
||||||
|
|
Loading…
Reference in a new issue