@@ -836,29 +836,48 @@ export class AppState {
836836      return ; 
837837    } 
838838
839-     console . log ( `State: Removing Electron ${ version }  ` ) ; 
840-     if  ( source  ===  VersionSource . local )  { 
841-       if  ( version  in  this . versions )  { 
842-         delete  this . versions [ version ] ; 
843-         saveLocalVersions ( Object . values ( this . versions ) ) ; 
844-       }  else  { 
845-         console . log ( `State: Version ${ version }   already removed, doing nothing` ) ; 
846-       } 
847-     }  else  { 
848-       if  ( 
849-         state  ===  InstallState . installed  || 
850-         state  ==  InstallState . downloaded 
851-       )  { 
852-         await  this . installer . remove ( version ) ; 
853-         if  ( this . installer . state ( version )  ===  InstallState . missing )  { 
854-           await  window . ElectronFiddle . app . electronTypes . uncache ( ver ) ; 
839+     await  navigator . locks . request ( 
840+       this . getVersionLockName ( version ) , 
841+       { 
842+         mode : 'exclusive' , 
843+         ifAvailable : true , 
844+       } , 
845+       async  ( lock )  =>  { 
846+         // another window is already removing this version 
847+         if  ( ! lock )  { 
848+           return ; 
849+         } 
855850
856-           this . broadcastVersionStates ( [ ver ] ) ; 
851+         console . log ( `State: Removing Electron ${ version }  ` ) ; 
852+ 
853+         if  ( source  ===  VersionSource . local )  { 
854+           if  ( version  in  this . versions )  { 
855+             delete  this . versions [ version ] ; 
856+             saveLocalVersions ( Object . values ( this . versions ) ) ; 
857+           }  else  { 
858+             console . log ( 
859+               `State: Version ${ version }   already removed, doing nothing` , 
860+             ) ; 
861+           } 
862+         }  else  { 
863+           if  ( 
864+             state  ===  InstallState . installed  || 
865+             state  ==  InstallState . downloaded 
866+           )  { 
867+             await  this . installer . remove ( version ) ; 
868+             if  ( this . installer . state ( version )  ===  InstallState . missing )  { 
869+               await  window . ElectronFiddle . app . electronTypes . uncache ( ver ) ; 
870+ 
871+               this . broadcastVersionStates ( [ ver ] ) ; 
872+             } 
873+           }  else  { 
874+             console . log ( 
875+               `State: Version ${ version }   already removed, doing nothing` , 
876+             ) ; 
877+           } 
857878        } 
858-       }  else  { 
859-         console . log ( `State: Version ${ version }   already removed, doing nothing` ) ; 
860-       } 
861-     } 
879+       } , 
880+     ) ; 
862881  } 
863882
864883  /** 
@@ -1044,8 +1063,17 @@ export class AppState {
10441063      } 
10451064    } 
10461065
1047-     // Fetch new binaries, maybe? 
1048-     await  this . downloadVersion ( ver ) ; 
1066+     await  navigator . locks . request ( 
1067+       `downloading:${ version }  ` , 
1068+       {  mode : 'exclusive'  } , 
1069+       async  ( lock )  =>  { 
1070+         console . log ( `exclusive download lock granted:` ) ; 
1071+         console . log ( lock ) ; 
1072+ 
1073+         // Fetch new binaries, maybe? 
1074+         await  this . downloadVersion ( ver ) ; 
1075+       } , 
1076+     ) ; 
10491077  } 
10501078
10511079  /** 
0 commit comments