Skip to content

Commit edadd3f

Browse files
committed
Avoid creating persistence file if no notes
1 parent c7b45ac commit edadd3f

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

src/persistence/local-db/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ import { getLocalDbFilePath } from '../../utils';
99
const persistenceFile = getLocalDbFilePath();
1010

1111
export const saveNotesToFile = (noteMap: Map<string, CommentThread>) => {
12+
// Avoid creating persistence file if no notes were created
13+
if (!fs.existsSync(persistenceFile) && !noteMap.size) {
14+
return;
15+
}
1216
fs.writeFileSync(persistenceFile, JSON.stringify(Serializer.serialize(noteMap)));
1317
};
1418

0 commit comments

Comments
 (0)