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;