@@ -3,7 +3,7 @@ import fs, { constants as fsConstants } from 'fs';
33import { tmpdir } from 'os' ;
44import path from 'path' ;
55
6- import { utils } from '../../utils' ;
6+ import { _ } from '../../utils' ;
77import { BACKGROUND_VER , ENCODING , VERSION } from '../../utils/constants' ;
88import { vsc } from '../../utils/vsc' ;
99
@@ -96,7 +96,7 @@ export abstract class AbsPatchFile {
9696 try {
9797 const mvcmd = process . platform === 'win32' ? 'move /Y' : 'mv -f' ;
9898 const cmdarg = `${ mvcmd } "${ tempFilePath } " "${ filePath } "` ;
99- await utils . sudoExec ( cmdarg , { name : 'Background Extension' } ) ;
99+ await _ . sudoExec ( cmdarg , { name : 'Background Extension' } ) ;
100100 return true ;
101101 } catch ( e : any ) {
102102 vsc . window . showErrorMessage ( e . message , { title : 'Common Issue' } ) . then ( confirm => {
@@ -145,11 +145,15 @@ export abstract class AbsPatchFile {
145145 protected abstract cleanPatches ( content : string ) : string ;
146146
147147 public async restore ( ) {
148- await utils . lock ( ) ;
149- let content = await this . getContent ( ) ;
150- content = this . cleanPatches ( content ) ;
151- const ok = await this . write ( content ) ;
152- await utils . unlock ( ) ;
153- return ok ;
148+ try {
149+ await _ . lock ( ) ;
150+ let content = await this . getContent ( ) ;
151+ content = this . cleanPatches ( content ) ;
152+ return await this . write ( content ) ;
153+ } catch {
154+ return false ;
155+ } finally {
156+ await _ . unlock ( ) ;
157+ }
154158 }
155159}
0 commit comments