Polochon-street / blissify-rs

bliss bindings for MPD.
29 stars 6 forks source link

reading sqlitedb ends up in Utf8Error #40

Closed altesockensuppe closed 8 months ago

altesockensuppe commented 8 months ago

Hi,

after installing, I initialized my music collection.
It worked well, about 60'000 files!

but the created songs.db cannot be read out

root@debian:~# .cargo/bin/blissify list-db
[2023-12-27T01:13:17Z WARN  blissify] Could not find any MPD_PORT environment variable set. Defaulting to 6600.
thread 'main' panicked at /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bliss-audio-0.6.9/src/library.rs:1085:31:
called `Result::unwrap()` on an `Err` value: FromSqlConversionFailure(2, Text, Utf8Error { valid_up_to: 6, error_len: Some(1) })
stack backtrace:
   0: rust_begin_unwind
             at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/std/src/panicking.rs:597:5
   1: core::panicking::panic_fmt
             at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/core/src/panicking.rs:72:14
   2: core::result::unwrap_failed
             at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/core/src/result.rs:1652:5
   3: bliss_audio::library::Library<Config>::_song_from_row_closure
   4: bliss_audio::library::Library<Config>::_songs_from_statement
   5: blissify::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

A rescan does not help

As a test, I put the music_directory on a subfolder in mpd. About 500 files were scanned. The list-db command worked.

if I install blissify on another computer and copy the sound.db to it, I get the same error.

System:

Polochon-street commented 8 months ago

Hi,

Thanks for submitting the bugreport. How big is the songs.db file? Would it be possible to maybe send it to me on my email on my github profile / upload it somewhere?

If not, tell me, and I'll try to reproduce it artificially myself.

altesockensuppe commented 8 months ago

Hi @Polochon-street

I looked at the DB with a sqlite browser but didn't notice anything conspicuous.

I have now started to scan my collection with mp3check and mp3val and to repair "broken" audio files. There were a lot of hits...

the sound.db is 64mb in size. I have zipped it (still 25mb) and uploaded it.
I have sent the link to your e-mail address.

I am very curious about what is causing the problem.
Many thanks for your quick support.

Polochon-street commented 8 months ago

Hi again! Thanks for all the nice debug info :)

The problem is most likely broken UTF8 in some songs (artists mostly), which leads to a panic when trying to get these fields from the database. Would you be able to try out this branch https://github.com/Polochon-street/bliss-rs/pull/67 (library-fix-utf8), and tell me whether it fixes it for you? Cloning blissify, and putting instead of bliss-audio = "0.6.9", bliss-audio = { git = "https://github.com/Polochon-street/bliss-rs.git", branch = "library-fix-utf8" } and running cargo run --release list-db should do the trick.

I've been able to blissify list-db with your database after my fix, but I don't know if making playlists will show other errors. Hopefully not! 🤞

altesockensuppe commented 8 months ago

Nice, works!

$ cargo run --release list-db | wc -l
    Finished release [optimized] target(s) in 0.07s
warning: the following packages contain code that will be rejected by a future version of Rust: rustc-serialize v0.3.24
note: to see what the problems were, use the option `--future-incompat-report`, or run `cargo report future-incompatibilities --id 1`
     Running `target/release/blissify list-db`
[2023-12-27T12:25:58Z WARN  blissify] Could not find any MPD_PORT environment variable set. Defaulting to 6600.
59378

And even the playlist command works! :muscle:

$ mpc
[playing] #1/1   0:04/3:53 (1%)

$ cargo run --release playlist 30
    Finished release [optimized] target(s) in 0.10s
warning: the following packages contain code that will be rejected by a future version of Rust: rustc-serialize v0.3.24
note: to see what the problems were, use the option `--future-incompat-report`, or run `cargo report future-incompatibilities --id 1`
     Running `target/release/blissify playlist 30`
[2023-12-27T12:27:42Z WARN  blissify] Could not find any MPD_PORT environment variable set. Defaulting to 6600.

$ mpc 
[playing] #1/30   0:43/3:53 (18%)

Should I test something else?

EDIT:
the command looks slightly different on the raspberry pi

cargo run --features=ffmpeg-next/rpi --release list-db
Polochon-street commented 8 months ago

Awesome! If this work, everything should work hopefully.

Closing the issue, but don't hesitate to open another one if you experience any other problem :)

Polochon-street commented 8 months ago

Hi! Just as a heads-up - I've updated blissify with the fix, so getting v.0.3.7+ should work for you. Cheers!