Log when there's an error while scanning a directory
Co-Authored-By: Max Brunsfeld <max@zed.dev> Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
co-authored by
Max Brunsfeld
Nathan Sobo
parent
99f51c0d85
commit
b2e7a2c42a
+12
-13
@@ -784,12 +784,12 @@ impl BackgroundScanner {
|
|||||||
|
|
||||||
let (tx, rx) = crossbeam_channel::unbounded();
|
let (tx, rx) = crossbeam_channel::unbounded();
|
||||||
|
|
||||||
tx.send(Ok(ScanJob {
|
tx.send(ScanJob {
|
||||||
inode,
|
inode,
|
||||||
path: path.clone(),
|
path: path.clone(),
|
||||||
relative_path,
|
relative_path,
|
||||||
scan_queue: tx.clone(),
|
scan_queue: tx.clone(),
|
||||||
}))
|
})
|
||||||
.unwrap();
|
.unwrap();
|
||||||
drop(tx);
|
drop(tx);
|
||||||
|
|
||||||
@@ -800,7 +800,8 @@ impl BackgroundScanner {
|
|||||||
pool.execute(|| {
|
pool.execute(|| {
|
||||||
let result = result;
|
let result = result;
|
||||||
while let Ok(job) = rx.recv() {
|
while let Ok(job) = rx.recv() {
|
||||||
if let Err(err) = job.and_then(|job| self.scan_dir(job)) {
|
if let Err(err) = self.scan_dir(&job) {
|
||||||
|
log::error!("error scanning {:?}: {}", job.path, err);
|
||||||
*result = Err(err);
|
*result = Err(err);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -829,9 +830,7 @@ impl BackgroundScanner {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn scan_dir(&self, job: ScanJob) -> io::Result<()> {
|
fn scan_dir(&self, job: &ScanJob) -> io::Result<()> {
|
||||||
let scan_queue = job.scan_queue;
|
|
||||||
|
|
||||||
let mut new_entries = Vec::new();
|
let mut new_entries = Vec::new();
|
||||||
let mut new_jobs = Vec::new();
|
let mut new_jobs = Vec::new();
|
||||||
|
|
||||||
@@ -860,7 +859,7 @@ impl BackgroundScanner {
|
|||||||
inode: child_inode,
|
inode: child_inode,
|
||||||
path: Arc::from(child_path),
|
path: Arc::from(child_path),
|
||||||
relative_path: child_relative_path,
|
relative_path: child_relative_path,
|
||||||
scan_queue: scan_queue.clone(),
|
scan_queue: job.scan_queue.clone(),
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
new_entries.push((
|
new_entries.push((
|
||||||
@@ -878,7 +877,7 @@ impl BackgroundScanner {
|
|||||||
|
|
||||||
self.snapshot.lock().populate_dir(job.inode, new_entries);
|
self.snapshot.lock().populate_dir(job.inode, new_entries);
|
||||||
for new_job in new_jobs {
|
for new_job in new_jobs {
|
||||||
scan_queue.send(Ok(new_job)).unwrap();
|
job.scan_queue.send(new_job).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -920,7 +919,7 @@ impl BackgroundScanner {
|
|||||||
snapshot.insert_entry(path.file_name(), fs_entry);
|
snapshot.insert_entry(path.file_name(), fs_entry);
|
||||||
if is_dir {
|
if is_dir {
|
||||||
scan_queue_tx
|
scan_queue_tx
|
||||||
.send(Ok(ScanJob {
|
.send(ScanJob {
|
||||||
inode,
|
inode,
|
||||||
path: Arc::from(path),
|
path: Arc::from(path),
|
||||||
relative_path: snapshot
|
relative_path: snapshot
|
||||||
@@ -928,7 +927,7 @@ impl BackgroundScanner {
|
|||||||
.map_or(PathBuf::new(), PathBuf::from)
|
.map_or(PathBuf::new(), PathBuf::from)
|
||||||
.join(relative_path),
|
.join(relative_path),
|
||||||
scan_queue: scan_queue_tx.clone(),
|
scan_queue: scan_queue_tx.clone(),
|
||||||
}))
|
})
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -948,8 +947,8 @@ impl BackgroundScanner {
|
|||||||
for _ in 0..self.thread_pool.thread_count() {
|
for _ in 0..self.thread_pool.thread_count() {
|
||||||
pool.execute(|| {
|
pool.execute(|| {
|
||||||
while let Ok(job) = scan_queue_rx.recv() {
|
while let Ok(job) = scan_queue_rx.recv() {
|
||||||
if let Err(err) = job.and_then(|job| self.scan_dir(job)) {
|
if let Err(err) = self.scan_dir(&job) {
|
||||||
log::error!("Error scanning {:?}", err);
|
log::error!("error scanning {:?}: {}", job.path, err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -1139,7 +1138,7 @@ struct ScanJob {
|
|||||||
inode: u64,
|
inode: u64,
|
||||||
path: Arc<Path>,
|
path: Arc<Path>,
|
||||||
relative_path: PathBuf,
|
relative_path: PathBuf,
|
||||||
scan_queue: crossbeam_channel::Sender<io::Result<ScanJob>>,
|
scan_queue: crossbeam_channel::Sender<ScanJob>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait WorktreeHandle {
|
pub trait WorktreeHandle {
|
||||||
|
|||||||
Reference in New Issue
Block a user