/// This only allows deleting files from the DB directory.
/// eg:
/// to delete "/sdcard/telemetry/123456789.db"
/// graphql `mutation{delete(files:["123456789.db"])}`
This only allows deleting files from the DB directory.
This only allows deleting files from the DB directory .
fn delete(context: &Context, files: Vec<String>) -> FieldResult<Vec<String>> {
        let db_path = context.subsystem().db_path.to_owned();
        let dir = db_path.parent().ok_or(FieldError::new(
            "path does not have a parent",
            Value::null(),
        ))?;
        Ok(files
            .iter()
            .map(|file| {
                let mut path = dir.to_owned();
                path.push(file);
                path
            })
            .filter(|path| std::fs::remove_file(&path).is_ok())
            .filter_map(|path| path.to_str().map(|s| s.to_owned()))
            .collect())
    }
fn delete ( context : & Context , files : Vec < String > ) -> FieldResult < Vec < String > > { let db_path = context . subsystem ( ) . db_path . to_owned ( ) ; let dir = db_path . parent ( ) . ok_or ( FieldError :: new ( " " , Value :: null ( ) , ) ) ? ; Ok ( files . iter ( ) . map ( | file | { let mut path = dir . to_owned ( ) ; path . push ( file ) ; path } ) . filter ( | path | std :: fs :: remove_file ( & path ) . is_ok ( ) ) . filter_map ( | path | path . to_str ( ) . map ( | s | s . to_owned ( ) ) ) . collect ( ) ) }
This only allows deleting files from the DB directory.
This only allows deleting files from the DB directory .
context
&Context
files
Vec<String>