-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathcache_check.rs
More file actions
34 lines (28 loc) · 882 Bytes
/
cache_check.rs
File metadata and controls
34 lines (28 loc) · 882 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
use clipanion::cli;
use zpm_utils::{get_system_string};
use crate::{cache, errors::Error};
/// Check if the specified versions are available in the cache
#[cli::command]
#[cli::path("switch", "cache")]
#[cli::category("Cache management")]
#[derive(Debug)]
pub struct CacheCheckCommand {
#[cli::option("--check")]
_check: bool,
versions: Vec<zpm_semver::Version>,
}
impl CacheCheckCommand {
pub async fn execute(&self) -> Result<(), Error> {
for version in &self.versions {
let cache_key = cache::CacheKey {
cache_version: cache::CACHE_VERSION,
version: version.clone(),
platform: get_system_string().to_string(),
};
if !cache::check(&cache_key).await? {
return Err(Error::CacheNotFound(version.clone()));
}
}
Ok(())
}
}