mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-12-23 17:43:47 +03:00
enable rename-tracking by FileId by configuring the cache.
This commit is contained in:
parent
a63b88669c
commit
3723cd279c
@ -83,7 +83,6 @@ impl FileIdMap {
|
||||
/// If `recursive_mode` is `Recursive`, all children will be added to the cache as well
|
||||
/// and all paths will be kept up-to-date in case of changes like new files being added,
|
||||
/// files being removed or renamed.
|
||||
#[allow(dead_code)]
|
||||
pub fn add_root(&mut self, path: impl Into<PathBuf>, recursive_mode: RecursiveMode) {
|
||||
let path = path.into();
|
||||
|
||||
|
@ -59,7 +59,7 @@ use notify::{
|
||||
event::{ModifyKind, RemoveKind, RenameMode},
|
||||
Error, ErrorKind, Event, EventKind, RecommendedWatcher, Watcher,
|
||||
};
|
||||
use parking_lot::Mutex;
|
||||
use parking_lot::{MappedMutexGuard, Mutex, MutexGuard};
|
||||
|
||||
#[cfg(test)]
|
||||
use mock_instant::Instant;
|
||||
@ -487,7 +487,6 @@ impl<T: FileIdCache> DebounceDataInner<T> {
|
||||
pub struct Debouncer<T: Watcher, C: FileIdCache> {
|
||||
watcher: T,
|
||||
debouncer_thread: Option<std::thread::JoinHandle<()>>,
|
||||
#[allow(dead_code)]
|
||||
data: DebounceData<C>,
|
||||
stop: Arc<AtomicBool>,
|
||||
flush: Arc<AtomicBool>,
|
||||
@ -519,6 +518,11 @@ impl<T: Watcher, C: FileIdCache> Debouncer<T, C> {
|
||||
self.flush.store(true, Ordering::Relaxed);
|
||||
}
|
||||
|
||||
/// Access to the internally used notify Watcher backend
|
||||
pub fn cache(&mut self) -> MappedMutexGuard<'_, C> {
|
||||
MutexGuard::map(self.data.lock(), |data| &mut data.cache)
|
||||
}
|
||||
|
||||
/// Access to the internally used notify Watcher backend
|
||||
pub fn watcher(&mut self) -> &mut T {
|
||||
&mut self.watcher
|
||||
|
@ -92,11 +92,21 @@ pub fn spawn(
|
||||
debouncer
|
||||
.watcher()
|
||||
.watch(worktree_path, notify::RecursiveMode::Recursive)
|
||||
.map(|_| {
|
||||
debouncer
|
||||
.cache()
|
||||
.add_root(worktree_path, notify::RecursiveMode::Recursive)
|
||||
})
|
||||
.and_then(|()| {
|
||||
if let Some(git_dir) = extra_git_dir_to_watch {
|
||||
debouncer
|
||||
.watcher()
|
||||
.watch(git_dir, notify::RecursiveMode::Recursive)
|
||||
.map(|_| {
|
||||
debouncer
|
||||
.cache()
|
||||
.add_root(git_dir, notify::RecursiveMode::Recursive)
|
||||
})
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user