1717
1818use  crate :: config:: OS ; 
1919use  crate :: config:: OS :: WINDOWS ; 
20+ use  crate :: lock:: Lock ; 
2021use  crate :: { 
2122    format_one_arg,  format_three_args,  run_shell_command_by_os,  Command ,  Logger ,  CP_VOLUME_COMMAND , 
2223    HDIUTIL_ATTACH_COMMAND ,  HDIUTIL_DETACH_COMMAND ,  MACOS ,  MSIEXEC_INSTALL_COMMAND , 
@@ -27,7 +28,6 @@ use apple_flat_package::PkgReader;
2728use  bzip2:: read:: BzDecoder ; 
2829use  directories:: BaseDirs ; 
2930use  flate2:: read:: GzDecoder ; 
30- use  fs2:: FileExt ; 
3131use  fs_extra:: dir:: { move_dir,  CopyOptions } ; 
3232use  regex:: Regex ; 
3333use  std:: fs; 
@@ -55,7 +55,6 @@ const MSI: &str = "msi";
5555const  XZ :  & str  = "xz" ; 
5656const  SEVEN_ZIP_HEADER :  & [ u8 ;  6 ]  = b"7z\xBC \xAF \x27 \x1C " ; 
5757const  UNCOMPRESS_MACOS_ERR_MSG :  & str  = "{} files are only supported in macOS" ; 
58- const  LOCK_FILE :  & str  = "sm.lock" ; 
5958
6059#[ derive( Hash ,  Eq ,  PartialEq ,  Debug ) ]  
6160pub  struct  BrowserPath  { 
@@ -72,39 +71,6 @@ impl BrowserPath {
7271    } 
7372} 
7473
75- pub  struct  Lock  { 
76-     file :  File , 
77-     path :  PathBuf , 
78- } 
79- 
80- impl  Lock  { 
81-     fn  acquire ( log :  & Logger ,  target :  & Path ,  single_file :  Option < String > )  -> Result < Self ,  Error >  { 
82-         let  lock_folder = if  single_file. is_some ( )  { 
83-             create_parent_path_if_not_exists ( target) ?; 
84-             target. parent ( ) . unwrap ( ) 
85-         }  else  { 
86-             create_path_if_not_exists ( target) ?; 
87-             target
88-         } ; 
89-         let  path = lock_folder. join ( LOCK_FILE ) ; 
90-         let  file = File :: create ( & path) ?; 
91- 
92-         log. trace ( format ! ( "Using lock file at {}" ,  path. display( ) ) ) ; 
93-         file. lock_exclusive ( ) . unwrap_or_default ( ) ; 
94- 
95-         Ok ( Self  {  file,  path } ) 
96-     } 
97- 
98-     fn  release ( & mut  self )  { 
99-         self . file . unlock ( ) . unwrap_or_default ( ) ; 
100-         fs:: remove_file ( & self . path ) . unwrap_or_default ( ) ; 
101-     } 
102- 
103-     fn  exists ( & mut  self )  -> bool  { 
104-         self . path . exists ( ) 
105-     } 
106- } 
107- 
10874pub  fn  create_parent_path_if_not_exists ( path :  & Path )  -> Result < ( ) ,  Error >  { 
10975    if  let  Some ( p)  = path. parent ( )  { 
11076        create_path_if_not_exists ( p) ?; 
0 commit comments