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 240a5c8
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 3 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
2 changes: 1 addition & 1 deletion Cargo.lock

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

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@ 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 }

[target.'cfg(unix)'.dependencies]
uzers = "0.11.3"

[dev-dependencies]
tempfile = "3.10.0"

Expand Down
28 changes: 28 additions & 0 deletions src/repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,29 @@ fn db_dirname(root: &Path, tmp_dir: &Path) -> String {
md5(&mut st.as_bytes())
}

#[cfg(windows)]
fn db_dirname(root: &Path, tmp_dir: &Path) -> String {
use std::os::unix::ffi::OsStrExt;

Check failure on line 68 in src/repo.rs

View workflow job for this annotation

GitHub Actions / Check (windows-latest)

failed to resolve: could not find `unix` in `os`
let btime = btime(tmp_dir).unwrap();
let user = uzers::get_current_username().unwrap();
let dvc_major = 3;
let salt = 2;

let mut st: OsString = "('".into();
st.push(root.as_os_str());
st.push("', ");
st.push(btime.to_string());
st.push(", '");
st.push(user);
st.push("', ");
st.push(dvc_major.to_string());
st.push(", ");
st.push(salt.to_string());
st.push(")");

md5(&mut st.as_bytes())
}

#[cfg(not(any(
target_os = "windows",
target_os = "macos",
Expand All @@ -73,6 +96,11 @@ fn db_dirs() -> PathBuf {
"/var/tmp/dvc/repo".into()
}

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

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

0 comments on commit 240a5c8

Please sign in to comment.