Skip to content

Commit 2ffa69d

Browse files
committed
Changes to main for issue of OCR.
1 parent 2d5e655 commit 2ffa69d

2 files changed

Lines changed: 32 additions & 6 deletions

File tree

isFirstLaunch.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
False

main.js

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,43 @@ async function rESM(name) {
3030
return await import(name);
3131
}
3232

33-
// ─── Deps check ───────────────────────────────────────────────────────────────
33+
// ─── Deps check (isFirstLaunch.txt flag) ──────────────────────────────────────
34+
function getFirstLaunchPath() {
35+
// In packaged app: use Program Files install dir or userData
36+
if (app.isPackaged) {
37+
// Try the app's install directory first
38+
const installDir = path.dirname(app.getPath('exe'));
39+
const installFlag = path.join(installDir, 'isFirstLaunch.txt');
40+
// If we can't write to install dir (permissions), fall back to userData
41+
try {
42+
fs.accessSync(installDir, fs.constants.W_OK);
43+
return installFlag;
44+
} catch {
45+
return path.join(app.getPath('userData'), 'isFirstLaunch.txt');
46+
}
47+
}
48+
// Dev mode: use project root
49+
return path.join(__dirname, 'isFirstLaunch.txt');
50+
}
51+
3452
function isDepsInstalled() {
35-
if (!app.isPackaged) return true;
36-
const marker = path.join(MODULES_DIR, '.cc-installed');
37-
if (!fs.existsSync(marker)) return false;
53+
const flagPath = getFirstLaunchPath();
54+
if (!fs.existsSync(flagPath)) return false;
3855
try {
39-
return fs.readFileSync(marker, 'utf-8').trim() === app.getVersion();
56+
const content = fs.readFileSync(flagPath, 'utf-8').trim();
57+
return content === 'True';
4058
} catch { return false; }
4159
}
4260

4361
function markDepsInstalled() {
44-
fs.writeFileSync(path.join(MODULES_DIR, '.cc-installed'), app.getVersion(), 'utf-8');
62+
const flagPath = getFirstLaunchPath();
63+
try {
64+
fs.writeFileSync(flagPath, 'True', 'utf-8');
65+
} catch (e) {
66+
// Fallback: write to userData if install dir is read-only
67+
const fallback = path.join(app.getPath('userData'), 'isFirstLaunch.txt');
68+
fs.writeFileSync(fallback, 'True', 'utf-8');
69+
}
4570
}
4671

4772
// ─── Setup window ─────────────────────────────────────────────────────────────

0 commit comments

Comments
 (0)