8000 :zap: Ct.js now checks whether recovery file actually differs from th… · ct-js/ct-js@5950ffa · GitHub
[go: up one dir, main page]

Skip to content

Commit 5950ffa

Browse files
⚡ Ct.js now checks whether recovery file actually differs from the regular project file
1 parent 7bd2cee commit 5950ffa

File tree

1 file changed

+10
-0
lines changed
  • src/node_requires/resources/projects

1 file changed

+10
-0
lines changed

src/node_requires/resources/projects/index.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,16 @@ const openProject = async (proj: string): Promise<void | false | Promise<void>>
306306
void 0;
307307
}
308308
if (recoveryStat && recoveryStat.isFile()) {
309+
// Make sure recovery and target files are not the same
310+
const [recoveryContent, targetContent] = await Promise.all([
311+
fs.readFile(proj + '.recovery', 'utf8'),
312+
fs.readFile(proj, 'utf8')
313+
]);
314+
if (recoveryContent === targetContent) {
315+
// Files match, load as usual
316+
return readProjectFile(proj);
317+
}
318+
// Files differ, ask user if they want to load the recovery file
309319
const targetStat = await fs.stat(proj);
310320
const voc = getLanguageJSON().intro.recovery;
311321
const userResponse = await window.alertify

0 commit comments

Comments
 (0)
0