mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-09-21 20:06:40 +00:00
Fix updating existing mods
Replace wrename, that fails when mod exists already with RenameFile by @Stan Check if mod was actually installed when downloading it error if mod cannot be coppied into modTemp Differential revision: D4222 This was SVN commit r25854.
This commit is contained in:
@@ -49,9 +49,18 @@ CModInstaller::ModInstallationResult CModInstaller::Install(
|
||||
CreateDirectories(modTemp.Parent(), 0700);
|
||||
|
||||
if (keepFile)
|
||||
CopyFile(mod, modTemp, true);
|
||||
else
|
||||
wrename(mod, modTemp);
|
||||
{
|
||||
if (CopyFile(mod, modTemp, true) != INFO::OK)
|
||||
{
|
||||
LOGERROR("Failed to copy '%s' to '%s'", mod.string8().c_str(), modTemp.string8().c_str());
|
||||
return FAIL_ON_MOD_COPY;
|
||||
}
|
||||
}
|
||||
else if (RenameFile(mod, modTemp) != INFO::OK)
|
||||
{
|
||||
LOGERROR("Failed to rename '%s' into '%s'", mod.string8().c_str(), modTemp.string8().c_str());
|
||||
return FAIL_ON_MOD_MOVE;
|
||||
}
|
||||
|
||||
// Load the mod to VFS
|
||||
if (m_VFS->Mount(m_CacheDir, m_TempDir / "") != INFO::OK)
|
||||
@@ -88,8 +97,12 @@ CModInstaller::ModInstallationResult CModInstaller::Install(
|
||||
// mod-name.zip
|
||||
// mod.json
|
||||
CreateDirectories(modDir, 0700);
|
||||
if (wrename(modTemp, modPath) != 0)
|
||||
if (RenameFile(modTemp, modPath) != INFO::OK)
|
||||
{
|
||||
LOGERROR("Failed to rename '%s' into '%s'", modTemp.string8().c_str(), modPath.string8().c_str());
|
||||
return FAIL_ON_MOD_MOVE;
|
||||
}
|
||||
|
||||
DeleteDirectory(modTemp.Parent());
|
||||
|
||||
std::ofstream mod_json((modDir / "mod.json").string8());
|
||||
|
||||
Reference in New Issue
Block a user