Skip to content

Commit edf05cb

Browse files
authored
chore: update file name (#54)
* chore: update file name Signed-off-by: kerthcet <kerthcet@gmail.com> * fix Signed-off-by: kerthcet <kerthcet@gmail.com> * update Signed-off-by: kerthcet <kerthcet@gmail.com> * update Signed-off-by: kerthcet <kerthcet@gmail.com> --------- Signed-off-by: kerthcet <kerthcet@gmail.com>
1 parent c1b8a23 commit edf05cb

6 files changed

Lines changed: 33 additions & 34 deletions

File tree

src/cli/commands.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ use clap::{Parser, Subcommand};
22
use prettytable::{format, row, Table};
33

44
use crate::cli::{inspect, ls, rm};
5-
use crate::downloader::downloader::Downloader;
65
use crate::downloader::huggingface::HuggingFaceDownloader;
6+
use crate::downloader::Downloader;
77
use crate::registry::model_registry::ModelRegistry;
88
use crate::system::system_info::SystemInfo;
99
use crate::utils::format::{format_size_decimal, format_time_ago};

src/downloader/downloader.rs

Lines changed: 0 additions & 28 deletions
This file was deleted.

src/downloader/huggingface.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ use tracing::debug;
44
use hf_hub::api::tokio::{ApiBuilder, Progress};
55
use indicatif::{ProgressBar, ProgressStyle};
66

7-
use crate::downloader::downloader::{DownloadError, Downloader};
87
use crate::downloader::progress::{DownloadProgressManager, FileProgress};
8+
use crate::downloader::{DownloadError, Downloader};
99
use crate::registry::model_registry::{CacheInfo, ModelInfo, ModelMetadata, ModelRegistry};
1010
use crate::utils::file::{self, format_model_name};
1111

src/downloader/mod.rs

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,31 @@
1-
#[allow(clippy::module_inception)]
2-
pub mod downloader;
1+
use core::fmt;
2+
33
pub mod huggingface;
44
pub mod progress;
5+
6+
#[derive(Debug)]
7+
pub enum DownloadError {
8+
NetworkError(String),
9+
AuthError(String),
10+
ModelNotFound(String),
11+
IoError(String),
12+
ApiError(String),
13+
}
14+
15+
impl std::error::Error for DownloadError {}
16+
17+
impl fmt::Display for DownloadError {
18+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
19+
match self {
20+
DownloadError::NetworkError(e) => write!(f, "Network error: {}", e),
21+
DownloadError::AuthError(e) => write!(f, "Authentication error: {}", e),
22+
DownloadError::ModelNotFound(e) => write!(f, "Model not found: {}", e),
23+
DownloadError::IoError(e) => write!(f, "IO error: {}", e),
24+
DownloadError::ApiError(e) => write!(f, "API error: {}", e),
25+
}
26+
}
27+
}
28+
29+
pub trait Downloader {
30+
async fn download_model(&self, name: &str) -> Result<(), DownloadError>;
31+
}

src/storage/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
pub mod model_storage;
12
pub mod sqlite;
2-
pub mod storage_trait;
33

4+
pub use model_storage::ModelStorage;
45
pub use sqlite::SqliteStorage;
5-
pub use storage_trait::ModelStorage;

0 commit comments

Comments
 (0)