Skip to content

Commit

Permalink
[ofl] Attempt to fix infinite watcher loop on macOS.
Browse files Browse the repository at this point in the history
  • Loading branch information
anp committed Apr 4, 2021
1 parent e433fc7 commit 4d3cd85
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion ofl/src/website.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ use anyhow::{Context, Error};
use gumdrop::Options;
use mdbook::MDBook;
use std::{
fs::File,
io::{BufReader, BufWriter},
path::{Path, PathBuf},
sync::Mutex,
};
Expand Down Expand Up @@ -62,7 +64,17 @@ impl DistOpts {
let parent = destination.parent().unwrap();
std::fs::create_dir_all(&parent)
.with_context(|| format!("creating {}", parent.display()))?;
std::fs::copy(&path, &destination).with_context(|| {

// note: can't use std::fs::copy here because it generates filesystem notifs
// see https://github.com/notify-rs/notify/issues/259
let mut src = BufReader::new(
File::open(&path).with_context(|| format!("opening {}", path.display()))?,
);
let mut dst = BufWriter::new(
File::create(&destination)
.with_context(|| format!("creating {}", destination.display()))?,
);
std::io::copy(&mut src, &mut dst).with_context(|| {
format!("copying {} to {}", path.display(), destination.display())
})?;
}
Expand Down

0 comments on commit 4d3cd85

Please sign in to comment.