WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 3abaa7f

Browse files
author
adinata.wijaya
committed
add overwriteable cache dir/lf storage dir
1 parent a9d8fa9 commit 3abaa7f

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/repo_tools/mod.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ mod primitives;
44
use futures_util::TryFutureExt;
55
use glob::glob;
66
use primitives::get_repo_root;
7+
use std::env;
78
use std::path::{Path, PathBuf};
89
use tokio::fs;
910
use tracing::{debug, error, info};
@@ -86,13 +87,17 @@ async fn get_cache_dir<P: AsRef<Path>>(
8687
let oid_1 = &metadata.oid[0..2];
8788
let oid_2 = &metadata.oid[2..4];
8889

89-
Ok(get_real_repo_root(repo_root)
90-
.await?
91-
.join(".git")
92-
.join("lfs")
93-
.join("objects")
94-
.join(oid_1)
95-
.join(oid_2))
90+
let lfs_object_dir = if let Ok(value) = env::var("LFS_STORAGE_DIR") {
91+
debug!("get from env var {}", &value);
92+
PathBuf::from(value)
93+
} else {
94+
get_real_repo_root(repo_root)
95+
.await?
96+
.join(".git")
97+
.join("lfs")
98+
};
99+
100+
Ok(lfs_object_dir.join("objects").join(oid_1).join(oid_2))
96101
}
97102

98103
async fn get_file_cached<P: AsRef<Path>>(

0 commit comments

Comments
 (0)