From 7401fde7fcc6a8022c007a0eae2506a1372cec01 Mon Sep 17 00:00:00 2001 From: Paul Lietar Date: Tue, 12 Jan 2016 23:29:31 +0000 Subject: [PATCH] Update dependencies --- Cargo.lock | 51 ++++++++++++++++++++++++-------------------- Cargo.toml | 14 ++++++------ build.rs | 2 +- src/audio_file.rs | 21 +++++++++--------- src/util/mod.rs | 2 -- src/util/zerofile.rs | 43 ------------------------------------- 6 files changed, 46 insertions(+), 87 deletions(-) delete mode 100644 src/util/zerofile.rs diff --git a/Cargo.lock b/Cargo.lock index fc679afa..56abdcf3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7,23 +7,23 @@ dependencies = [ "dns-sd 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "eventual 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", - "json_macros 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "json_macros 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", "librespot-protocol 0.1.0", - "num 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "portaudio 0.1.2 (git+https://github.com/mvdnes/portaudio-rs)", + "num 0.1.30 (registry+https://github.com/rust-lang/crates.io-index)", + "portaudio 0.2.0 (git+https://github.com/mvdnes/portaudio-rs)", "protobuf 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", - "protobuf_macros 0.1.1 (git+https://github.com/plietar/rust-protobuf-macros.git)", - "rand 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)", + "protobuf_macros 0.1.2 (git+https://github.com/plietar/rust-protobuf-macros.git)", + "rand 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)", "rpassword 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "rust-crypto 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", "shannon 0.1.1 (git+https://github.com/plietar/rust-shannon.git)", - "tempfile 1.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "tempfile 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)", "tiny_http 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "url 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "vergen 0.0.16 (registry+https://github.com/rust-lang/crates.io-index)", + "vergen 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "vorbis 0.0.14 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -59,6 +59,11 @@ name = "bitflags" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "blastfig" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "byteorder" version = "0.4.2" @@ -69,7 +74,7 @@ name = "chrono" version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "num 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "num 0.1.30 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -169,7 +174,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "json_macros" -version = "0.2.6" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", @@ -237,10 +242,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "num" -version = "0.1.29" +version = "0.1.30" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rand 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -261,8 +266,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "portaudio" -version = "0.1.2" -source = "git+https://github.com/mvdnes/portaudio-rs#f49d9e1652f88083b9ea0fe021cca6ee3f57fa32" +version = "0.2.0" +source = "git+https://github.com/mvdnes/portaudio-rs#6a5d4ffaa9a2564d79391b6994ea69358bfe6b22" dependencies = [ "bitflags 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -272,7 +277,7 @@ dependencies = [ [[package]] name = "portaudio_sys" version = "0.1.1" -source = "git+https://github.com/mvdnes/portaudio-rs#f49d9e1652f88083b9ea0fe021cca6ee3f57fa32" +source = "git+https://github.com/mvdnes/portaudio-rs#6a5d4ffaa9a2564d79391b6994ea69358bfe6b22" dependencies = [ "libc 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -296,12 +301,12 @@ dependencies = [ [[package]] name = "protobuf_macros" -version = "0.1.1" -source = "git+https://github.com/plietar/rust-protobuf-macros.git#ade4282d3570304e967e5ab7a677d97cfd8586e0" +version = "0.1.2" +source = "git+https://github.com/plietar/rust-protobuf-macros.git#aede2228ead6aa4da28cbc300440aaecefe0ad86" [[package]] name = "rand" -version = "0.3.12" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "advapi32-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -327,7 +332,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "gcc 0.3.21 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -365,12 +370,12 @@ dependencies = [ [[package]] name = "tempfile" -version = "1.1.3" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "kernel32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -430,16 +435,16 @@ name = "uuid" version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rand 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "vergen" -version = "0.0.16" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bitflags 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "blastfig 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)", ] diff --git a/Cargo.toml b/Cargo.toml index 20f95277..e2a84585 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,19 +20,19 @@ bit-set = "~0.2.0" byteorder = "~0.4.2" eventual = "~0.1.5" getopts = "~0.2.14" -json_macros = "~0.2.6" +json_macros = "~0.3.0" lazy_static = "~0.1.15" -num = "~0.1.29" -protobuf = "~1.0.10" -rand = "~0.3.12" +num = "~0.1.30" +protobuf = "~1.0.15" +rand = "~0.3.13" rpassword = "~0.1.0" rust-crypto = "~0.2.34" rustc-serialize = "~0.3.16" +tempfile = "~2.0.0" time = "~0.1.34" tiny_http = "~0.5.1" -tempfile = "~1.1.3" url = "~0.5.2" -vorbis = "~0.0.13" +vorbis = "~0.0.14" [dependencies.dns-sd] version = "~0.1.1" @@ -46,7 +46,7 @@ git = "https://github.com/plietar/rust-shannon.git" git = "https://github.com/mvdnes/portaudio-rs" [build-dependencies] -vergen = "~0.0.16" +vergen = "~0.1.0" [features] default = ["dns-sd"] diff --git a/build.rs b/build.rs index 21c3c8e5..df2aaa38 100644 --- a/build.rs +++ b/build.rs @@ -1,6 +1,6 @@ extern crate vergen; fn main() { - vergen::vergen(vergen::SHORT_SHA); + vergen::vergen(vergen::SHORT_SHA).unwrap(); } diff --git a/src/audio_file.rs b/src/audio_file.rs index c9ba3ea2..630344c0 100644 --- a/src/audio_file.rs +++ b/src/audio_file.rs @@ -7,9 +7,9 @@ use std::thread; use std::fs; use std::io::{self, Read, Write, Seek, SeekFrom}; use std::path::PathBuf; -use tempfile::TempFile; +use tempfile::NamedTempFile; -use util::{FileId, IgnoreExt, ZeroFile, mkdir_existing}; +use util::{FileId, IgnoreExt, mkdir_existing}; use session::Session; use stream::StreamEvent; @@ -21,7 +21,7 @@ pub enum AudioFile { } pub struct AudioFileLoading { - read_file: TempFile, + read_file: fs::File, position: u64, seek: mpsc::Sender, @@ -39,10 +39,6 @@ struct AudioFileShared { impl AudioFileLoading { fn new(session: &Session, file_id: FileId) -> AudioFileLoading { - let mut files_iter = TempFile::shared(2).unwrap().into_iter(); - let read_file = files_iter.next().unwrap(); - let mut write_file = files_iter.next().unwrap(); - let size = session.stream(file_id, 0, 1) .into_iter() .filter_map(|event| { @@ -58,6 +54,7 @@ impl AudioFileLoading { let chunk_count = (size + CHUNK_SIZE - 1) / CHUNK_SIZE; + let shared = Arc::new(AudioFileShared { file_id: file_id, size: size, @@ -66,7 +63,9 @@ impl AudioFileLoading { bitmap: Mutex::new(BitSet::with_capacity(chunk_count)), }); - io::copy(&mut ZeroFile::new(size as u64), &mut write_file).unwrap(); + let write_file = NamedTempFile::new().unwrap(); + write_file.set_len(size as u64).unwrap(); + let read_file = write_file.reopen().unwrap(); let (seek_tx, seek_rx) = mpsc::channel(); @@ -88,7 +87,7 @@ impl AudioFileLoading { fn fetch(session: &Session, shared: Arc, - mut write_file: TempFile, + mut write_file: NamedTempFile, seek_rx: mpsc::Receiver) { let mut index = 0; @@ -119,7 +118,7 @@ impl AudioFileLoading { fn fetch_chunk(session: &Session, shared: &Arc, - write_file: &mut TempFile, + write_file: &mut NamedTempFile, index: usize) { let rx = session.stream(shared.file_id, @@ -151,7 +150,7 @@ impl AudioFileLoading { shared.cond.notify_all(); } - fn store(session: &Session, shared: &AudioFileShared, write_file: &mut TempFile) { + fn store(session: &Session, shared: &AudioFileShared, write_file: &mut NamedTempFile) { write_file.seek(SeekFrom::Start(0)).unwrap(); mkdir_existing(&AudioFileManager::cache_dir(session, shared.file_id)).unwrap(); diff --git a/src/util/mod.rs b/src/util/mod.rs index ee584f62..8df033d1 100644 --- a/src/util/mod.rs +++ b/src/util/mod.rs @@ -10,13 +10,11 @@ mod int128; mod spotify_id; mod arcvec; mod subfile; -mod zerofile; pub use util::int128::u128; pub use util::spotify_id::{SpotifyId, FileId}; pub use util::arcvec::ArcVec; pub use util::subfile::Subfile; -pub use util::zerofile::ZeroFile; #[macro_export] macro_rules! eprintln( diff --git a/src/util/zerofile.rs b/src/util/zerofile.rs deleted file mode 100644 index 912eef7e..00000000 --- a/src/util/zerofile.rs +++ /dev/null @@ -1,43 +0,0 @@ -use std::io; -use std::cmp::{min, max}; - -pub struct ZeroFile { - position: u64, - size: u64, -} - -impl ZeroFile { - pub fn new(size: u64) -> ZeroFile { - ZeroFile { - position: 0, - size: size, - } - } -} - -impl io::Seek for ZeroFile { - fn seek(&mut self, pos: io::SeekFrom) -> io::Result { - let newpos = match pos { - io::SeekFrom::Start(offset) => offset as i64, - io::SeekFrom::End(offset) => self.size as i64 + offset, - io::SeekFrom::Current(offset) => self.position as i64 + offset, - }; - - self.position = max(min(newpos, self.size as i64), 0) as u64; - - Ok(self.position) - } -} - -impl io::Read for ZeroFile { - // TODO optimize with memset or similar - fn read(&mut self, output: &mut [u8]) -> io::Result { - let len = min(output.len(), (self.size - self.position) as usize); - for b in output { - *b = 0; - } - - self.position += len as u64; - Ok(len) - } -}