Skip to content

Commit

Permalink
create a table to see diesel working
Browse files Browse the repository at this point in the history
  • Loading branch information
pansen committed Aug 21, 2016
1 parent e311e37 commit 818f375
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 4 deletions.
Empty file added migrations/.gitkeep
Empty file.
1 change: 1 addition & 0 deletions migrations/20160820123759_create_track/down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DROP TABLE track;
9 changes: 9 additions & 0 deletions migrations/20160820123759_create_track/up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CREATE TABLE track (
id INTEGER PRIMARY KEY AUTOINCREMENT,
path TEXT NOT NULL,
title TEXT NOT NULL,
album TEXT DEFAULT NULL,
hash TEXT NOT NULL
);

CREATE UNIQUE INDEX IF NOT EXISTS track__hash on track(hash);
2 changes: 1 addition & 1 deletion src/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub fn setup_logging(config: &AppConfig) {
};

if let Err(e) = fern::init_global_logger(logger_config, log_level) {
panic!("Failed to initialize global logger: {}", e);
panic!("Failed to initialize global logger: {:?}", e);
}
}

1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ fn main() {
let scanner = scan::Scanner::new(&config);
scanner.scan_all();


// after the scanner is done, we just join the watcher thread to avoid the mainthread to exit
// creating a channel could also be done, but seems like overhead here
// http://stackoverflow.com/a/26200583/2741111
Expand Down
8 changes: 5 additions & 3 deletions src/scan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ use std::fs::File;
struct FoundTrack {
/// path of that file
pub path: String,
/// id3 title
pub title: String,
/// id3 album
pub album: String,
/// hash of the parsed file
pub hash: String
Expand Down Expand Up @@ -59,11 +61,11 @@ impl Scanner {
}
}
drop(tx);

for value in rx.iter() {
warn!("[recursive] receiving {} - {} from thread",
Red.paint(value.album),
warn!("{} - {} [{}]",
Green.paint(value.album),
Green.paint(value.title),
value.hash,
);
}
}
Expand Down

0 comments on commit 818f375

Please sign in to comment.