Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

scanner: handle dot-entries #17

Merged
merged 1 commit into from
Dec 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ Any skip-spec which matches always wins over a previous ignore-spec match. So wi

The supported glob patterns can be found in the [globset](https://docs.rs/globset) project.

> Any dot-directories (e.g. ".git") encountered while scanning will not be recursed into any further and thus no ignore matching will be performed on their contents. Such directories should either be ignored or synced entirely.
>
> It is recommended to use the `-n` (dry-run) option when testing new ignore or skip specifications!

### One-time scanning
Expand Down
23 changes: 10 additions & 13 deletions src/scanner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::process;
use std::sync::mpsc::channel;
use std::time::Duration;

use log::{debug, error, info, trace, warn};
use log::{debug, error, info, warn};
use notify::{DebouncedEvent, RecommendedWatcher, RecursiveMode, Watcher};
use walkdir::WalkDir;

Expand Down Expand Up @@ -88,17 +88,6 @@ impl Scanner {
}

fn handle_entry(&self, path: &Path, dry_run: bool, scanner_stats: &mut ScannerStats) -> bool {
if let Some(file_name) = path.file_name() {
if file_name
.to_str()
.map(|s| s.starts_with('.'))
.unwrap_or(false)
{
trace!("SKIPDOT {:?}", path);
return false;
}
}

let matches = self.matcher.matches(path.to_str().unwrap().to_string());
if matches {
if self.dropbox.is_ignored(path) {
Expand All @@ -119,6 +108,14 @@ impl Scanner {
return false;
}

true
// don't recurse dot-entries (only effective in "scan" mode)
let recurse = path
.file_name()
.unwrap_or_default()
.to_str()
.map(|s| !s.starts_with('.'))
.unwrap_or(true);

recurse
}
}