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
4 changes: 2 additions & 2 deletions src/cli/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ pub async fn run(cli: Cli) {

let mut table = Table::new();
table.set_format(*format::consts::FORMAT_CLEAN);
table.add_row(row!["MODEL", "PROVIDER", "REVISION", "SIZE", "CREATED"]);
table.add_row(row!["MODEL", "PROVIDER", "REVISION", "SIZE", "MODIFIED"]);

for model in models {
let size_str = format_size_decimal(model.size);
Expand All @@ -100,7 +100,7 @@ pub async fn run(cli: Cli) {
&model.revision
};

let created_str = format_time_ago(&model.created_at);
let created_str = format_time_ago(&model.modified_at);

table.add_row(row![
model.name,
Expand Down
18 changes: 13 additions & 5 deletions src/downloader/huggingface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ impl Downloader for HuggingFaceDownloader {
let sha = model_info.sha.clone();
let snapshot_path = model_cache_path.join("snapshots").join(&sha);

// Check if all files are already cached
let model_totally_cached = model_info
.siblings
.iter()
.all(|sibling| snapshot_path.join(&sibling.rfilename).exists());

// Process all files in manifest order (cached files show as instantly complete)
let mut tasks = Vec::new();

Expand Down Expand Up @@ -168,14 +174,16 @@ impl Downloader for HuggingFaceDownloader {
provider: "huggingface".to_string(),
revision: sha,
size: downloaded_size,
created_at: chrono::Local::now().to_rfc3339(),
modified_at: chrono::Local::now().to_rfc3339(),
cache_path: model_cache_path.to_string_lossy().to_string(),
};

let registry = ModelRegistry::new(None);
registry
.register_model(model_info_record)
.map_err(|e| DownloadError::ApiError(format!("Failed to register model: {}", e)))?;
if !model_totally_cached {
let registry = ModelRegistry::new(None);
registry
.register_model(model_info_record)
.map_err(|e| DownloadError::ApiError(format!("Failed to register model: {}", e)))?;
}

println!(
"\n{} {} {} {} {:.2?}",
Expand Down
14 changes: 7 additions & 7 deletions src/registry/model_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub struct ModelInfo {
pub provider: String,
pub revision: String,
pub size: u64,
pub created_at: String,
pub modified_at: String,
pub cache_path: String,
}

Expand Down Expand Up @@ -122,7 +122,7 @@ mod tests {
provider: "huggingface".to_string(),
revision: "abc123".to_string(),
size: 1000,
created_at: "2025-01-01T00:00:00Z".to_string(),
modified_at: "2025-01-01T00:00:00Z".to_string(),
cache_path: "/tmp/test".to_string(),
};

Expand All @@ -143,7 +143,7 @@ mod tests {
provider: "huggingface".to_string(),
revision: "abc123".to_string(),
size: 1000,
created_at: "2025-01-01T00:00:00Z".to_string(),
modified_at: "2025-01-01T00:00:00Z".to_string(),
cache_path: "/tmp/test".to_string(),
};

Expand All @@ -164,7 +164,7 @@ mod tests {
provider: "huggingface".to_string(),
revision: "abc123".to_string(),
size: 1000,
created_at: "2025-01-01T00:00:00Z".to_string(),
modified_at: "2025-01-01T00:00:00Z".to_string(),
cache_path: "/tmp/test".to_string(),
};

Expand Down Expand Up @@ -198,7 +198,7 @@ mod tests {
provider: "huggingface".to_string(),
revision: "abc123".to_string(),
size: 1000,
created_at: "2025-01-01T00:00:00Z".to_string(),
modified_at: "2025-01-01T00:00:00Z".to_string(),
cache_path: "/tmp/test".to_string(),
};

Expand All @@ -209,7 +209,7 @@ mod tests {
provider: "huggingface".to_string(),
revision: "def456".to_string(),
size: 2000,
created_at: "2025-01-02T00:00:00Z".to_string(),
modified_at: "2025-01-02T00:00:00Z".to_string(),
cache_path: "/tmp/test2".to_string(),
};

Expand All @@ -236,7 +236,7 @@ mod tests {
provider: "huggingface".to_string(),
revision: "abc123".to_string(),
size: 1000,
created_at: "2025-01-01T00:00:00Z".to_string(),
modified_at: "2025-01-01T00:00:00Z".to_string(),
cache_path: cache_dir.to_string_lossy().to_string(),
};

Expand Down
Loading