@@ -19,7 +19,15 @@ fn hash_package(package_manifest: &PackageManifest, hash_kind: HashKind) -> Resu
1919///
2020/// - Filesystem errors (Out of space, Permissions)
2121/// - Invalid Repository/Package manifest
22- pub fn install_version ( repo_path : & Path , package_id : & str , chunk_store_path : & Path ) -> Result < ( ) > {
22+ ///
23+ /// # Returns
24+ ///
25+ /// Returns the hash of the installed package
26+ pub fn install_version (
27+ repo_path : & Path ,
28+ package_id : & str ,
29+ chunk_store_path : & Path ,
30+ ) -> Result < String > {
2331 let repo_manifest = read_manifest ( repo_path) ?;
2432
2533 let package_manifest = get_package ( & repo_manifest, package_id)
@@ -37,14 +45,22 @@ pub fn install_version(repo_path: &Path, package_id: &str, chunk_store_path: &Pa
3745 serde_yaml:: to_string ( & package_manifest) ?,
3846 ) ?;
3947
40- Ok ( ( ) )
48+ Ok ( package_hash )
4149}
4250
43- pub fn switch_version ( repo_path : & Path , hash : String , package_id : & str ) -> Result < ( ) > {
51+ /// Switch to an older version/package hash.
52+ ///
53+ /// # Errors
54+ ///
55+ /// - Filesystem error during symlink (Within repo directory)
56+ pub fn switch_version ( repo_path : & Path , hash : & str , package_id : & str ) -> Result < ( ) > {
4457 let target_parent_path = repo_path. join ( "installed" ) ;
4558 let target_path = target_parent_path. join ( package_id) ;
59+ fs:: create_dir ( target_parent_path) ?;
4660 symlink ( format ! ( "../versions/{package_id}-{hash}" ) , target_path) ?;
4761
62+ println ! ( "{}" , repo_path. display( ) ) ;
63+
4864 Ok ( ( ) )
4965}
5066
0 commit comments