mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-25 05:26:50 +00:00
@@ -8,10 +8,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
use futures::future::join_all;
|
use futures::future::join_all;
|
||||||
use std::{future::Future, pin::Pin, sync::Arc};
|
use std::{future::Future, pin::Pin, sync::Arc};
|
||||||
use tokio::{
|
use tokio::{spawn, sync::broadcast::Receiver as B_Receiver};
|
||||||
spawn,
|
|
||||||
sync::{broadcast::Receiver as B_Receiver, RwLock},
|
|
||||||
};
|
|
||||||
use tracing::{error, info};
|
use tracing::{error, info};
|
||||||
|
|
||||||
type AgreedFn = Box<dyn Fn(MetaCacheEntry) -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + 'static>;
|
type AgreedFn = Box<dyn Fn(MetaCacheEntry) -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + 'static>;
|
||||||
@@ -65,7 +62,7 @@ pub async fn list_path_raw(mut rx: B_Receiver<bool>, opts: ListPathRawOptions) -
|
|||||||
|
|
||||||
let mut jobs: Vec<tokio::task::JoinHandle<std::result::Result<(), Error>>> = Vec::new();
|
let mut jobs: Vec<tokio::task::JoinHandle<std::result::Result<(), Error>>> = Vec::new();
|
||||||
let mut readers = Vec::with_capacity(opts.disks.len());
|
let mut readers = Vec::with_capacity(opts.disks.len());
|
||||||
let fds = Arc::new(RwLock::new(opts.fallback_disks.clone()));
|
let fds = Arc::new(opts.fallback_disks.clone());
|
||||||
|
|
||||||
for disk in opts.disks.iter() {
|
for disk in opts.disks.iter() {
|
||||||
let opdisk = disk.clone();
|
let opdisk = disk.clone();
|
||||||
@@ -101,20 +98,16 @@ pub async fn list_path_raw(mut rx: B_Receiver<bool>, opts: ListPathRawOptions) -
|
|||||||
}
|
}
|
||||||
|
|
||||||
while need_fallback {
|
while need_fallback {
|
||||||
let f_disk = loop {
|
let disk = match fds_clone.iter().find(|d| d.is_some()) {
|
||||||
let mut fds_w = fds_clone.write().await;
|
Some(d) => {
|
||||||
if fds_w.is_empty() {
|
if let Some(disk) = d.clone() {
|
||||||
break None;
|
disk
|
||||||
}
|
} else {
|
||||||
|
break;
|
||||||
if let Some(fd) = fds_w.remove(0) {
|
|
||||||
if fd.is_online().await {
|
|
||||||
break Some(fd);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
None => break,
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(disk) = f_disk {
|
|
||||||
match disk
|
match disk
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.walk_dir(
|
.walk_dir(
|
||||||
@@ -140,9 +133,6 @@ pub async fn list_path_raw(mut rx: B_Receiver<bool>, opts: ListPathRawOptions) -
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -295,7 +285,7 @@ pub async fn list_path_raw(mut rx: B_Receiver<bool>, opts: ListPathRawOptions) -
|
|||||||
if let Some(partial_fn) = opts.partial.as_ref() {
|
if let Some(partial_fn) = opts.partial.as_ref() {
|
||||||
partial_fn(MetaCacheEntries(top_entries), &errs).await;
|
partial_fn(MetaCacheEntries(top_entries), &errs).await;
|
||||||
}
|
}
|
||||||
break;
|
// break;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user