Merge pull request #67 from Polochon-street/library-fix-utf8

Fix utf8 panic in the library module
This commit is contained in:
Polochon-street 2023-12-27 19:31:30 +01:00 committed by GitHub
commit d10a1cf526
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 44 additions and 11 deletions

View File

@ -3,7 +3,8 @@
## bliss 0.6.10
* Make the `analyze` function public, for people who don't want to use
ffmpeg
* Run `cargo update`
* Run `cargo update`, bump ffmpeg to 6.1
* Fix the library module erroring when wrong UTF-8 ends up in the database.
## bliss 0.6.9
* Add a feature flag for compilation on raspberry pis.

2
Cargo.lock generated
View File

@ -112,7 +112,7 @@ checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07"
[[package]]
name = "bliss-audio"
version = "0.6.9"
version = "0.6.10"
dependencies = [
"anyhow",
"bliss-audio-aubio-rs",

View File

@ -1,6 +1,6 @@
[package]
name = "bliss-audio"
version = "0.6.9"
version = "0.6.10"
build = "build.rs"
authors = ["Polochon-street <polochonstreet@gmx.fr>"]
edition = "2021"
@ -40,8 +40,8 @@ serde = ["dep:serde"]
# Hopefully we'll be able to use the official aubio-rs at some point.
bliss-audio-aubio-rs = "0.2.1"
crossbeam = "0.8.2"
ffmpeg-next = "6.0.0"
ffmpeg-sys-next = { version = "6.0.1", default-features = false }
ffmpeg-next = "6.1.0"
ffmpeg-sys-next = { version = "6.1.0", default-features = false }
log = "0.4.17"
ndarray = { version = "0.15.6", features = ["rayon"] }
num_cpus = "1.15.0"

View File

@ -1081,12 +1081,42 @@ impl<Config: AppConfigTrait> Library<Config> {
let song = Song {
path: PathBuf::from(path),
artist: row.get(1).unwrap(),
title: row.get(2).unwrap(),
album: row.get(3).unwrap(),
album_artist: row.get(4).unwrap(),
track_number: row.get(5).unwrap(),
genre: row.get(6).unwrap(),
artist: row
.get_ref(1)
.unwrap()
.as_bytes_or_null()
.unwrap()
.map(|v| String::from_utf8_lossy(v).to_string()),
title: row
.get_ref(2)
.unwrap()
.as_bytes_or_null()
.unwrap()
.map(|v| String::from_utf8_lossy(v).to_string()),
album: row
.get_ref(3)
.unwrap()
.as_bytes_or_null()
.unwrap()
.map(|v| String::from_utf8_lossy(v).to_string()),
album_artist: row
.get_ref(4)
.unwrap()
.as_bytes_or_null()
.unwrap()
.map(|v| String::from_utf8_lossy(v).to_string()),
track_number: row
.get_ref(5)
.unwrap()
.as_bytes_or_null()
.unwrap()
.map(|v| String::from_utf8_lossy(v).to_string()),
genre: row
.get_ref(6)
.unwrap()
.as_bytes_or_null()
.unwrap()
.map(|v| String::from_utf8_lossy(v).to_string()),
analysis: Analysis {
internal_analysis: [0.; NUMBER_FEATURES],
},
@ -1287,6 +1317,8 @@ fn data_local_dir() -> Option<PathBuf> {
#[cfg(test)]
// TODO refactor (especially the helper functions)
// TODO the tests should really open a songs.db
// TODO test with invalid UTF-8
mod test {
use super::*;
use crate::{Analysis, NUMBER_FEATURES};