Fix a couple of tests after #2218 (#2219)

- Fix some rust warnings
This commit is contained in:
Vítor Vasconcellos
2024-03-18 23:23:42 -03:00
committed by GitHub
parent 98a4ba8d94
commit d6f899a93d
8 changed files with 24 additions and 16 deletions

View File

@@ -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(),

View File

@@ -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![],

View File

@@ -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;

View File

@@ -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)?;
}

View File

@@ -105,7 +105,12 @@ impl StatefulJob for OldMediaProcessorJobInit {
ctx: &WorkerContext,
data: &mut Option<Self::Data>,
) -> Result<JobInitOutput<Self::RunMetadata, Self::Step>, 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 =

View File

@@ -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> {

View File

@@ -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,

View File

@@ -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();