Skip to content

Commit

Permalink
Fix warg update
Browse files Browse the repository at this point in the history
This inserts "/package-logs/" into the package logs path, fixing
iteration of the logs.
  • Loading branch information
lann committed Jul 10, 2023
1 parent 9057d7b commit 1afab21
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 5 additions & 3 deletions crates/client/src/storage/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use warg_protocol::{
const TEMP_DIRECTORY: &str = "temp";
const PENDING_PUBLISH_FILE: &str = "pending-publish.json";
const LOCK_FILE_NAME: &str = ".lock";
const PACKAGE_LOGS_DIR: &str = "package-logs";

/// Represents a package storage using the local file system.
pub struct FileSystemRegistryStorage {
Expand Down Expand Up @@ -70,7 +71,7 @@ impl FileSystemRegistryStorage {
}

fn package_path(&self, id: &PackageId) -> PathBuf {
self.base_dir.join(
self.base_dir.join(PACKAGE_LOGS_DIR).join(
LogId::package_log::<Sha256>(id)
.to_string()
.replace(':', "/"),
Expand All @@ -95,11 +96,12 @@ impl RegistryStorage for FileSystemRegistryStorage {
async fn load_packages(&self) -> Result<Vec<PackageInfo>> {
let mut packages = Vec::new();

for entry in WalkDir::new(&self.base_dir) {
let packages_dir = self.base_dir.join(PACKAGE_LOGS_DIR);
for entry in WalkDir::new(&packages_dir) {
let entry = entry.with_context(|| {
anyhow!(
"failed to walk directory `{path}`",
path = self.base_dir.display()
path = packages_dir.display()
)
})?;

Expand Down
4 changes: 4 additions & 0 deletions tests/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ async fn client_incrementally_fetches() -> Result<()> {
// Fetch the package log
client.upsert([&id]).await?;

// Ensure that the package is in the packages list
let packages = client.registry().load_packages().await?;
assert_eq!(packages[0].id.as_ref(), PACKAGE_ID);

// Ensure the package log exists and has releases with all with the same digest
let package = client
.registry()
Expand Down

0 comments on commit 1afab21

Please sign in to comment.