Skip to content
Merged
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
2 changes: 2 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ jobs:

steps:
- uses: actions/checkout@v4
- name: lint
run: cargo clippy --all-targets --all-features -- -D warnings
- name: Build
run: cargo build --verbose
- name: Run tests
Expand Down
8 changes: 4 additions & 4 deletions src/export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ impl Export {
)?;
cache.set_clean_shutdown(false)?;
let chunk_total = cache.chunk_count();
return Ok(Arc::new(Self {
Ok(Arc::new(Self {
journal_path: config.cache_dir.join("snapshot.journal.json"),
clone_seed_path,
config,
Expand All @@ -282,7 +282,7 @@ impl Export {
operation_running: AtomicBool::new(false),
operation_name: StdMutex::new(None),
chunk_locks: (0..chunk_total).map(|_| Mutex::new(())).collect(),
}));
}))
} else {
let resolved = resolve_manifest_for_clone(&*remote, &clone_source).await?;
CloneSeedRecord {
Expand All @@ -300,7 +300,7 @@ impl Export {
cache.set_clean_shutdown(false)?;

let chunk_total = cache.chunk_count();
return Ok(Arc::new(Self {
Ok(Arc::new(Self {
journal_path: config.cache_dir.join("snapshot.journal.json"),
clone_seed_path,
config,
Expand All @@ -312,7 +312,7 @@ impl Export {
operation_running: AtomicBool::new(false),
operation_name: StdMutex::new(None),
chunk_locks: (0..chunk_total).map(|_| Mutex::new(())).collect(),
}));
}))
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,13 +229,13 @@ impl ExportManager {
}

async fn get_managed(&self, export_id: &str) -> Result<Arc<ManagedExport>> {
Ok(self
self
.exports
.read()
.await
.get(export_id)
.cloned()
.ok_or_else(|| Error::InvalidRequest(format!("unknown export {export_id}")))?)
.ok_or_else(|| Error::InvalidRequest(format!("unknown export {export_id}")))
}

async fn ensure_not_loaded(&self, export_id: &str) -> Result<()> {
Expand Down
10 changes: 4 additions & 6 deletions src/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,13 @@ impl Manifest {

let refs: BTreeMap<u32, &RefEntry> =
self.refs.iter().map(|entry| (entry.id, entry)).collect();
if let Some(base_ref) = self.base_ref {
if !refs.contains_key(&base_ref) {
if let Some(base_ref) = self.base_ref
&& !refs.contains_key(&base_ref) {
return Err(Error::InvalidManifest(format!(
"base_ref {} missing from refs",
base_ref
)));
}
}

let mut last_index = None;
for entry in &self.entries {
Expand All @@ -113,14 +112,13 @@ impl Manifest {
entry.index, self.chunk_count
)));
}
if let Some(previous) = last_index {
if entry.index <= previous {
if let Some(previous) = last_index
&& entry.index <= previous {
return Err(Error::InvalidManifest(format!(
"entries not strictly ordered: {} after {}",
entry.index, previous
)));
}
}
last_index = Some(entry.index);

if !refs.contains_key(&entry.ref_id) {
Expand Down
Loading