From 16354b0f72f1162d0c083acecbc97253bdc85cbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Vasconcellos?= Date: Mon, 18 Mar 2024 23:23:42 -0300 Subject: [PATCH] Fix a couple of tests after #2218 (#2219) - Fix some rust warnings --- core/crates/sync/src/ingest.rs | 4 ++-- core/crates/sync/tests/lib.rs | 6 ------ core/src/cloud/sync/send.rs | 2 +- core/src/location/mod.rs | 3 ++- core/src/object/media/old_media_processor/job.rs | 7 ++++++- core/src/object/media/old_media_processor/shallow.rs | 7 ++++++- core/src/p2p/sync/mod.rs | 1 - crates/crypto/examples/secure_erase.rs | 10 +++++++--- 8 files changed, 24 insertions(+), 16 deletions(-) diff --git a/core/crates/sync/src/ingest.rs b/core/crates/sync/src/ingest.rs index 9ddccbdb4..0be7b5070 100644 --- a/core/crates/sync/src/ingest.rs +++ b/core/crates/sync/src/ingest.rs @@ -89,7 +89,7 @@ impl Actor { if let Some(Event::Messages(event)) = res { break State::Ingesting(event) } } res = &mut rx => { - if let Err(_) = res { + if res.is_err() { debug!("messages request ignored"); break State::WaitingForNotification } @@ -98,7 +98,7 @@ impl Actor { } } State::Ingesting(event) => { - if event.messages.len() > 0 { + if !event.messages.is_empty() { debug!( "ingesting {} operations: {} to {}", event.messages.len(), diff --git a/core/crates/sync/tests/lib.rs b/core/crates/sync/tests/lib.rs index a84a9814b..e31f8717a 100644 --- a/core/crates/sync/tests/lib.rs +++ b/core/crates/sync/tests/lib.rs @@ -44,8 +44,6 @@ impl Instance { uuid_to_bytes(id), vec![], vec![], - format!("Instace {id}"), - 0, Utc::now().into(), Utc::now().into(), vec![], @@ -84,8 +82,6 @@ impl Instance { uuid_to_bytes(right.id), vec![], vec![], - String::new(), - 0, Utc::now().into(), Utc::now().into(), vec![], @@ -101,8 +97,6 @@ impl Instance { uuid_to_bytes(left.id), vec![], vec![], - String::new(), - 0, Utc::now().into(), Utc::now().into(), vec![], diff --git a/core/src/cloud/sync/send.rs b/core/src/cloud/sync/send.rs index 4df3cde06..92f9ff24c 100644 --- a/core/src/cloud/sync/send.rs +++ b/core/src/cloud/sync/send.rs @@ -1,7 +1,7 @@ use super::CompressedCRDTOperations; use sd_cloud_api::RequestConfigProvider; -use sd_core_sync::{GetOpsArgs, SyncMessage, NTP64}; +use sd_core_sync::{SyncMessage, NTP64}; use tracing::debug; use uuid::Uuid; diff --git a/core/src/location/mod.rs b/core/src/location/mod.rs index 555188c99..950650e43 100644 --- a/core/src/location/mod.rs +++ b/core/src/location/mod.rs @@ -37,7 +37,7 @@ use serde::Deserialize; use serde_json::json; use specta::Type; use tokio::{fs, io, time::Instant}; -use tracing::{debug, info, warn}; +use tracing::{debug, error, info, warn}; use uuid::Uuid; mod error; @@ -177,6 +177,7 @@ impl LocationCreateArgs { .await { // DISABLED TO FAIL SILENTLY - HOTFIX FOR LACK OF WRITE PERMISSION PREVENTING LOCATION CREATION + error!("Failed to write .spacedrive file: {:?}", err); // delete_location(node, library, location.data.id).await?; // Err(err)?; } diff --git a/core/src/object/media/old_media_processor/job.rs b/core/src/object/media/old_media_processor/job.rs index d50f1be02..746c7d09f 100644 --- a/core/src/object/media/old_media_processor/job.rs +++ b/core/src/object/media/old_media_processor/job.rs @@ -105,7 +105,12 @@ impl StatefulJob for OldMediaProcessorJobInit { ctx: &WorkerContext, data: &mut Option, ) -> Result, JobError> { - let Library { db, sync, .. } = ctx.library.as_ref(); + let Library { + db, + #[cfg(feature = "ai")] + sync, + .. + } = ctx.library.as_ref(); let location_id = self.location.id; let location_path = diff --git a/core/src/object/media/old_media_processor/shallow.rs b/core/src/object/media/old_media_processor/shallow.rs index 3afcecf80..c34ace220 100644 --- a/core/src/object/media/old_media_processor/shallow.rs +++ b/core/src/object/media/old_media_processor/shallow.rs @@ -40,7 +40,12 @@ const BATCH_SIZE: usize = 10; pub async fn old_shallow( location: &location::Data, sub_path: &PathBuf, - library @ Library { db, sync, .. }: &Library, + library @ Library { + db, + #[cfg(feature = "ai")] + sync, + .. + }: &Library, #[cfg(feature = "ai")] regenerate_labels: bool, node: &Node, ) -> Result<(), JobError> { diff --git a/core/src/p2p/sync/mod.rs b/core/src/p2p/sync/mod.rs index dcdf70a28..d76011df0 100644 --- a/core/src/p2p/sync/mod.rs +++ b/core/src/p2p/sync/mod.rs @@ -68,7 +68,6 @@ mod originator { let original = Operations(vec![CRDTOperation { instance: Uuid::new_v4(), timestamp: sync::NTP64(0), - id: Uuid::new_v4(), record_id: rmpv::Value::Nil, model: "name".to_string(), data: sd_sync::CRDTOperationData::Create, diff --git a/crates/crypto/examples/secure_erase.rs b/crates/crypto/examples/secure_erase.rs index 6013ab9f1..8d0bfb55a 100644 --- a/crates/crypto/examples/secure_erase.rs +++ b/crates/crypto/examples/secure_erase.rs @@ -1,4 +1,4 @@ -use sd_crypto::{rng::CryptoRng, sys::fs}; +use sd_crypto::rng::CryptoRng; use std::io::{Seek, Write}; use tempfile::tempfile; @@ -9,8 +9,12 @@ fn main() { file.rewind().unwrap(); - // Erase the file (the size would normally be obtained via `fs::Metadata::len()` or similar) - fs::erase(&mut file, 1048576 * 16, 2).unwrap(); + #[cfg(feature = "sys")] + { + use sd_crypto::sys::fs; + // Erase the file (the size would normally be obtained via `fs::Metadata::len()` or similar) + fs::erase(&mut file, 1048576 * 16, 2).unwrap(); + } // Truncate the file to a length of zero file.set_len(0).unwrap();