Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@ jobs:
cache-dependency-path: .pre-commit-config.yaml

# cargo-clippy, cargo-fmt and cargo-deny run as Rust pre-commit hooks.
# Lore formats with nightly; clippy and cargo-deny run on stable.
# Lore formats with nightly; clippy and cargo-deny run on stable. Both are pinned: a new
# release brings new lints and formatting that fail code nobody changed.
- name: Install Rust toolchains
run: |
rustup toolchain install nightly --profile minimal -c rustfmt
rustup component add clippy rustfmt
rustup toolchain install nightly-2026-11-22 --profile minimal -c rustfmt
rustup toolchain install 1.97.1 --profile minimal -c clippy -c rustfmt
rustup default 1.97.1

- name: Cache cargo registry and build artifacts
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ repos:
- id: cargo-fmt
name: cargo format
language: rust
entry: cargo +nightly fmt --all --check
entry: cargo +nightly-2026-11-22 fmt --all --check
pass_filenames: false
always_run: true

Expand Down
4 changes: 2 additions & 2 deletions build-helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ struct LoreVergen {
}

/// The source commit, stamped into the binary so a deployed artifact can be
/// identified. The version name cannot do this: it is CARGO_PKG_VERSION plus a
/// identified. The version name cannot do this: it is `CARGO_PKG_VERSION` plus a
/// Lore revision number that falls back to "0" whenever the CLI probe below
/// fails, so every build in a lineage reports the same string.
/// LORE_BUILD_SHA is checked first because container/CI builds copy a source
/// `LORE_BUILD_SHA` is checked first because container/CI builds copy a source
/// tree without .git, leaving git no way to answer.
fn get_build_sha() -> String {
// Without this, a build in a tree that was built before keeps the stamp of that earlier
Expand Down
41 changes: 22 additions & 19 deletions lore-base/src/fs/lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ impl FSLock {
std::env::var("LORE_LOCK_TIMEOUT_SECS")
.ok()
.and_then(|value| value.parse().ok())
.map(Duration::from_secs)
.unwrap_or(Duration::from_secs(10))
.map_or(Duration::from_secs(10), Duration::from_secs)
}

/// Whether a lock error means "currently held by someone else" (retryable until the
Expand Down Expand Up @@ -153,6 +152,22 @@ impl FSLock {
}
}

impl Drop for FSLock {
fn drop(&mut self) {
#[cfg(target_family = "windows")]
{
// Safety: Calling OS functions
unsafe { FileSystem::UnlockFile(self.file.as_raw_handle(), 0, 0, !0, !0) };
}

#[cfg(not(target_family = "windows"))]
{
// Safety: Calling OS functions
unsafe { libc::flock(self.file.as_raw_fd(), libc::LOCK_UN) };
}
}
}

