fn write_file_by_path(
        &self,
        path: String,
        content: String,
        filesystem_name: String,
        state_id: u8,
        token: String,
    ) -> BoxFuture<RPCResult<Result<(), Errors>>> {
        let states = self.states.clone();
        Box::pin(async move {
            let states = states.lock().await;
            // Try to get the requested state
            if let Some(state) = states.get_state_by_id(state_id) {
                let state = state.lock().await;
                // Make sure the token is valid
                if state.has_token(&token) {
                    // Try to get the requested filesystem implementation
                    if let Some(filesystem) = state.get_fs_by_name(&filesystem_name) {
                        let filesystem = filesystem.lock().await;
                        let result = filesystem.write_file_by_path(&path, &content);
                        let result = result.await;

                        state.notify_extensions(ExtensionMessages::WriteFile(
                            state_id,
                            filesystem_name,
                            content,
                            result.clone(),
                        ));
                        Ok(result)
                    } else {
                        Ok(Err(Errors::Fs(FilesystemErrors::FilesystemNotFound)))
                    }
                } else {
                    Ok(Err(Errors::BadToken))
                }
            } else {
                Ok(Err(Errors::StateNotFound))
            }
        })
    }
/// Writes new content to the specified path
Writes new content to the specified path
Writes new content to the specified path
fn write_file_by_path(
        &self,
        path: String,
        content: String,
        filesystem_name: String,
        state_id: u8,
        token: String,
    ) -> BoxFuture<RPCResult<Result<(), Errors>>> {
        let states = self.states.clone();
        Box::pin(async move {
            let states = states.lock().await;
            // Try to get the requested state
            if let Some(state) = states.get_state_by_id(state_id) {
                let state = state.lock().await;
                // Make sure the token is valid
                if state.has_token(&token) {
                    // Try to get the requested filesystem implementation
                    if let Some(filesystem) = state.get_fs_by_name(&filesystem_name) {
                        let filesystem = filesystem.lock().await;
                        let result = filesystem.write_file_by_path(&path, &content);
                        let result = result.await;
                        state.notify_extensions(ExtensionMessages::WriteFile(
                            state_id,
                            filesystem_name,
                            content,
                            result.clone(),
                        ));
                        Ok(result)
                    } else {
                        Ok(Err(Errors::Fs(FilesystemErrors::FilesystemNotFound)))
                    }
                } else {
                    Ok(Err(Errors::BadToken))
                }
            } else {
                Ok(Err(Errors::StateNotFound))
            }
        })
    }
fn write_file_by_path ( & self , path : String , content : String , filesystem_name : String , state_id : u8 , token : String , ) -> BoxFuture < RPCResult < Result < ( ) , Errors > > > { let states = self . states . clone ( ) ; Box :: pin ( async move { let states = states . lock ( ) . await ; // Try to get the requested state if let Some ( state ) = states . get_state_by_id ( state_id ) { let state = state . lock ( ) . await ; // Make sure the token is valid if state . has_token ( & token ) { // Try to get the requested filesystem implementation if let Some ( filesystem ) = state . get_fs_by_name ( & filesystem_name ) { let filesystem = filesystem . lock ( ) . await ; let result = filesystem . write_file_by_path ( & path , & content ) ; let result = result . await ; state . notify_extensions ( ExtensionMessages :: WriteFile ( state_id , filesystem_name , content , result . clone ( ) , ) ) ; Ok ( result ) } else { Ok ( Err ( Errors :: Fs ( FilesystemErrors :: FilesystemNotFound ) ) ) } } else { Ok ( Err ( Errors :: BadToken ) ) } } else { Ok ( Err ( Errors :: StateNotFound ) ) } } ) }
Writes new content to the specified path
Writes new content to the specified path
&self
path
String
content
String
filesystem_name
String
state_id
u8
token
String