Skip to content

Commit a8e5da8

Browse files
committed
feat: installer now records successful upgrade hash
1 parent 0ce1550 commit a8e5da8

File tree

4 files changed

+37
-18
lines changed

4 files changed

+37
-18
lines changed

installer_scripts/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ output.log
1111
.python_version
1212
.pip_packages
1313
.db_version
14+
.git_version
1415

1516
# Diagnostic
1617
diagnostic.txt

installer_scripts/init_app.js

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,20 @@ const updateConda = async () => {
2020
};
2121

2222
const FORCE_REINSTALL = process.env.FORCE_REINSTALL ? true : false;
23-
const DEBUG_ALWAYS_RETURN_UPDATED = FORCE_REINSTALL || process.env.DEBUG_ALWAYS_RETURN_UPDATED
24-
? true
25-
: false;
23+
const DEBUG_ALWAYS_RETURN_UPDATED =
24+
FORCE_REINSTALL || process.env.DEBUG_ALWAYS_RETURN_UPDATED ? true : false;
25+
26+
const getGitCommitHash = () =>
27+
fs.readFileSync("./.git/refs/heads/main", "utf8");
28+
29+
const AppliedGitVersion = {
30+
file: "./.git_version",
31+
get: () =>
32+
fs.existsSync(AppliedGitVersion.file)
33+
? fs.readFileSync(AppliedGitVersion.file, "utf8")
34+
: null,
35+
save: () => fs.writeFileSync(AppliedGitVersion.file, getGitCommitHash()),
36+
};
2637

2738
const syncRepo = async () => {
2839
if (!fs.existsSync(".git")) {
@@ -39,11 +50,10 @@ const syncRepo = async () => {
3950
} else {
4051
displayMessage("Pulling updates from tts-generation-webui");
4152
try {
42-
const file = ".git/refs/heads/main";
43-
const currentHash = fs.readFileSync(file, "utf8");
4453
await $("git pull");
45-
const newHash = fs.readFileSync(file, "utf8");
46-
if (currentHash === newHash) {
54+
const newHash = getGitCommitHash();
55+
if (AppliedGitVersion.get() === newHash) {
56+
displayMessage("Current git version: " + newHash);
4757
displayMessage("No updates found, skipping...");
4858
return false || DEBUG_ALWAYS_RETURN_UPDATED;
4959
}
@@ -77,9 +87,8 @@ async function main() {
7787
// await updateConda();
7888
// check if there are any packages actually installed inside of conda
7989
const isUpdated = await syncRepo();
80-
if (!isUpdated) {
81-
return;
82-
}
90+
if (!isUpdated) return;
91+
8392
const {
8493
initializeApp,
8594
repairTorch,
@@ -88,6 +97,8 @@ async function main() {
8897
await initializeApp();
8998
await setupReactUI();
9099
await repairTorch();
100+
101+
AppliedGitVersion.save();
91102
} catch (error) {
92103
displayError(error.message);
93104
processExit(1);

installer_scripts/js/applyDatabaseConfig.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ async function applyDatabaseConfig() {
5656
await awaitDatabase();
5757
try {
5858
await func();
59+
} catch (error) {
60+
throw error;
5961
} finally {
6062
await stopDatabase();
6163
}

installer_scripts/js/initializeApp.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -219,14 +219,8 @@ const checkIfTorchInstalled = async () => {
219219

220220
const FORCE_REINSTALL = process.env.FORCE_REINSTALL ? true : false;
221221

222-
const initializeApp = async () => {
223-
displayMessage("Ensuring that python has the correct version...");
224-
await ensurePythonVersion();
225-
try {
226-
await applyDatabaseConfig();
227-
} catch (error) {
228-
displayError("Failed to apply database config");
229-
}
222+
async function applyCondaConfig() {
223+
displayMessage("Applying conda config...");
230224
displayMessage("Checking if Torch is installed...");
231225
if (readMajorVersion() === majorVersion && !FORCE_REINSTALL) {
232226
if (await checkIfTorchInstalled()) {
@@ -251,6 +245,17 @@ const initializeApp = async () => {
251245
saveGPUChoice(gpuchoice);
252246
await installDependencies(gpuchoice);
253247
}
248+
}
249+
250+
const initializeApp = async () => {
251+
displayMessage("Ensuring that python has the correct version...");
252+
await ensurePythonVersion();
253+
await applyCondaConfig();
254+
try {
255+
await applyDatabaseConfig();
256+
} catch (error) {
257+
displayError("Failed to apply database config");
258+
}
254259
};
255260
exports.initializeApp = initializeApp;
256261

0 commit comments

Comments
 (0)