diff --git a/crates/turborepo-api-client/src/lib.rs b/crates/turborepo-api-client/src/lib.rs index 741bde6438b32..1dff42be73ea0 100644 --- a/crates/turborepo-api-client/src/lib.rs +++ b/crates/turborepo-api-client/src/lib.rs @@ -135,7 +135,7 @@ pub struct PreflightResponse { } #[derive(Deserialize)] -struct ApiError { +struct APIError { code: String, message: String, } @@ -334,7 +334,7 @@ impl APIClient { } async fn handle_403(response: Response) -> Error { - let api_error: ApiError = match response.json().await { + let api_error: APIError = match response.json().await { Ok(api_error) => api_error, Err(e) => return Error::ReqwestError(e), }; diff --git a/crates/turborepo-cache/src/async_cache.rs b/crates/turborepo-cache/src/async_cache.rs index 81a10cee41bdb..adcb7b59b2c0e 100644 --- a/crates/turborepo-cache/src/async_cache.rs +++ b/crates/turborepo-cache/src/async_cache.rs @@ -68,7 +68,9 @@ impl AsyncCache { self.real_cache.exists(key, team_id, team_slug).await } - // Mostly used for testing to ensure that the workers resolve + // Used for testing to ensure that the workers resolve + // before checking the cache. + #[cfg(test)] pub async fn wait(&mut self) { while let Some(worker) = self.workers.next().await { let _ = worker; diff --git a/crates/turborepo-cache/src/fs.rs b/crates/turborepo-cache/src/fs.rs index 6ed0096aacb69..d162e540c71cb 100644 --- a/crates/turborepo-cache/src/fs.rs +++ b/crates/turborepo-cache/src/fs.rs @@ -9,7 +9,7 @@ use crate::{ CacheError, CacheResponse, CacheSource, }; -pub struct FsCache { +pub struct FSCache { cache_directory: AbsoluteSystemPathBuf, } @@ -26,7 +26,7 @@ impl CacheMetadata { } } -impl FsCache { +impl FSCache { fn resolve_cache_dir( repo_root: &AbsoluteSystemPath, override_dir: Option<&Utf8Path>, @@ -45,7 +45,7 @@ impl FsCache { let cache_directory = Self::resolve_cache_dir(repo_root, override_dir); cache_directory.create_dir_all()?; - Ok(FsCache { cache_directory }) + Ok(FSCache { cache_directory }) } pub fn fetch( @@ -174,7 +174,7 @@ mod test { let repo_root_path = AbsoluteSystemPath::from_std_path(repo_root.path())?; test_case.initialize(repo_root_path)?; - let cache = FsCache::new(None, &repo_root_path)?; + let cache = FSCache::new(None, &repo_root_path)?; let expected_miss = cache .exists(&test_case.hash) diff --git a/crates/turborepo-cache/src/multiplexer.rs b/crates/turborepo-cache/src/multiplexer.rs index 3ec8554a3e384..46fc32e40b48c 100644 --- a/crates/turborepo-cache/src/multiplexer.rs +++ b/crates/turborepo-cache/src/multiplexer.rs @@ -5,18 +5,18 @@ use turbopath::{AbsoluteSystemPath, AnchoredSystemPathBuf}; use turborepo_api_client::APIClient; use crate::{ - fs::FsCache, + fs::FSCache, http::{APIAuth, HTTPCache}, CacheError, CacheOpts, CacheResponse, }; pub struct CacheMultiplexer { // We use an `AtomicBool` instead of removing the cache because that would require - // wrapping the cache in a Mutex which would cause a lot of contention. + // wrapping the cache in a `Mutex` which would cause a lot of contention. // This does create a mild race condition where we might use the cache // even though another thread might be removing it, but that's fine. should_use_http_cache: AtomicBool, - fs: Option, + fs: Option, http: Option, } @@ -29,20 +29,16 @@ impl CacheMultiplexer { ) -> Result { let use_fs_cache = !opts.skip_filesystem; let use_http_cache = !opts.skip_remote; + // Since the above two flags are not mutually exclusive it is possible to // configure yourself out of having a cache. We should tell you about it // but we shouldn't fail your build for that reason. - // - // Further, since the httpCache can be removed at runtime, we need to insert a - // noopCache as a backup if you are configured to have *just* an - // httpCache. - // if !use_fs_cache && !use_http_cache { warn!("no caches are enabled"); } let fs_cache = use_fs_cache - .then(|| FsCache::new(opts.override_dir, repo_root)) + .then(|| FSCache::new(opts.override_dir, repo_root)) .transpose()?; let http_cache = use_http_cache