Skip to content

Commit

Permalink
windows support
Browse files Browse the repository at this point in the history
  • Loading branch information
skshetry committed Feb 19, 2024
1 parent a506406 commit 1b7904c
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 19 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ env:
jobs:
ci:
name: Check
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
Expand Down
34 changes: 22 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ ignore = "0.4.22"
itertools = "0.12.1"
env_logger = "0.11.2"
log = "0.4.20"
uzers = "0.11.3"
config = "0.14.0"
serde_derive = "1.0.196"
directories = "5.0.1"
git2 = { version = "0.18.2", default-features = false }
whoami = "1.4.1"

[dev-dependencies]
tempfile = "3.10.0"
Expand Down
15 changes: 10 additions & 5 deletions src/repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,16 @@ fn btime(tmp_dir: &Path) -> Result<f64, io::Error> {
}
}

#[cfg(unix)]
fn db_dirname(root: &Path, tmp_dir: &Path) -> String {
use std::os::unix::ffi::OsStrExt;
let btime = btime(tmp_dir).unwrap();
let user = uzers::get_current_username().unwrap();
let user = whoami::username();
let dvc_major = 3;
let salt = 2;
let salt = 0;

let mut st: OsString = "('".into();
st.push(root.as_os_str());
st.push("', ");
st.push("None, "); // subdir
st.push(btime.to_string());
st.push(", '");
st.push(user);
Expand All @@ -60,7 +59,7 @@ fn db_dirname(root: &Path, tmp_dir: &Path) -> String {
st.push(salt.to_string());
st.push(")");

md5(&mut st.as_bytes())
md5(&mut st.as_encoded_bytes())
}

#[cfg(not(any(
Expand All @@ -73,6 +72,12 @@ fn db_dirs() -> PathBuf {
"/var/tmp/dvc/repo".into()
}

#[cfg(target_os = "windows")]
fn db_dirs() -> PathBuf {
Path::new(&env::var("CSIDL_COMMON_APPDATA").unwrap_or("C:/ProgramData/iterative/dvc".into()))
.to_owned()
}

#[cfg(target_os = "macos")]
fn db_dirs() -> PathBuf {
"/Library/Caches/dvc/repo".into()
Expand Down

0 comments on commit 1b7904c

Please sign in to comment.