chore: update Angular cache and TypeScript build info files
This commit is contained in:
+19
-2
@@ -478,9 +478,26 @@ app.put('/api/vault/bookmarks', (req, res) => {
|
||||
}
|
||||
}
|
||||
|
||||
// Write bookmarks
|
||||
// Create backup before writing
|
||||
const backupPath = bookmarksPath + '.bak';
|
||||
if (fs.existsSync(bookmarksPath)) {
|
||||
fs.copyFileSync(bookmarksPath, backupPath);
|
||||
}
|
||||
|
||||
// Atomic write: write to temp file, then rename
|
||||
const tempPath = bookmarksPath + '.tmp';
|
||||
const content = JSON.stringify(req.body, null, 2);
|
||||
fs.writeFileSync(bookmarksPath, content, 'utf-8');
|
||||
|
||||
try {
|
||||
fs.writeFileSync(tempPath, content, 'utf-8');
|
||||
fs.renameSync(tempPath, bookmarksPath);
|
||||
} catch (writeError) {
|
||||
// If write failed, restore backup if it exists
|
||||
if (fs.existsSync(backupPath)) {
|
||||
fs.copyFileSync(backupPath, bookmarksPath);
|
||||
}
|
||||
throw writeError;
|
||||
}
|
||||
|
||||
const newRev = calculateSimpleHash(content);
|
||||
res.json({ rev: newRev });
|
||||
|
||||
Reference in New Issue
Block a user