@@ -39,31 +39,41 @@ struct CopyFilesToGtaSaParams {
3939
4040fn get_checksum_of_files ( list : Vec < String > ) -> Result < Vec < String > > {
4141 let mut result = Vec :: new ( ) ;
42-
42+
4343 for file in list {
44- let mut f = File :: open ( & file)
45- . map_err ( |e| LauncherError :: Io ( e) ) ?;
46-
44+ let mut f = File :: open ( & file) . map_err ( |e| LauncherError :: Io ( e) ) ?;
45+
4746 let mut contents = Vec :: new ( ) ;
4847 f. read_to_end ( & mut contents)
4948 . map_err ( |e| LauncherError :: Io ( e) ) ?;
50-
49+
5150 let digest = compute ( & contents) ;
5251 let checksum_entry = format ! ( "{}|{:x}" , file, digest) ;
5352 result. push ( checksum_entry) ;
5453 }
55-
54+
5655 Ok ( result)
5756}
5857
5958fn extract_7z ( path : & str , output_path : & str ) -> Result < ( ) > {
60- decompress_file ( path, output_path)
61- . map_err ( |e| LauncherError :: InternalError ( format ! ( "Failed to extract archive '{}': {}" , path, e) ) )
59+ decompress_file ( path, output_path) . map_err ( |e| {
60+ LauncherError :: InternalError ( format ! ( "Failed to extract archive '{}': {}" , path, e) )
61+ } )
6262}
6363
64- fn copy_files_to_gtasa ( src : & str , gtasa_dir : & str ) -> Result < ( ) > {
65- helpers:: copy_files ( src, gtasa_dir)
66- . map_err ( |_| LauncherError :: InternalError ( "Failed to copy files" . to_string ( ) ) )
64+ fn copy_files_to_gtasa ( src : & str , gtasa_dir : & str ) -> std:: result:: Result < ( ) , String > {
65+ match helpers:: copy_files ( src, gtasa_dir) {
66+ Ok ( _) => Ok ( ( ) ) ,
67+ Err ( e) => {
68+ log:: warn!( "{}" , e) ;
69+ match e {
70+ LauncherError :: AccessDenied ( _) => {
71+ return Err ( "need_admin" . to_string ( ) ) ;
72+ }
73+ _ => return Err ( e. to_string ( ) ) ,
74+ }
75+ }
76+ }
6777}
6878
6979async fn rpc_handler (
@@ -114,7 +124,7 @@ pub async fn initialize_rpc() -> Result<()> {
114124 . service ( web:: resource ( "/rpc/{method}" ) . route ( web:: post ( ) . to ( rpc_handler) ) )
115125 } )
116126 . bind ( format ! ( "127.0.0.1:{}" , RPC_PORT ) )
117- . map_err ( |e| LauncherError :: from ( e) ) ?
127+ . map_err ( |e| LauncherError :: from ( e) ) ?
118128 . run ( )
119129 . await
120130 . map_err ( |e| LauncherError :: from ( e) )
0 commit comments