diff --git a/binaries/data/mods/public/gui/replaymenu/replay_menu.xml b/binaries/data/mods/public/gui/replaymenu/replay_menu.xml index dc6f4135e0..83e68fb216 100644 --- a/binaries/data/mods/public/gui/replaymenu/replay_menu.xml +++ b/binaries/data/mods/public/gui/replaymenu/replay_menu.xml @@ -238,7 +238,7 @@ Rebuild Cache Rebuild the replay cache from scratch. Potentially slow! - reloadCache(); + reloadCache(); displayReplayList(); diff --git a/source/ps/VisualReplay.cpp b/source/ps/VisualReplay.cpp index f81c23b972..f7cb9fb415 100644 --- a/source/ps/VisualReplay.cpp +++ b/source/ps/VisualReplay.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2020 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 @@ -117,8 +117,8 @@ JS::HandleObject VisualReplay::ReloadReplayCache(const ScriptInterface& scriptIn TIMER(L"ReloadReplayCache"); ScriptRequest rq(scriptInterface); - // Maps the filename onto the index and size - typedef std::map> replayCacheMap; + // Maps the filename onto the index, mtime and size + using replayCacheMap = std::map>; replayCacheMap fileList; @@ -136,10 +136,12 @@ JS::HandleObject VisualReplay::ReloadReplayCache(const ScriptInterface& scriptIn JS::RootedValue file(rq.cx); OsPath fileName; double fileSize; + double fileMtime; scriptInterface.GetProperty(replay, "directory", fileName); scriptInterface.GetProperty(replay, "fileSize", fileSize); + scriptInterface.GetProperty(replay, "fileMTime", fileMtime); - fileList[fileName] = std::make_pair(j, fileSize); + fileList[fileName] = std::make_tuple(j, fileMtime, fileSize); } } @@ -174,7 +176,7 @@ JS::HandleObject VisualReplay::ReloadReplayCache(const ScriptInterface& scriptIn continue; CFileInfo fileInfo; GetFileInfo(replayFile, &fileInfo); - if (fileInfo.Size() == it->second.second) + if ((u64)fileInfo.MTime() == std::get<1>(it->second) && (off_t)fileInfo.Size() == std::get<2>(it->second)) isNew = false; } else @@ -195,13 +197,14 @@ JS::HandleObject VisualReplay::ReloadReplayCache(const ScriptInterface& scriptIn rq, &replayData, "directory", directory.string(), + "fileMTime", static_cast(fileInfo.MTime()), "fileSize", static_cast(fileInfo.Size())); } JS_SetElement(rq.cx, replays, i++, replayData); newReplays = true; } else - copyFromOldCache.push_back(it->second.first); + copyFromOldCache.push_back(std::get<0>(it->second)); } debug_printf( @@ -411,6 +414,7 @@ JS::Value VisualReplay::LoadReplayData(const ScriptInterface& scriptInterface, c &replayData, "directory", directory.string(), "fileSize", static_cast(fileSize), + "fileMTime", static_cast(fileInfo.MTime()), "duration", duration); scriptInterface.SetProperty(replayData, "attribs", attribs);