fix: auto-install AppImage dans ~/.local/bin au premier lancement Linux
Au démarrage, si l'AppImage ne tourne pas depuis ~/.local/bin/farm-tracker.AppImage, elle s'y copie automatiquement — plus besoin d'installation manuelle. Les mises à jour suivantes y atterrissent toujours (fix update Linux). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
35
main.js
35
main.js
@@ -154,13 +154,22 @@ async function downloadAndInstall(downloadUrl, version) {
|
|||||||
if (process.platform === 'linux') {
|
if (process.platform === 'linux') {
|
||||||
fs.chmodSync(tmpPath, 0o755);
|
fs.chmodSync(tmpPath, 0o755);
|
||||||
const stablePath = path.join(require('os').homedir(), '.local', 'bin', 'farm-tracker.AppImage');
|
const stablePath = path.join(require('os').homedir(), '.local', 'bin', 'farm-tracker.AppImage');
|
||||||
const target = fs.existsSync(stablePath) ? stablePath : process.env.APPIMAGE;
|
try {
|
||||||
if (target) {
|
fs.mkdirSync(path.dirname(stablePath), { recursive: true });
|
||||||
fs.copyFileSync(tmpPath, target);
|
fs.copyFileSync(tmpPath, stablePath);
|
||||||
|
fs.chmodSync(stablePath, 0o755);
|
||||||
fs.unlinkSync(tmpPath);
|
fs.unlinkSync(tmpPath);
|
||||||
app.relaunch({ execPath: target });
|
app.relaunch({ execPath: stablePath });
|
||||||
} else {
|
} catch (_) {
|
||||||
app.relaunch({ execPath: tmpPath });
|
// fallback: remplace l'AppImage courant si la copie vers bin/ échoue
|
||||||
|
const fallback = process.env.APPIMAGE;
|
||||||
|
if (fallback) {
|
||||||
|
fs.copyFileSync(tmpPath, fallback);
|
||||||
|
fs.unlinkSync(tmpPath);
|
||||||
|
app.relaunch({ execPath: fallback });
|
||||||
|
} else {
|
||||||
|
app.relaunch({ execPath: tmpPath });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
app.exit(0);
|
app.exit(0);
|
||||||
} else if (process.platform === 'win32') {
|
} else if (process.platform === 'win32') {
|
||||||
@@ -251,7 +260,21 @@ function createWindow() {
|
|||||||
mainWindow.loadFile(path.join(__dirname, 'renderer', 'index.html'));
|
mainWindow.loadFile(path.join(__dirname, 'renderer', 'index.html'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function selfInstallLinux() {
|
||||||
|
if (process.platform !== 'linux' || !app.isPackaged) return;
|
||||||
|
const appImagePath = process.env.APPIMAGE;
|
||||||
|
if (!appImagePath) return;
|
||||||
|
const stablePath = path.join(require('os').homedir(), '.local', 'bin', 'farm-tracker.AppImage');
|
||||||
|
if (appImagePath === stablePath) return;
|
||||||
|
try {
|
||||||
|
fs.mkdirSync(path.dirname(stablePath), { recursive: true });
|
||||||
|
fs.copyFileSync(appImagePath, stablePath);
|
||||||
|
fs.chmodSync(stablePath, 0o755);
|
||||||
|
} catch (_) {}
|
||||||
|
}
|
||||||
|
|
||||||
app.whenReady().then(() => {
|
app.whenReady().then(() => {
|
||||||
|
selfInstallLinux();
|
||||||
createWindow();
|
createWindow();
|
||||||
setTimeout(() => checkForUpdates(false), 5000);
|
setTimeout(() => checkForUpdates(false), 5000);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "farm-tracker",
|
"name": "farm-tracker",
|
||||||
"version": "1.0.3",
|
"version": "1.0.5",
|
||||||
"description": "Suivi de loot Minecraft en direct, avec sauvegarde automatique des stats et des chances de drop.",
|
"description": "Suivi de loot Minecraft en direct, avec sauvegarde automatique des stats et des chances de drop.",
|
||||||
"main": "main.js",
|
"main": "main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Reference in New Issue
Block a user