Separate updatedAt from mtime in SaveDetails

If a new save is added to the saves list of an instance the current save
selected to be loaded by default changes its state without updating the
mtime of the file on disk, which in turn means basing the updatedAt
property on mtime will not work with caching.  Fix by having a separate
updatedAt property that is set by the controller whenever the save
details changes from the controller's perspective.

Noticed-By: @Cooldude2606
This commit is contained in:
Hornwitser committed 2024-01-06 18:52:41 +01:00
1 parent 1ae686b3ea
commit 699ef2c3cb
3 files changed
+12 -4

No files matched your search

@@ -269,12 +269,14 @@ export default class HostConnection extends BaseConnection {
}
async handleInstanceSaveDetailsUpdatesEvent(event: lib.InstanceSaveDetailsUpdatesEvent) {
const now = Date.now();
const updates: lib.SaveDetails[] = [];
for (const save of event.updates) {
const existingSave = this._controller.saves.get(save.id);
if (existingSave && save.equals(existingSave)) {
continue;
}
save.updatedAt = now;
this._controller.saves.set(save.id, save);
updates.push(save);
}
@@ -283,6 +285,7 @@ export default class HostConnection extends BaseConnection {
for (const [id, save] of this._controller.saves) {
if (save.instanceId === event.instanceId && !updatedSaves.has(id)) {
save.isDeleted = true;
save.updatedAt = now;
updates.push(save);
this._controller.saves.delete(id);
}