Skip to content

Commit 574659e

Browse files
nodeeeeeeclaude
andcommitted
Fix note deletion to also remove multi-file section files and images
Section files can be L01_S01.md (single-file) or L01_F02_S01.md (multi-file lectures). The previous pattern only matched _S, missing the _F variant. Changed to match any file starting with L{num}_. Also fixed image directory deletion to handle L01_F02/ directories in addition to L01/. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent a6d4dfa commit 574659e

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

electron/main.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -870,10 +870,10 @@ function deleteVideoData(courseId, captionStem) {
870870
for (const num of lecNums) {
871871
const prefix = `L${String(num).padStart(2, '0')}`;
872872

873-
// Delete section files: L{num}_S*.md
873+
// Delete section files: L{num}_S*.md and L{num}_F*_S*.md
874874
if (fs.existsSync(sectionsDir)) {
875875
for (const sf of fs.readdirSync(sectionsDir)) {
876-
if (sf.startsWith(prefix + '_S') && sf.endsWith('.md')) {
876+
if (sf.startsWith(prefix + '_') && sf.endsWith('.md')) {
877877
fs.unlinkSync(path.join(sectionsDir, sf));
878878
deleted.push('notes/sections/' + sf);
879879
}
@@ -890,11 +890,15 @@ function deleteVideoData(courseId, captionStem) {
890890
}
891891
}
892892

893-
// Delete images directory: images/L{num}/
894-
const imgDir = path.join(imagesDir, prefix);
895-
if (fs.existsSync(imgDir)) {
896-
fs.rmSync(imgDir, { recursive: true, force: true });
897-
deleted.push('notes/images/' + prefix + '/');
893+
// Delete images directories: images/L{num}/ and images/L{num}_F*/
894+
if (fs.existsSync(imagesDir)) {
895+
for (const d of fs.readdirSync(imagesDir)) {
896+
if ((d === prefix || d.startsWith(prefix + '_F')) &&
897+
fs.statSync(path.join(imagesDir, d)).isDirectory()) {
898+
fs.rmSync(path.join(imagesDir, d), { recursive: true, force: true });
899+
deleted.push('notes/images/' + d + '/');
900+
}
901+
}
898902
}
899903
}
900904

0 commit comments

Comments
 (0)