refactor: clean up unwrap and clone (#17282)

Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com>
This commit is contained in:
Yiyu Lin 2023-01-15 12:06:46 +08:00 committed by GitHub
parent 05ef925eb0
commit fd85f840cd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 75 additions and 94 deletions

View file

@ -239,7 +239,7 @@ impl NpmResolution {
package_reqs: Vec<NpmPackageReq>,
) -> Result<(), AnyError> {
// only allow one thread in here at a time
let _permit = self.update_semaphore.acquire().await.unwrap();
let _permit = self.update_semaphore.acquire().await?;
let snapshot = self.snapshot.read().clone();
let snapshot = self
@ -255,7 +255,7 @@ impl NpmResolution {
package_reqs: HashSet<NpmPackageReq>,
) -> Result<(), AnyError> {
// only allow one thread in here at a time
let _permit = self.update_semaphore.acquire().await.unwrap();
let _permit = self.update_semaphore.acquire().await?;
let snapshot = self.snapshot.read().clone();
let has_removed_package = !snapshot