Removed filetransfer module; migrated to remotefs crate

This commit is contained in:
veeso
2021-12-09 18:07:36 +01:00
committed by Christian Visintin
parent 25dd1b9b0a
commit df7a4381c4
60 changed files with 1185 additions and 6814 deletions

View File

@@ -57,7 +57,7 @@ pub struct Release {
///
/// The update structure defines the options used to install the update.
/// Once you're fine with the options, just call the `upgrade()` method to upgrade termscp.
#[derive(Debug)]
#[derive(Debug, Default)]
pub struct Update {
ask_confirm: bool,
progress: bool,
@@ -141,16 +141,6 @@ impl Update {
}
}
}
impl Default for Update {
fn default() -> Self {
Self {
progress: false,
ask_confirm: false,
}
}
}
impl From<Status> for UpdateStatus {
fn from(s: Status) -> Self {
match s {

View File

@@ -30,8 +30,8 @@ use crate::config::{
params::{UserConfig, DEFAULT_NOTIFICATION_TRANSFER_THRESHOLD},
serialization::{deserialize, serialize, SerializerError, SerializerErrorKind},
};
use crate::explorer::GroupDirs;
use crate::filetransfer::FileTransferProtocol;
use crate::fs::explorer::GroupDirs;
// Ext
use std::fs::{create_dir, remove_file, File, OpenOptions};
use std::io::Write;

View File

@@ -28,8 +28,9 @@
// Locals
use super::config_client::ConfigClient;
// Ext
use remotefs::client::ssh::SshKeyStorage as SshKeyStorageT;
use std::collections::HashMap;
use std::path::PathBuf;
use std::path::{Path, PathBuf};
pub struct SshKeyStorage {
hosts: HashMap<String, PathBuf>, // Association between {user}@{host} and RSA key path
@@ -74,14 +75,6 @@ impl SshKeyStorage {
}
}
/// ### resolve
///
/// Return RSA key path from host and username
pub fn resolve(&self, host: &str, username: &str) -> Option<&PathBuf> {
let key: String = Self::make_mapkey(host, username);
self.hosts.get(&key)
}
/// ### make_mapkey
///
/// Make mapkey from host and username
@@ -100,6 +93,13 @@ impl SshKeyStorage {
}
}
impl SshKeyStorageT for SshKeyStorage {
fn resolve(&self, host: &str, username: &str) -> Option<&Path> {
let key: String = Self::make_mapkey(host, username);
self.hosts.get(&key).map(|x| x.as_path())
}
}
#[cfg(test)]
mod tests {