Skip to content

Commit 475d75c

Browse files
committed
Fix DATA_DIR when scripts run from ~/.auto_note/scripts/ via venv Python
Scripts copied to ~/.auto_note/scripts/ run with sys.frozen=False (venv Python), so the previous frozen-only check set DATA_DIR=~/.auto_note/scripts/ instead of ~/.auto_note/, leaving config.json and credentials unfound (CANVAS_URL=''). Fix: also use ~/.auto_note/ as DATA_DIR when PROJECT_DIR is ~/.auto_note/scripts/.
1 parent fb7a255 commit 475d75c

4 files changed

Lines changed: 14 additions & 10 deletions

File tree

‎downloader.py‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,11 @@
3838
PROJECT_DIR = Path(__file__).parent
3939
MANIFEST_FILE = None # set after DATA_DIR is resolved below
4040

41-
# When bundled as an AppImage, __file__ resolves to a temp dir deleted on exit.
42-
# Credentials and config must be read from the persistent ~/.auto_note/ directory.
43-
if getattr(sys, "frozen", False):
44-
DATA_DIR = Path.home() / ".auto_note"
41+
# Persistent data dir: ~/.auto_note/ when installed (AppImage or scripts/ copy),
42+
# else the project directory (dev mode).
43+
_AUTO_NOTE_DIR = Path.home() / ".auto_note"
44+
if getattr(sys, "frozen", False) or PROJECT_DIR == _AUTO_NOTE_DIR / "scripts":
45+
DATA_DIR = _AUTO_NOTE_DIR
4546
else:
4647
DATA_DIR = PROJECT_DIR
4748

‎extract_caption.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@
2323
from pathlib import Path
2424

2525
PROJECT_DIR = Path(__file__).parent
26-
if getattr(sys, "frozen", False):
27-
DATA_DIR = Path.home() / ".auto_note"
26+
_AUTO_NOTE_DIR = Path.home() / ".auto_note"
27+
if getattr(sys, "frozen", False) or PROJECT_DIR == _AUTO_NOTE_DIR / "scripts":
28+
DATA_DIR = _AUTO_NOTE_DIR
2829
else:
2930
DATA_DIR = PROJECT_DIR
3031
MANIFEST_FILE = DATA_DIR / "manifest.json"

‎note_generation.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@
3131

3232
PROJECT_DIR = Path(__file__).parent
3333
import sys as _sys
34-
if getattr(_sys, "frozen", False):
35-
DATA_DIR = Path.home() / ".auto_note"
34+
_AUTO_NOTE_DIR = Path.home() / ".auto_note"
35+
if getattr(_sys, "frozen", False) or PROJECT_DIR == _AUTO_NOTE_DIR / "scripts":
36+
DATA_DIR = _AUTO_NOTE_DIR
3637
else:
3738
DATA_DIR = PROJECT_DIR
3839

‎semantic_alignment.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@
4040

4141
PROJECT_DIR = Path(__file__).parent
4242
import sys as _sys
43-
if getattr(_sys, "frozen", False):
44-
DATA_DIR = Path.home() / ".auto_note"
43+
_AUTO_NOTE_DIR = Path.home() / ".auto_note"
44+
if getattr(_sys, "frozen", False) or PROJECT_DIR == _AUTO_NOTE_DIR / "scripts":
45+
DATA_DIR = _AUTO_NOTE_DIR
4546
else:
4647
DATA_DIR = PROJECT_DIR
4748

0 commit comments

Comments
 (0)