#[cfg(test)]
mod tests {
use super::*;
Expand All @@ -179,7 +194,11 @@ mod tests {
Ok(_) => panic!("second acquisition must not succeed while held"),
Err(err) => err,
};
assert_eq!(err.kind(), std::io::ErrorKind::TimedOut, "unexpected error: {err}");
assert_eq!(
err.kind(),
std::io::ErrorKind::TimedOut,
"unexpected error: {err}"
);
assert!(
elapsed >= Duration::from_secs(1) && elapsed < Duration::from_secs(8),
"acquisition should time out promptly, took {elapsed:?}"
Expand All @@ -194,19 +213,3 @@ mod tests {
let _ = std::fs::remove_dir_all(&dir);
}
}

impl Drop for FSLock {
fn drop(&mut self) {
#[cfg(target_family = "windows")]
{
// Safety: Calling OS functions
unsafe { FileSystem::UnlockFile(self.file.as_raw_handle(), 0, 0, !0, !0) };
}

#[cfg(not(target_family = "windows"))]
{
// Safety: Calling OS functions
unsafe { libc::flock(self.file.as_raw_fd(), libc::LOCK_UN) };
}
}
}
4 changes: 2 additions & 2 deletions lore-base/src/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ pub static LORE_LIBRARY_VERSION_CSTR: &str =
concat!(env!("VERGEN_LORE_LIBRARY_VERSION_NAME"), "\0");

/// Source commit this binary was built from, or "unknown" when the build had
/// neither LORE_BUILD_SHA nor a git tree. This — not the version name — is what
/// identifies a build: the version name is CARGO_PKG_VERSION plus a Lore revision
/// neither `LORE_BUILD_SHA` nor a git tree. This — not the version name — is what
/// identifies a build: the version name is `CARGO_PKG_VERSION` plus a Lore revision
/// number that degrades to "0", so it is identical across a whole lineage.
pub static LORE_BUILD_SHA: LazyLock<String> =
LazyLock::new(|| env!("VERGEN_LORE_BUILD_SHA").to_owned());
Expand Down
5 changes: 4 additions & 1 deletion lore-client/src/cli/commands/repository.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1156,7 +1156,10 @@ pub fn handle_repository_unmount(_globals: LoreGlobalArgs, args: &RepositoryUnmo
0
}
Ok(status) => {
eprintln!("fusermount3 failed to unmount {}: {status}", args.mountpoint);
eprintln!(
"fusermount3 failed to unmount {}: {status}",
args.mountpoint
);
1
}
Err(err) => {
Expand Down
2 changes: 1 addition & 1 deletion lore-credential/src/token_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -968,7 +968,7 @@ async fn get_token_encryption_key() -> Result<Encryption, TokenStoreError> {
/// that has ended, seen from a job that outlived it), and making a new key resets every token.
async fn load_encryption() -> Result<Encryption, TokenStoreError> {
let encryption_key_nonce = get_secret_from_store(ENCRYPTION_KEY_TARGET).await?;
get_encryption(encryption_key_nonce).map_err(|_| {
get_encryption(encryption_key_nonce).map_err(|_unavailable| {
lore_warn!("{KEY_UNAVAILABLE_MSG}");
TokenStoreError::internal(KEY_UNAVAILABLE_MSG)
})
Expand Down
5 changes: 4 additions & 1 deletion lore-revision/src/branch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,10 @@ pub async fn load_unpinned_push(

/// Drop the note of [`store_unpinned_push`]: the head is pinned on the remote, or gone from it.
pub async fn clear_unpinned_push(repository: Arc<RepositoryContext>, branch: BranchId) {
if load_unpinned_push(repository.clone(), branch).await.is_some() {
if load_unpinned_push(repository.clone(), branch)
.await
.is_some()
{
let _ = mutable_store(repository, UNPINNED_PUSH, branch, Hash::default()).await;
}
}
Expand Down
12 changes: 8 additions & 4 deletions lore-revision/src/branch/push.rs
Original file line number Diff line number Diff line change
Expand Up @@ -964,8 +964,13 @@ async fn push_revisions(
if repository.is_link() {
// Noted in the workspace before the remote is asked, and written out: this
// push may not live to see the answer, and a note still in memory dies with it
branch::store_unpinned_push(repository.clone(), branch, link_base, current_revision)
.await;
branch::store_unpinned_push(
repository.clone(),
branch,
link_base,
current_revision,
)
.await;
let _ = repository.flush(false).await;
}

Expand Down Expand Up @@ -1215,8 +1220,7 @@ async fn withdraw_link_heads(moved: Vec<LinkHeadMove>) {
let Ok(remote) = link.repository.remote().await else {
continue;
};
let Ok(status) =
branch::load_remote(remote.clone(), link.repository.id, link.branch).await
let Ok(status) = branch::load_remote(remote.clone(), link.repository.id, link.branch).await
else {
continue;
};
Expand Down
18 changes: 15 additions & 3 deletions lore-revision/src/file/dirty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,14 +241,23 @@ pub async fn dirty_explicit(
for relative_path in &paths {
match action {
ExplicitDirty::Add => {
dirty_add(repository.clone(), state.clone(), relative_path, stats.clone()).await?;
dirty_add(
repository.clone(),
state.clone(),
relative_path,
stats.clone(),
)
.await?;
changed = true;
}
ExplicitDirty::Modify => {
let Some(link) =
resolve_dirty_link(&repository, &state, &state_current, relative_path).await
else {
lore_trace!("dirty_explicit modify: no node for {}", relative_path.as_str());
lore_trace!(
"dirty_explicit modify: no node for {}",
relative_path.as_str()
);
continue;
};
state
Expand All @@ -261,7 +270,10 @@ pub async fn dirty_explicit(
let Some(link) =
resolve_dirty_link(&repository, &state, &state_current, relative_path).await
else {
lore_trace!("dirty_explicit delete: no node for {}", relative_path.as_str());
lore_trace!(
"dirty_explicit delete: no node for {}",
relative_path.as_str()
);
continue;
};
dirty_delete(
Expand Down
8 changes: 6 additions & 2 deletions lore-revision/src/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,9 @@ pub async fn load_current_anchor(
// file-based `.urc/current` (32-byte revision + 16-byte branch). Migration
// into the mutable store only runs in write-mode contexts, so a read-only
// command on a repository with unmigrated anchors would otherwise fail.
let dot_path = repository.require_metadata_path()?.join(repository.format.dot_dir());
let dot_path = repository
.require_metadata_path()?
.join(repository.format.dot_dir());
let current_anchor_path = dot_path.join(crate::anchor::CURRENT);
if current_anchor_path.exists()
&& let Ok((file_revision, file_branch)) =
Expand Down Expand Up @@ -447,7 +449,9 @@ pub async fn load_staged_revision(
// file (32-byte revision + 16-byte branch — branch is ignored here, the
// staged anchor only carries a revision). Mirrors load_current_anchor's
// file-based fallback for read-only commands on unmigrated repositories.
let dot_path = repository.require_metadata_path()?.join(repository.format.dot_dir());
let dot_path = repository
.require_metadata_path()?
.join(repository.format.dot_dir());
let staged_anchor_path = dot_path.join(crate::anchor::STAGED);
if staged_anchor_path.exists()
&& let Ok((file_revision, _branch)) =
Expand Down
4 changes: 2 additions & 2 deletions lore-revision/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ pub mod state;
pub mod store;
pub mod util;

#[cfg(feature = "vfs")]
pub mod vfs;
#[cfg(all(target_family = "windows", feature = "vfs"))]
pub mod projfs;
#[cfg(feature = "vfs")]
pub mod vfs;
//#[cfg(all(target_family = "windows", feature = "vfs"))]
//pub mod swfs;

Expand Down
11 changes: 7 additions & 4 deletions lore-revision/src/projfs/serve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,11 +469,12 @@ pub fn serve(

/// Name of the per-mountpoint Win32 event `unmount` uses to signal the serving process.
fn stop_event_name(mountpoint: &Path) -> Vec<u16> {
let canonical =
std::fs::canonicalize(mountpoint).unwrap_or_else(|_| mountpoint.to_path_buf());
let canonical = std::fs::canonicalize(mountpoint).unwrap_or_else(|_| mountpoint.to_path_buf());
let key = canonical.to_string_lossy().to_lowercase();
let hash = xxhash_rust::xxh3::xxh3_64(key.as_bytes());
let mut wide: Vec<u16> = format!("Local\\LoreVfsStop-{hash:016x}").encode_utf16().collect();
let mut wide: Vec<u16> = format!("Local\\LoreVfsStop-{hash:016x}")
.encode_utf16()
.collect();
wide.push(0);
wide
}
Expand Down Expand Up @@ -1172,7 +1173,9 @@ unsafe extern "system" fn get_placeholder_info(

/// Build the ProjFS placeholder metadata for a resolved node: type, size, revision timestamps,
/// and the provider/content identity ProjFS uses to detect stale placeholders.
async fn placeholder_info_for(resolved: &ResolvedNode) -> ProjectedFileSystem::PRJ_PLACEHOLDER_INFO {
async fn placeholder_info_for(
resolved: &ResolvedNode,
) -> ProjectedFileSystem::PRJ_PLACEHOLDER_INFO {
let timestamp = ms_filetime(resolved.revision_timestamp_ms().await) as i64;

// Safety: This type is safe to zero initialize but not marked with default in windows_sys
Expand Down
36 changes: 18 additions & 18 deletions lore-revision/src/repository.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2188,23 +2188,20 @@ pub async fn load_and_connect_with_token(
} else {
None
};
match working_root {
Some(root) => {
lore_debug!(
"Working tree bound to {} (mount {})",
root.display(),
if live { "live" } else { "not served" }
);
repository.with_working_root(root, live)
}
None => {
lore_warn!(
"This repository's working tree is bound to the mountpoint {}, which \
no longer exists; operating on the repository directory instead",
binding.mountpoint.display()
);
repository
}
if let Some(root) = working_root {
lore_debug!(
"Working tree bound to {} (mount {})",
root.display(),
if live { "live" } else { "not served" }
);
repository.with_working_root(root, live)
} else {
lore_warn!(
"This repository's working tree is bound to the mountpoint {}, which \
no longer exists; operating on the repository directory instead",
binding.mountpoint.display()
);
repository
}
}
_ => repository,
Expand Down Expand Up @@ -2490,6 +2487,7 @@ pub fn read_mount_binding(dot_path: &Path) -> Option<MountBinding> {
}

/// Record the mount binding for a repository.
#[allow(clippy::disallowed_methods)] // Authorized writer of the `.lore` mount-binding file.
pub fn write_mount_binding(
dot_path: &Path,
mountpoint: &Path,
Expand Down Expand Up @@ -3537,7 +3535,9 @@ pub fn repository_remote(repository_path: impl AsRef<str>) -> Result<String, Rep
}

pub async fn gc(repository: Arc<RepositoryContext>) -> Result<(), RepositoryError> {
let dot_path = repository.require_metadata_path()?.join(repository.format.dot_dir());
let dot_path = repository
.require_metadata_path()?
.join(repository.format.dot_dir());
let config_path = dot_path.join(CONFIG);

let config = load_config(config_path.as_path())?;
Expand Down
13 changes: 7 additions & 6 deletions lore-revision/src/repository/clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ pub struct CloneOptions {
/// a FUSE mount fully virtualizes its mountpoint, hiding the co-located `.lore` from the
/// serving process, whose next path-based store access would re-enter its own mount and
/// deadlock in the kernel — so the repository is created elsewhere (the caller relocates
/// it) and the mount serves this path. Unused on Windows, where ProjFS projects into the
/// it) and the mount serves this path. Unused on Windows, where `ProjFS` projects into the
/// repository directory and passes real files through.
pub virtual_mountpoint: Option<PathBuf>,
/// Use direct file write
Expand Down Expand Up @@ -1324,16 +1324,14 @@ async fn clone_materialize(
repository directory (CloneOptions::virtual_mountpoint)"
);
return Err(NotSupported {
operation: "Virtual clone on Linux requires a separate mountpoint"
.to_string(),
operation: "Virtual clone on Linux requires a separate mountpoint".to_string(),
}
.into());
};
let overlay = PathBuf::from(format!("{}-overlay", mountpoint.display()));
std::fs::create_dir_all(&mountpoint)
.internal("Failed to create the mountpoint directory")?;
std::fs::create_dir_all(&overlay)
.internal("Failed to create the overlay directory")?;
std::fs::create_dir_all(&overlay).internal("Failed to create the overlay directory")?;
crate::repository::write_mount_binding(
&_path.join(repository.format.dot_dir()),
&mountpoint,
Expand Down Expand Up @@ -1361,7 +1359,10 @@ async fn clone_materialize(
}
.into());
}
#[cfg(all(feature = "vfs", not(any(target_family = "windows", target_os = "linux"))))]
#[cfg(all(
feature = "vfs",
not(any(target_family = "windows", target_os = "linux"))
))]
{
lore_error!("Virtual repositories not yet supported on this platform");
return Err(NotSupported {
Expand Down
8 changes: 4 additions & 4 deletions lore-revision/src/stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,10 +348,6 @@ pub(crate) async fn process_link_updates(
Ok(())
}

/// Stage changes from filesystem into the given state
/// The base directory is the point where the relative path starts
/// Only the relative path will be checked for case consistency
#[allow(clippy::too_many_arguments)]
/// Enforce the cross-VCS disjointness invariant: a file tracked by a git working tree
/// covering this workspace must not be staged into Lore — once staged, a backward sync would
/// overwrite or delete the git-tracked source. This holds even when the ignore allowlist is
Expand All @@ -376,6 +372,10 @@ fn ensure_not_git_tracked(
Ok(())
}

/// Stage changes from filesystem into the given state
/// The base directory is the point where the relative path starts
/// Only the relative path will be checked for case consistency
#[allow(clippy::too_many_arguments)]
pub(crate) async fn stage_filesystem_path(
repository: Arc<RepositoryContext>,
state: Arc<State>,
Expand Down
Loading