Skip to content

Commit 176d1c8

Browse files
authored
Move FileLock into oak_cache and remove oak_fs (#1321)
More minor follow up from the source PRs, nothing to see here really
1 parent 6618e9a commit 176d1c8

12 files changed

Lines changed: 26 additions & 49 deletions

File tree

Cargo.lock

Lines changed: 2 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ notify = "8.2.0"
7878
oak_cache = { path = "crates/oak_cache" }
7979
oak_core = { path = "crates/oak_core" }
8080
oak_db = { path = "crates/oak_db" }
81-
oak_fs = { path = "crates/oak_fs" }
8281
oak_ide = { path = "crates/oak_ide" }
8382
oak_index_vec = { path = "crates/oak_index_vec" }
8483
oak_package_metadata = { path = "crates/oak_package_metadata" }

crates/oak_cache/Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@ license.workspace = true
99
[dependencies]
1010
anyhow.workspace = true
1111
etcetera.workspace = true
12+
libc.workspace = true
1213
log.workspace = true
13-
oak_fs.workspace = true
14+
15+
[target.'cfg(windows)'.dependencies]
16+
windows-sys = { workspace = true, features = ["Win32_Foundation"] }
1417

1518
[dev-dependencies]
1619
tempfile.workspace = true

crates/oak_cache/src/lib.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@
77
//! completion-sentinel, last-access, and LRU-eviction machinery all live here so
88
//! callers don't reimplement it.
99
10+
mod file_lock;
11+
1012
use std::path::Path;
1113
use std::path::PathBuf;
1214
use std::time::SystemTime;
1315

14-
use oak_fs::file_lock::FileLock;
15-
use oak_fs::file_lock::Filesystem;
16+
use crate::file_lock::FileLock;
17+
use crate::file_lock::Filesystem;
1618

1719
/// Name of the root lock file and the per-key lock file.
1820
const LOCK_FILENAME: &str = ".lock";

crates/oak_fs/Cargo.toml

Lines changed: 0 additions & 18 deletions
This file was deleted.

crates/oak_fs/src/lib.rs

Lines changed: 0 additions & 2 deletions
This file was deleted.

crates/oak_fs/src/permissions.rs

Lines changed: 0 additions & 8 deletions
This file was deleted.

crates/oak_source/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ anyhow.workspace = true
1111
flate2.workspace = true
1212
log.workspace = true
1313
oak_cache.workspace = true
14-
oak_fs.workspace = true
1514
tar.workspace = true
1615
ureq.workspace = true
1716

crates/oak_source/src/extract.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ pub(crate) fn extract(reader: impl Read, dir: &Path) -> anyhow::Result<()> {
4545
entry.unpack(&destination)?;
4646

4747
if is_file {
48-
oak_fs::permissions::set_readonly(&destination)?;
48+
set_readonly(&destination)?;
4949
}
5050
}
5151

@@ -74,3 +74,10 @@ fn strip_top_level(path: &Path) -> Option<&Path> {
7474

7575
Some(rest)
7676
}
77+
78+
/// Mark a file as read only
79+
fn set_readonly(path: &Path) -> std::io::Result<()> {
80+
let mut permissions = std::fs::metadata(path)?.permissions();
81+
permissions.set_readonly(true);
82+
std::fs::set_permissions(path, permissions)
83+
}

0 commit comments

Comments
 (0)