This commit is contained in:
veeso
2022-03-05 10:35:16 +01:00
committed by Christian Visintin
parent babbc5eadb
commit 697ab225ea
2 changed files with 7 additions and 10 deletions

View File

@@ -85,8 +85,7 @@ impl FileTransferActivity {
SelectedFileIndex::Many(files) => { SelectedFileIndex::Many(files) => {
let files: Vec<&File> = files let files: Vec<&File> = files
.iter() .iter()
.map(|x| self.local().get(*x)) // Usize to Option<File> .filter_map(|x| self.local().get(*x)) // Usize to Option<File>
.flatten()
.collect(); .collect();
SelectedFile::from(files) SelectedFile::from(files)
} }
@@ -101,8 +100,7 @@ impl FileTransferActivity {
SelectedFileIndex::Many(files) => { SelectedFileIndex::Many(files) => {
let files: Vec<&File> = files let files: Vec<&File> = files
.iter() .iter()
.map(|x| self.remote().get(*x)) // Usize to Option<File> .filter_map(|x| self.remote().get(*x)) // Usize to Option<File>
.flatten()
.collect(); .collect();
SelectedFile::from(files) SelectedFile::from(files)
} }
@@ -129,8 +127,7 @@ impl FileTransferActivity {
SelectedFileIndex::Many(files) => { SelectedFileIndex::Many(files) => {
let files: Vec<&File> = files let files: Vec<&File> = files
.iter() .iter()
.map(|x| self.found().as_ref().unwrap().get(*x)) // Usize to Option<File> .filter_map(|x| self.found().as_ref().unwrap().get(*x)) // Usize to Option<File>
.flatten()
.collect(); .collect();
SelectedFile::from(files) SelectedFile::from(files)
} }

View File

@@ -32,16 +32,16 @@ use magic_crypt::MagicCryptTrait;
/// ///
/// Crypt a string using AES128; output is returned as a BASE64 string /// Crypt a string using AES128; output is returned as a BASE64 string
pub fn aes128_b64_crypt(key: &str, input: &str) -> String { pub fn aes128_b64_crypt(key: &str, input: &str) -> String {
let crypter = new_magic_crypt!(key.to_string(), 128); let crypter = new_magic_crypt!(key, 128);
crypter.encrypt_str_to_base64(input.to_string()) crypter.encrypt_str_to_base64(input)
} }
/// ### aes128_b64_decrypt /// ### aes128_b64_decrypt
/// ///
/// Decrypt a string using AES128 /// Decrypt a string using AES128
pub fn aes128_b64_decrypt(key: &str, secret: &str) -> Result<String, magic_crypt::MagicCryptError> { pub fn aes128_b64_decrypt(key: &str, secret: &str) -> Result<String, magic_crypt::MagicCryptError> {
let crypter = new_magic_crypt!(key.to_string(), 128); let crypter = new_magic_crypt!(key, 128);
crypter.decrypt_base64_to_string(secret.to_string()) crypter.decrypt_base64_to_string(secret)
} }
#[cfg(test)] #[cfg(test)]