Commit 0c7b8f8d authored by Stavros Korokithakis's avatar Stavros Korokithakis

Initial commit, gets notified and publishes

# Created by
### Rust ###
# Generated by Cargo
# will have compiled files and executables
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here
# These are backup files generated by rustfmt
# End of
name = "hearth"
version = "0.1.0"
authors = ["Stavros Korokithakis <>"]
notify = "4.0.0"
xdg = "^2.1"
lazy_static = "0.2"
This diff is collapsed.
extern crate lazy_static;
extern crate notify;
extern crate xdg;
use notify::{Watcher, RecursiveMode, watcher};
use std::time::Duration;
use std::sync::mpsc::channel;
use std::thread;
use std::process::Command;
static HEARTH_DIR: &'static str = "/home/stavros/Hearth/";
lazy_static! {
static ref IPFS_PATH: std::path::PathBuf = {
let xdg_dirs = xdg::BaseDirectories::with_prefix("hearth")
.expect("Could not retrieve config directory path.");
.expect("Could not create IPFS config directory.")
fn add_files_to_ipfs() -> String {
let output = Command::new("./ipfs")
.args(&["add", "-r", "-Q", &HEARTH_DIR])
.expect("Could not add directory.");
fn notify_ipfs(event: notify::DebouncedEvent) {
println!("{:?}", event);
println!("{}", add_files_to_ipfs());
fn spawn_ipfs_thread() {
thread::spawn(move || {
println!("Starting IPFS daemon...");
.expect("Could not initialize IPFS.");
.args(&["daemon", "--writable", "--enable-gc"])
.expect("Could not launch IPFS daemon.");
fn main() {
println!("Starting hearth...");
// Create a channel to receive the events.
let (tx, rx) = channel();
// Create a watcher object, delivering debounced events.
// The notification back-end is selected based on the platform.
let mut watcher = watcher(tx, Duration::from_secs(5)).unwrap();
// Add a path to be watched. All files and directories at that path and
// below will be monitored for changes.
.watch("/home/stavros/Hearth/", RecursiveMode::Recursive)
loop {
match rx.recv() {
Ok(event) => notify_ipfs(event),
Err(e) => println!("watch error: {:?}", e),
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment