From 049bd5f9ca581adc6deb9078fc97f7336c0b8426 Mon Sep 17 00:00:00 2001 From: xieshuang Date: Thu, 14 Nov 2024 16:49:51 +0800 Subject: [PATCH] do nothing if file unchanged --- src/background/PatchFile/PatchFile.javascript.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/background/PatchFile/PatchFile.javascript.ts b/src/background/PatchFile/PatchFile.javascript.ts index b82749b..c6cb7f9 100644 --- a/src/background/PatchFile/PatchFile.javascript.ts +++ b/src/background/PatchFile/PatchFile.javascript.ts @@ -16,8 +16,8 @@ export class JsPatchFile extends AbsPatchFile { public async applyPatches(patchContent: string): Promise { try { await _.lock(); - let content = await this.getContent(); - content = this.cleanPatches(content); + const curContent = await this.getContent(); + let content = this.cleanPatches(curContent); content += [ // `\n// vscode-background-start ${BACKGROUND_VER}.${VERSION}`, @@ -25,6 +25,11 @@ export class JsPatchFile extends AbsPatchFile { '// vscode-background-end' ].join('\n'); + // file unchanged + if (curContent === content) { + return true; + } + return await this.write(content); } catch { return false;