mirror of
https://github.com/edera-dev/krata.git
synced 2025-08-02 21:00:55 +00:00
hypha: include squashfs version in image cache key
This commit is contained in:
parent
e401a2cb2b
commit
228e42a779
@ -16,6 +16,8 @@ use std::path::PathBuf;
|
|||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
use walkdir::WalkDir;
|
use walkdir::WalkDir;
|
||||||
|
|
||||||
|
pub const IMAGE_SQUASHFS_VERSION: u64 = 1;
|
||||||
|
|
||||||
pub struct ImageInfo {
|
pub struct ImageInfo {
|
||||||
pub squashfs: PathBuf,
|
pub squashfs: PathBuf,
|
||||||
pub manifest: ImageManifest,
|
pub manifest: ImageManifest,
|
||||||
@ -75,8 +77,13 @@ impl ImageCompiler<'_> {
|
|||||||
let mut client = Client::new(image.registry_url()?, name.clone())?;
|
let mut client = Client::new(image.registry_url()?, name.clone())?;
|
||||||
let manifest = client.get_manifest(reference)?;
|
let manifest = client.get_manifest(reference)?;
|
||||||
let manifest_serialized = serde_json::to_string(&manifest)?;
|
let manifest_serialized = serde_json::to_string(&manifest)?;
|
||||||
let manifest_digest = sha256::digest(manifest_serialized);
|
let cache_key = format!(
|
||||||
if let Some(cached) = self.cache.recall(&manifest_digest)? {
|
"manifest\n{}squashfs-version\n{}\n",
|
||||||
|
manifest_serialized, IMAGE_SQUASHFS_VERSION
|
||||||
|
);
|
||||||
|
let cache_digest = sha256::digest(cache_key);
|
||||||
|
|
||||||
|
if let Some(cached) = self.cache.recall(&cache_digest)? {
|
||||||
return Ok(cached);
|
return Ok(cached);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,7 +121,7 @@ impl ImageCompiler<'_> {
|
|||||||
);
|
);
|
||||||
self.squash(image_dir, squash_file)?;
|
self.squash(image_dir, squash_file)?;
|
||||||
let info = ImageInfo::new(squash_file.clone(), manifest.clone(), config)?;
|
let info = ImageInfo::new(squash_file.clone(), manifest.clone(), config)?;
|
||||||
return self.cache.store(&manifest_digest, &info);
|
return self.cache.store(&cache_digest, &info);
|
||||||
}
|
}
|
||||||
Err(Error::MissingLayer.into())
|
Err(Error::MissingLayer.into())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user