From 8c819cd8e1215e5c8d283d7186ce8241c4b6d708 Mon Sep 17 00:00:00 2001 From: Jonathan Cammisuli Date: Wed, 29 Nov 2023 14:47:22 -0500 Subject: [PATCH] fix(core): rename struct --- packages/nx/src/native/workspace/context.rs | 6 +++--- .../nx/src/native/workspace/files_archive.rs | 20 +++++++++---------- .../nx/src/native/workspace/files_hashing.rs | 12 +++++------ 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/packages/nx/src/native/workspace/context.rs b/packages/nx/src/native/workspace/context.rs index 5efbeee4d1d52..02ceaa2f0bf68 100644 --- a/packages/nx/src/native/workspace/context.rs +++ b/packages/nx/src/native/workspace/context.rs @@ -53,13 +53,13 @@ impl FilesWorker { let (lock, cvar) = &*files_lock_clone; let mut workspace_files = lock.lock(); let now = std::time::Instant::now(); - let new_archived_files = if let Some(archived_files) = archived_files { + let file_hashes = if let Some(archived_files) = archived_files { selective_files_hash(&workspace_root, archived_files) } else { full_files_hash(&workspace_root) }; - let mut files = new_archived_files + let mut files = file_hashes .iter() .map(|(path, file_hashed)| (PathBuf::from(path), file_hashed.0.to_owned())) .collect::>(); @@ -72,7 +72,7 @@ impl FilesWorker { cvar.notify_all(); - write_files_archive(&cache_dir, new_archived_files); + write_files_archive(&cache_dir, file_hashes); }); FilesWorker(Some(files_lock)) diff --git a/packages/nx/src/native/workspace/files_archive.rs b/packages/nx/src/native/workspace/files_archive.rs index e04b50d941ee8..eaea136e97d60 100644 --- a/packages/nx/src/native/workspace/files_archive.rs +++ b/packages/nx/src/native/workspace/files_archive.rs @@ -14,9 +14,9 @@ pub struct NxFileHashed(pub String, pub i64); #[derive(Archive, Deserialize, Serialize, Debug, PartialEq)] #[archive(check_bytes)] -pub struct NxFilesArchive(HashMap); +pub struct NxFileHashes(HashMap); -impl Deref for NxFilesArchive { +impl Deref for NxFileHashes { type Target = HashMap; fn deref(&self) -> &Self::Target { @@ -24,21 +24,21 @@ impl Deref for NxFilesArchive { } } -impl DerefMut for NxFilesArchive { +impl DerefMut for NxFileHashes { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.0 } } -impl FromIterator<(String, NxFileHashed)> for NxFilesArchive { - fn from_iter>(iter: T) -> NxFilesArchive { +impl FromIterator<(String, NxFileHashed)> for NxFileHashes { + fn from_iter>(iter: T) -> NxFileHashes { let mut map = HashMap::with_hasher(Default::default()); map.extend(iter); - NxFilesArchive(map) + NxFileHashes(map) } } -pub fn read_files_archive>(cache_dir: P) -> Option { +pub fn read_files_archive>(cache_dir: P) -> Option { let now = std::time::Instant::now(); let archive_path = cache_dir.as_ref().join(NX_FILES_ARCHIVE); if !archive_path.exists() { @@ -49,9 +49,9 @@ pub fn read_files_archive>(cache_dir: P) -> Option(&bytes) }; - let archived = rkyv::check_archived_root::(&bytes) + let archived = rkyv::check_archived_root::(&bytes) .map_err(|_| anyhow!("invalid archive file"))?; - >::deserialize( + >::deserialize( archived, &mut rkyv::Infallible, ) @@ -70,7 +70,7 @@ pub fn read_files_archive>(cache_dir: P) -> Option>(cache_dir: P, files: NxFilesArchive) { +pub fn write_files_archive>(cache_dir: P, files: NxFileHashes) { let now = std::time::Instant::now(); let archive_path = cache_dir.as_ref().join(NX_FILES_ARCHIVE); let result = rkyv::to_bytes::<_, 2048>(&files) diff --git a/packages/nx/src/native/workspace/files_hashing.rs b/packages/nx/src/native/workspace/files_hashing.rs index da8cb20ba4ab5..adb910e951931 100644 --- a/packages/nx/src/native/workspace/files_hashing.rs +++ b/packages/nx/src/native/workspace/files_hashing.rs @@ -7,17 +7,17 @@ use tracing::trace; use crate::native::hasher::hash_file_path; use crate::native::walker::{nx_walker, NxFile}; -use crate::native::workspace::files_archive::{NxFileHashed, NxFilesArchive}; +use crate::native::workspace::files_archive::{NxFileHashed, NxFileHashes}; -pub fn full_files_hash(workspace_root: &Path) -> NxFilesArchive { +pub fn full_files_hash(workspace_root: &Path) -> NxFileHashes { let files = nx_walker(workspace_root).collect::>(); hash_files(files).into_iter().collect() } pub fn selective_files_hash( workspace_root: &Path, - mut archived_files: NxFilesArchive, -) -> NxFilesArchive { + mut archived_files: NxFileHashes, +) -> NxFileHashes { let files = nx_walker(workspace_root).collect::>(); let mut archived = vec![]; let mut not_archived = vec![]; @@ -84,7 +84,7 @@ mod tests { use assert_fs::TempDir; use crate::native::utils::get_mod_time; - use crate::native::workspace::files_archive::{NxFileHashed, NxFilesArchive}; + use crate::native::workspace::files_archive::{NxFileHashed, NxFileHashes}; fn setup_fs() -> TempDir { let temp = TempDir::new().unwrap(); @@ -140,7 +140,7 @@ mod tests { ), ] .into_iter() - .collect::(); + .collect::(); let hashed_files = super::selective_files_hash(temp.path(), archived_files); let mut hashed_files = hashed_files