Fix issue where cache swapping wouldn't work if record wasn't already present

Not sure why I re-ordered this before
This commit is contained in:
CakeLancelot 2023-09-27 05:01:22 -05:00 committed by GitHub
parent 3fc6cabe33
commit 2e7dc51aa1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -166,10 +166,6 @@ function performCacheSwap(newVersion) {
var currentCache = path.join(cacheRoot, "FusionFall"); var currentCache = path.join(cacheRoot, "FusionFall");
var newCache = path.join(cacheRoot, newVersion); var newCache = path.join(cacheRoot, newVersion);
var record = path.join(userData, ".lastver"); var record = path.join(userData, ".lastver");
var lastVersion = remotefs.readFileSync(record, (encoding = "utf8"));
// Make note of what version we are launching for next launch
remotefs.writeFileSync(record, newVersion);
// If cache renaming would result in a no-op (ex. launching the same version // If cache renaming would result in a no-op (ex. launching the same version
// two times), then skip it. This avoids permissions errors with multiple clients // two times), then skip it. This avoids permissions errors with multiple clients
@ -179,6 +175,7 @@ function performCacheSwap(newVersion) {
if (remotefs.existsSync(currentCache)) { if (remotefs.existsSync(currentCache)) {
// Cache already exists, find out what version it belongs to // Cache already exists, find out what version it belongs to
if (remotefs.existsSync(record)) { if (remotefs.existsSync(record)) {
var lastVersion = remotefs.readFileSync(record, (encoding = "utf8"));
if (lastVersion != newVersion) { if (lastVersion != newVersion) {
// Remove the directory we're trying to store the // Remove the directory we're trying to store the
// existing cache to if it already exists for whatever // existing cache to if it already exists for whatever
@ -198,6 +195,9 @@ function performCacheSwap(newVersion) {
} }
} }
// Make note of what version we are launching for next launch
remotefs.writeFileSync(record, newVersion);
if (remotefs.existsSync(newCache) && !skip) { if (remotefs.existsSync(newCache) && !skip) {
// Rename saved cache to FusionFall // Rename saved cache to FusionFall
remotefs.renameSync(newCache, currentCache); remotefs.renameSync(newCache, currentCache);