Преглед изворни кода

Ignore files which don’t have an id.

Fixes #42
Paul Lietar пре 9 година
родитељ
комит
ac0d597e75
4 измењених фајлова са 6 додато и 4 уклоњено
  1. 2 2
      Cargo.lock
  2. 1 1
      src/lib.rs
  3. 2 0
      src/metadata.rs
  4. 1 1
      src/spirc.rs

+ 2 - 2
Cargo.lock

@@ -15,7 +15,7 @@ dependencies = [
  "protobuf 1.0.15 (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)",
+ "rpassword 0.1.2 (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)",
@@ -316,7 +316,7 @@ dependencies = [
 
 [[package]]
 name = "rpassword"
-version = "0.1.0"
+version = "0.1.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "kernel32-sys 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",

+ 1 - 1
src/lib.rs

@@ -1,6 +1,6 @@
 #![crate_name = "librespot"]
 
-#![feature(plugin,zero_one,iter_arith,mpsc_select,clone_from_slice)]
+#![feature(plugin,zero_one,iter_arith,mpsc_select)]
 
 #![plugin(protobuf_macros)]
 #![plugin(json_macros)]

+ 2 - 0
src/metadata.rs

@@ -73,6 +73,7 @@ impl MetadataTrait for Track {
             album: SpotifyId::from_raw(msg.get_album().get_gid()),
             files: msg.get_file()
                       .iter()
+                      .filter(|file| file.has_file_id())
                       .map(|file| {
                           let mut dst = [0u8; 20];
                           dst.clone_from_slice(&file.get_file_id());
@@ -108,6 +109,7 @@ impl MetadataTrait for Album {
             covers: msg.get_cover_group()
                        .get_image()
                        .iter()
+                       .filter(|image| image.has_file_id())
                        .map(|image| {
                            let mut dst = [0u8; 20];
                            dst.clone_from_slice(&image.get_file_id());

+ 1 - 1
src/spirc.rs

@@ -156,7 +156,7 @@ impl<D: SpircDelegate> SpircManager<D> {
                 self.tracks = frame.get_state()
                                    .get_track()
                                    .iter()
-                                   .filter(|track| track.get_gid().len()==16)
+                                   .filter(|track| track.has_gid())
                                    .map(|track| SpotifyId::from_raw(track.get_gid()))
                                    .collect();