Changed notification from create to modify
mbsync doesnt seem to create the files, it moves them into place. Added an existence check and switched the watched event to modify
This commit is contained in:
parent
dc7239f9c2
commit
2943d45ea9
|
@ -11,7 +11,7 @@
|
||||||
};
|
};
|
||||||
packages.${system}.default = pkgs.rustPlatform.buildRustPackage {
|
packages.${system}.default = pkgs.rustPlatform.buildRustPackage {
|
||||||
pname = "mbdirnotify";
|
pname = "mbdirnotify";
|
||||||
version = "0.4.3";
|
version = "0.0.1";
|
||||||
cargoLock.lockFile = ./Cargo.lock;
|
cargoLock.lockFile = ./Cargo.lock;
|
||||||
src = pkgs.lib.cleanSource ./.;
|
src = pkgs.lib.cleanSource ./.;
|
||||||
};
|
};
|
||||||
|
|
|
@ -48,8 +48,11 @@ fn watch(event: notify::Result<Event>) {
|
||||||
|
|
||||||
fn parse_event(event: notify::Result<Event>) -> Result<()> {
|
fn parse_event(event: notify::Result<Event>) -> Result<()> {
|
||||||
let event = event?;
|
let event = event?;
|
||||||
if let EventKind::Create(_kind) = event.kind {
|
if let EventKind::Modify(_kind) = event.kind {
|
||||||
if let Some(p) = event.paths.first() {
|
if let Some(p) = event.paths.first() {
|
||||||
|
if !p.exists() {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
let mut f = File::open(&p)?;
|
let mut f = File::open(&p)?;
|
||||||
let mut buf = vec![];
|
let mut buf = vec![];
|
||||||
f.read_to_end(&mut buf)?;
|
f.read_to_end(&mut buf)?;
|
||||||
|
|
Loading…
Reference in New Issue