Skip to content

Commit 728e6fa

Browse files
nodeeeeeeclaude
andcommitted
Fix COURSE_DATA_DIR default to ~/AutoNote (matching Electron app)
Root cause: Python scripts defaulted COURSE_DATA_DIR to DATA_DIR (~/.auto_note) when OUTPUT_DIR was empty, but the Electron app's getOutputDir() defaults to ~/AutoNote. Course data (captions, materials, alignment) lives under ~/AutoNote, so Python saved the mapping to ~/.auto_note where the JS scan couldn't find it. Fix: all Python scripts (semantic_alignment, note_generation, frame_extractor) now default COURSE_DATA_DIR to ~/AutoNote when OUTPUT_DIR is not set — matching the Electron app's behavior. JS align:scan also updated to check OUTPUT_DIR first, DATA_DIR as fallback. Verified end-to-end: Python saves mapping to ~/AutoNote/88787/, JS align:scan finds it there. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 4da7ec6 commit 728e6fa

4 files changed

Lines changed: 15 additions & 11 deletions

File tree

electron/main.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -843,16 +843,17 @@ function registerIpc() {
843843

844844
// ── Align: scan captions + slides, load/save mapping ───────────────────
845845
ipcMain.handle('align:scan', (_, cid) => {
846-
// Course data may be under OUTPUT_DIR or DATA_DIR (~/.auto_note/).
847-
// Python uses COURSE_DATA_DIR = config.OUTPUT_DIR or DATA_DIR.
848-
// Check all possible locations and use whichever has the captions/ dir.
846+
// Course data lives under OUTPUT_DIR (~/AutoNote by default).
847+
// Check OUTPUT_DIR first, then DATA_DIR as fallback.
849848
const candidates = [
850-
path.join(DATA_DIR, String(cid)),
851849
path.join(getOutputDir(), String(cid)),
850+
path.join(DATA_DIR, String(cid)),
852851
];
853-
let base = candidates[0]; // default to DATA_DIR
852+
let base = candidates[0]; // default to OUTPUT_DIR
854853
for (const c of candidates) {
855-
if (fs.existsSync(path.join(c, 'captions'))) { base = c; break; }
854+
if (fs.existsSync(path.join(c, 'captions')) || fs.existsSync(path.join(c, 'materials'))) {
855+
base = c; break;
856+
}
856857
}
857858
const capDir = path.join(base, 'captions');
858859
const matDir = path.join(base, 'materials');
@@ -1112,12 +1113,14 @@ function registerIpc() {
11121113

11131114
ipcMain.handle('align:saveMapping', (_, { cid, mapping }) => {
11141115
const candidates = [
1115-
path.join(DATA_DIR, String(cid)),
11161116
path.join(getOutputDir(), String(cid)),
1117+
path.join(DATA_DIR, String(cid)),
11171118
];
11181119
let base = candidates[0];
11191120
for (const c of candidates) {
1120-
if (fs.existsSync(path.join(c, 'captions'))) { base = c; break; }
1121+
if (fs.existsSync(path.join(c, 'captions')) || fs.existsSync(path.join(c, 'materials'))) {
1122+
base = c; break;
1123+
}
11211124
}
11221125
const alignDir = path.join(base, 'alignment');
11231126
if (!fs.existsSync(alignDir)) fs.mkdirSync(alignDir, { recursive: true });

frame_extractor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
_cfg_file = DATA_DIR / "config.json"
3939
_fe_config: dict = json.loads(_cfg_file.read_text(encoding="utf-8")) if _cfg_file.exists() else {}
4040
_out_dir = _fe_config.get("OUTPUT_DIR", "").strip()
41-
COURSE_DATA_DIR = Path(_out_dir) if _out_dir else DATA_DIR
41+
COURSE_DATA_DIR = Path(_out_dir) if _out_dir else Path.home() / "AutoNote"
4242

4343
# Prevent console windows flashing on Windows
4444
_SUBPROCESS_FLAGS = subprocess.CREATE_NO_WINDOW if sys.platform == "win32" else 0

note_generation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
if (DATA_DIR / "config.json").exists() else {}
5858
)
5959
_out_dir = _ng_config.get("OUTPUT_DIR", "").strip()
60-
COURSE_DATA_DIR = Path(_out_dir) if _out_dir else DATA_DIR
60+
COURSE_DATA_DIR = Path(_out_dir) if _out_dir else Path.home() / "AutoNote"
6161

6262
# ── Constants ─────────────────────────────────────────────────────────────────
6363

semantic_alignment.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@
6868
except Exception:
6969
_sa_config = {}
7070
_out_dir = _sa_config.get("OUTPUT_DIR", "").strip()
71-
COURSE_DATA_DIR = Path(_out_dir) if _out_dir else DATA_DIR
71+
# Default to ~/AutoNote (same as the Electron app's getOutputDir())
72+
COURSE_DATA_DIR = Path(_out_dir) if _out_dir else Path.home() / "AutoNote"
7273

7374
# ── Tunable knobs ─────────────────────────────────────────────────────────────
7475

0 commit comments

Comments
 (0)