mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-09-21 20:06:40 +00:00
Make real directory paths on the VFS predictable.
Partial revert/fix of2f19cf86d3and2567fee329. Before this diff, it was possible for a mod containing a cache/ or a config/ folder to get written to incorrectly. The issue is VFS can map multiple directories to one 'virtual' path, for reading mods. However, writing data is problematic: which path to choose? The only viable solution is to use a path relative to the highest priority directory encountered in the VFS path, or write paths could be 'hijacked' by lower-priority mods. This fixes these issues by: - Adding a new lookup mode ('Real-path') that explicitly picks the real path relative to the highest-priority subdirectory in the VFS Path. - Preventing overwriting a real directory with a lower priority one in general. - Revert c0c8132dd4's GetRealPath change, re-introducing the function as GetOriginalPath. This also cleans up some duplication that led to empty mod folders in the user mod path, and cleans up loading the 'user' mod. Note that the new 'realpath' lookup can still be somewhat complex with many mount points at various hierarchy levels, but it is at least predictable/deterministic without having to be careful about populating order. Fixes #2553 Differential Revision: https://code.wildfiregames.com/D3217 This was SVN commit r25104.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2018 Wildfire Games.
|
||||
/* Copyright (C) 2021 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@@ -140,7 +140,7 @@ VfsPath CCacheLoader::LooseCachePath(const VfsPath& sourcePath, const MD5& initi
|
||||
|
||||
// Get the mod path
|
||||
OsPath path;
|
||||
m_VFS->GetRealPath(sourcePath, path);
|
||||
m_VFS->GetOriginalPath(sourcePath, path);
|
||||
|
||||
return VfsPath("cache") /
|
||||
path_name_only(path.BeforeCommon(sourcePath).Parent().string().c_str()) /
|
||||
|
||||
Reference in New Issue
Block a user