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