Skip to content

Commit

Permalink
ref(proguard): Simplify download code (#1419)
Browse files Browse the repository at this point in the history
  • Loading branch information
loewenheim authored Mar 27, 2024
1 parent 0f6e0c9 commit 115e4a5
Showing 1 changed file with 15 additions and 30 deletions.
45 changes: 15 additions & 30 deletions crates/symbolicator-proguard/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,33 +38,8 @@ impl ProguardService {
}
}

async fn find_proguard_file(
&self,
sources: &[SourceConfig],
identifier: &ObjectId,
) -> Option<RemoteFile> {
let file_ids = self
.download_svc
.list_files(sources, &[FileType::Proguard], identifier)
.await;

file_ids.into_iter().next()
}

/// Retrieves the given [`RemoteFile`] from cache, or fetches it and persists it according
/// to the provided [`Scope`].
/// It is possible to avoid using the shared cache using the `use_shared_cache` parameter.
pub async fn fetch_file(&self, scope: &Scope, file: RemoteFile) -> CacheEntry<ProguardMapper> {
let cache_key = CacheKey::from_scoped_file(scope, &file);

let request = FetchProguard {
file,
download_svc: Arc::clone(&self.download_svc),
};

self.cache.compute_memoized(request, cache_key).await
}

/// Downloads a proguard file for the given scope and debug id and converts it into a
/// `ProguardMapper`.
pub async fn download_proguard_file(
&self,
sources: &[SourceConfig],
Expand All @@ -76,12 +51,22 @@ impl ProguardService {
..Default::default()
};

let remote_file = self
.find_proguard_file(sources, &identifier)
let file = self
.download_svc
.list_files(sources, &[FileType::Proguard], &identifier)
.await
.into_iter()
.next()
.ok_or(CacheError::NotFound)?;

self.fetch_file(scope, remote_file).await
let cache_key = CacheKey::from_scoped_file(scope, &file);

let request = FetchProguard {
file,
download_svc: Arc::clone(&self.download_svc),
};

self.cache.compute_memoized(request, cache_key).await
}

/// Downloads a source bundle for the given scope and debug id.
Expand Down

0 comments on commit 115e4a5

Please sign in to comment.