chore: bump version to 0.3.8

Code audit fixes:
- CRITICAL: reorder Markdown pipeline (fixImages before sanitize)
- CRITICAL: fix path prefix separator check
- BLOCKING: remove duplicate useEffect in Editor
- BLOCKING: skip onChange when content unchanged
- BLOCKING: optimize Sidebar re-render with useMemo
- HIGH: cleanup FileWatcher polling intervals
- HIGH: improve validatePath segment check
- HIGH: fix isExternalUpdate race with counter
- HIGH: add will-navigate / setWindowOpenHandler
- HIGH: explicit strip in sanitize schema
- MEDIUM: random temp file suffix instead of Date.now()
- MEDIUM/LOW: add IndexedDB error boundaries
- LOW: support UTF-16 BOM detection
This commit is contained in:
thzxx
2026-06-18 21:28:35 +08:00
parent dd78ff15a9
commit 7f070eb11d
13 changed files with 165 additions and 63 deletions
+18 -4
View File
@@ -5,6 +5,8 @@ export class FileWatcher {
private watcher: fs.FSWatcher | null = null
private currentPath: string | null = null
private isSelfWriting = false
private pollTimer: ReturnType<typeof setInterval> | null = null
private pollTimeout: ReturnType<typeof setTimeout> | null = null
constructor(private getMainWindow: () => BrowserWindow | null) {}
@@ -27,18 +29,18 @@ export class FileWatcher {
const originalPath = this.currentPath
this.stop()
if (originalPath) {
const pollInterval = setInterval(() => {
this.pollTimer = setInterval(() => {
try {
if (fs.existsSync(originalPath)) {
clearInterval(pollInterval)
this.clearPollTimers()
this.start(originalPath)
}
} catch {
clearInterval(pollInterval)
this.clearPollTimers()
}
}, 2000)
// 最多轮询30秒
setTimeout(() => clearInterval(pollInterval), 30000)
this.pollTimeout = setTimeout(() => this.clearPollTimers(), 30000)
}
})
} catch {
@@ -47,6 +49,7 @@ export class FileWatcher {
}
stop(): void {
this.clearPollTimers()
if (this.watcher) {
this.watcher.close()
this.watcher = null
@@ -54,6 +57,17 @@ export class FileWatcher {
this.currentPath = null
}
private clearPollTimers(): void {
if (this.pollTimer) {
clearInterval(this.pollTimer)
this.pollTimer = null
}
if (this.pollTimeout) {
clearTimeout(this.pollTimeout)
this.pollTimeout = null
}
}
getCurrentPath(): string | null {
return this.currentPath
}