@@ -21,7 +21,7 @@ impl OciLoader {
2121 Self { working_dir }
2222 }
2323
24- /// Loads a LockedApp with the given OCI client and reference.
24+ /// Pulls and loads an OCI Artifact and returns a LockedApp with the given OCI client and reference
2525 pub async fn load_app ( & self , client : & mut Client , reference : & str ) -> Result < LockedApp > {
2626 // Fetch app
2727 client. pull ( reference) . await . with_context ( || {
@@ -33,6 +33,17 @@ impl OciLoader {
3333 . lockfile_path ( & reference)
3434 . await
3535 . context ( "cannot get path to spin.lock" ) ?;
36+ self . load_from_cache ( lockfile_path, reference, & client. cache )
37+ . await
38+ }
39+
40+ /// Loads an OCI Artifact from the given cache and returns a LockedApp with the given reference
41+ pub async fn load_from_cache (
42+ & self ,
43+ lockfile_path : PathBuf ,
44+ reference : & str ,
45+ cache : & Cache ,
46+ ) -> std:: result:: Result < LockedApp , anyhow:: Error > {
3647 let locked_content = tokio:: fs:: read ( & lockfile_path)
3748 . await
3849 . with_context ( || format ! ( "failed to read from {lockfile_path:?}" ) ) ?;
@@ -47,7 +58,7 @@ impl OciLoader {
4758 . insert ( "origin" . to_string ( ) , origin_uri. into ( ) ) ;
4859
4960 for component in & mut locked_app. components {
50- self . resolve_component_content_refs ( component, & client . cache )
61+ self . resolve_component_content_refs ( component, cache)
5162 . await
5263 . with_context ( || {
5364 format ! ( "failed to resolve content for component {:?}" , component. id)
0 commit comments