use std::sync::Arc;
use object_store::ObjectStore;
use crate::store_paths::models::Location;
#[derive(Debug, Clone)]
pub struct OpenFolder {
pub store: Arc<dyn ObjectStore>,
pub location: Location,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct StoredFile {
pub path: object_store::path::Path,
pub relative_key: String,
pub size: u64,
pub etag: Option<String>,
pub modified_ms: i64,
}
impl StoredFile {
pub fn version(&self) -> String {
match &self.etag {
Some(etag) => etag.trim_matches('"').to_owned(),
None => format!("{}-{}", self.size, self.modified_ms),
}
}
}
pub struct SftpStore {
pub server: crate::ssh_tunnel::models::SshTunnel,
pub root: String,
pub(crate) link: Arc<tokio::sync::OnceCell<SftpLink>>,
}
impl std::fmt::Debug for SftpStore {
fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
formatter,
"SftpStore({}, root {:?})",
self.server.route(),
self.root
)
}
}
impl std::fmt::Display for SftpStore {
fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(formatter, "SFTP({})", self.server.route())
}
}
pub(crate) struct SftpLink {
pub(crate) sftp: russh_sftp::client::SftpSession,
pub(crate) _session: Arc<russh::client::Handle<crate::ssh_tunnel::models::HostCheck>>,
}