Skip to content
Prev Previous commit
Next Next commit
Add a ton of debugging stuff
  • Loading branch information
thecrypticace committed Oct 30, 2024
commit ed783a8f72a8c20f72d6b9dd69790a78055d23d5
14 changes: 14 additions & 0 deletions crates/oxide/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,12 +223,18 @@ impl Scanner {

// Check all directories to see if they were modified
for path in &self.dirs {
dbg!(&path);

let current_time = fs::metadata(path)
.and_then(|m| m.modified())
.unwrap_or(SystemTime::now());

dbg!(&current_time);

let previous_time = self.mtimes.insert(path.clone(), current_time);

dbg!(&previous_time);

let should_scan = match previous_time {
// Time has changed, so we need to re-scan the file
Some(prev) if prev != current_time => true,
Expand All @@ -240,6 +246,8 @@ impl Scanner {
None => true,
};

dbg!(&should_scan);

if should_scan {
modified_dirs.push(path.clone());
}
Expand All @@ -248,6 +256,8 @@ impl Scanner {
// Scan all modified directories for their immediate files
let mut known = FxHashSet::from_iter(self.files.iter().chain(self.dirs.iter()).cloned());

dbg!(&self.dirs, &modified_dirs, &known);

while !modified_dirs.is_empty() {
let new_entries = modified_dirs
.iter()
Expand All @@ -256,6 +266,8 @@ impl Scanner {
.filter(|path| !known.contains(path))
.collect::<Vec<_>>();

dbg!(&new_entries);

modified_dirs.clear();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit cursed, I love it.


for path in new_entries {
Expand All @@ -268,6 +280,8 @@ impl Scanner {

// Recursively scan the new directory for files
modified_dirs.push(path);
} else {
eprintln!("Ignoring non-file/directory: {:?}", path);
}
}
}
Expand Down