mirror of
https://github.com/karl0ss/homepage.git
synced 2025-05-03 05:53:40 +01:00
Merge pull request #963 from benphelps/fix-settings-after-container-update
Fix settings after container update
This commit is contained in:
commit
45946ddfe1
@ -19,7 +19,10 @@ export default async function handler(req, res) {
|
|||||||
return hash(readFileSync(configYaml, "utf8"));
|
return hash(readFileSync(configYaml, "utf8"));
|
||||||
});
|
});
|
||||||
|
|
||||||
const combinedHash = hash(hashes.join(""));
|
// this ties hash to specific build which should force revaliation between versions
|
||||||
|
const buildTime = process.env.NEXT_PUBLIC_BUILDTIME?.length ? process.env.NEXT_PUBLIC_BUILDTIME : '';
|
||||||
|
|
||||||
|
const combinedHash = hash(hashes.join("") + buildTime);
|
||||||
|
|
||||||
res.send({
|
res.send({
|
||||||
hash: combinedHash,
|
hash: combinedHash,
|
||||||
|
@ -100,7 +100,7 @@ function Index({ initialSettings, fallback }) {
|
|||||||
localStorage.setItem("hash", hashData.hash);
|
localStorage.setItem("hash", hashData.hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!initialSettings.isValid || (previousHash && previousHash !== hashData.hash)) {
|
if (previousHash && previousHash !== hashData.hash) {
|
||||||
setStale(true);
|
setStale(true);
|
||||||
localStorage.setItem("hash", hashData.hash);
|
localStorage.setItem("hash", hashData.hash);
|
||||||
|
|
||||||
@ -112,7 +112,7 @@ function Index({ initialSettings, fallback }) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [hashData, initialSettings]);
|
}, [hashData]);
|
||||||
|
|
||||||
if (stale) {
|
if (stale) {
|
||||||
return (
|
return (
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/* eslint-disable no-console */
|
/* eslint-disable no-console */
|
||||||
import { join } from "path";
|
import { join } from "path";
|
||||||
import { existsSync, copyFile, readFileSync, statSync } from "fs";
|
import { existsSync, copyFile, readFileSync } from "fs";
|
||||||
|
|
||||||
import yaml from "js-yaml";
|
import yaml from "js-yaml";
|
||||||
|
|
||||||
@ -32,18 +32,5 @@ export function getSettings() {
|
|||||||
|
|
||||||
const settingsYaml = join(process.cwd(), "config", "settings.yaml");
|
const settingsYaml = join(process.cwd(), "config", "settings.yaml");
|
||||||
const fileContents = readFileSync(settingsYaml, "utf8");
|
const fileContents = readFileSync(settingsYaml, "utf8");
|
||||||
|
return yaml.load(fileContents) ?? {};
|
||||||
let stats;
|
|
||||||
try {
|
|
||||||
stats = statSync(settingsYaml);
|
|
||||||
} catch (e) {
|
|
||||||
stats = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
const yamlLoaded = yaml.load(fileContents) ?? {};
|
|
||||||
|
|
||||||
return {
|
|
||||||
...yamlLoaded,
|
|
||||||
isValid: fileContents !== "-\n" && stats.size !== 2 // see https://github.com/benphelps/homepage/pull/609
|
|
||||||
};
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user