FVJQ6OJYLCXGPDNHCP56JXZ44VQKFIOC7NC3S42D3JPQSZ2F7R4AC
Command::new(
"/home/maniac/.cache/pypoetry/virtualenvs/flickr-upload-AGKUL9KW-py3.9/bin/python",
)
.arg("/home/maniac/code/flickr-upload/upload.py")
.arg(&newname)
.status()?
.exit_ok()?;
Command::new(command)
.args(args)
.arg(&newname)
.status()?
.exit_ok()?;
fn register_processor<'a>(
processors: &mut HashMap<WatchDescriptor, Processor<'a>>,
inotify: &mut Inotify,
path: &'a Path,
command: &'a str,
args: &'a [&'a str],
) -> Result<(), Box<dyn Error>> {
println!(
"Registering {} for {} {}",
path.to_string_lossy(),
command,
args.join(" ")
);
let descriptor = inotify.add_watch(path, WatchMask::CLOSE_WRITE)?;
let processor = Processor {
path,
command,
args,
};
processors.insert(descriptor, processor);
Ok(())
}
inotify.add_watch(root, WatchMask::CLOSE_WRITE)?;
register_processor(
&mut processors,
&mut inotify,
Path::new("/tmp/flickr"),
"/home/maniac/.cache/pypoetry/virtualenvs/flickr-upload-AGKUL9KW-py3.9/bin/python",
&["/home/maniac/code/flickr-upload/upload.py"],
)?;
let filename = event.name.unwrap();
println!("Processing {:?}", root.join(filename));
let _ = process(&root.join(filename));
let processor = &processors[&event.wd];
let filename = processor.path.join(event.name.unwrap());
println!("Processing {:?}", filename);
let _ = process(&filename, processor.command, processor.args);