Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/cli/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use clap::{Parser, Subcommand};
use prettytable::{format, row, Table};

use crate::cli::{inspect, ls, rm};
use crate::downloader::downloader::Downloader;
use crate::downloader::huggingface::HuggingFaceDownloader;
use crate::downloader::Downloader;
use crate::registry::model_registry::ModelRegistry;
use crate::system::system_info::SystemInfo;
use crate::utils::format::{format_size_decimal, format_time_ago};
Expand Down
28 changes: 0 additions & 28 deletions src/downloader/downloader.rs

This file was deleted.

2 changes: 1 addition & 1 deletion src/downloader/huggingface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use tracing::debug;
use hf_hub::api::tokio::{ApiBuilder, Progress};
use indicatif::{ProgressBar, ProgressStyle};

use crate::downloader::downloader::{DownloadError, Downloader};
use crate::downloader::progress::{DownloadProgressManager, FileProgress};
use crate::downloader::{DownloadError, Downloader};
use crate::registry::model_registry::{CacheInfo, ModelInfo, ModelMetadata, ModelRegistry};
use crate::utils::file::{self, format_model_name};

Expand Down
31 changes: 29 additions & 2 deletions src/downloader/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,31 @@
#[allow(clippy::module_inception)]
pub mod downloader;
use core::fmt;

pub mod huggingface;
pub mod progress;

#[derive(Debug)]
pub enum DownloadError {
NetworkError(String),
AuthError(String),
ModelNotFound(String),
IoError(String),
ApiError(String),
}

impl std::error::Error for DownloadError {}

impl fmt::Display for DownloadError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
DownloadError::NetworkError(e) => write!(f, "Network error: {}", e),
DownloadError::AuthError(e) => write!(f, "Authentication error: {}", e),
DownloadError::ModelNotFound(e) => write!(f, "Model not found: {}", e),
DownloadError::IoError(e) => write!(f, "IO error: {}", e),
DownloadError::ApiError(e) => write!(f, "API error: {}", e),
}
}
}

pub trait Downloader {
async fn download_model(&self, name: &str) -> Result<(), DownloadError>;
}
4 changes: 2 additions & 2 deletions src/storage/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pub mod model_storage;
pub mod sqlite;
pub mod storage_trait;

pub use model_storage::ModelStorage;
pub use sqlite::SqliteStorage;
pub use storage_trait::ModelStorage;
File renamed without changes.
Loading