summaryrefslogtreecommitdiffstats
path: root/src/launcher/assets.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/launcher/assets.rs')
-rw-r--r--src/launcher/assets.rs10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/launcher/assets.rs b/src/launcher/assets.rs
index 992af2a..271f79e 100644
--- a/src/launcher/assets.rs
+++ b/src/launcher/assets.rs
@@ -93,6 +93,10 @@ impl AssetRepository {
home
})
}
+
+ pub fn get_home(&self) -> &Path {
+ self.home.as_path()
+ }
fn get_index_path(&self, id: &str) -> Result<PathBuf, AssetError> {
let mut indexes_path: PathBuf = [self.home.as_ref(), OsStr::new(INDEX_PATH)].iter().collect();
@@ -192,7 +196,7 @@ impl AssetRepository {
format!("{}{:02x}/{}", super::constants::URL_RESOURCE_BASE, obj.hash.bytes()[0], obj.hash)
}
- fn get_object_path(&self, obj: &Asset) -> PathBuf {
+ pub fn get_object_path(&self, obj: &Asset) -> PathBuf {
let hex_digest = obj.hash.to_string();
[self.home.as_ref(), OsStr::new(OBJECT_PATH), OsStr::new(&hex_digest[..2]), OsStr::new(&hex_digest)].iter().collect()
}
@@ -214,7 +218,7 @@ impl AssetRepository {
error: e
})?;
- for object in index.objects.iter() {
+ for object in index.objects.values() {
let path = self.get_object_path(object);
Self::ensure_dir(path.parent().unwrap()).await.map_err(|error| AssetError::IO { error, what: "creating directory for object" })?;
@@ -257,7 +261,7 @@ impl AssetRepository {
fs::create_dir_all(&target_path).await.map_err(|e| AssetError::from(("creating virtual assets directory", e)))?;
- stream::iter(index.objects.iter()
+ stream::iter(index.objects.values()
.map(|object| {
let obj_path = util::check_path(object.name.as_str()).map_err(AssetError::AssetNameError)?;
let obj_path = target_path.join(obj_path);