Fix sample_rate type mismatches for LocalAlbum and inserts
Changed LocalAlbum.sample_rate from u32 to f64 to match database REAL type. Fixed database queries to read sample_rate as f64 instead of u32. Removed incorrect i64 casts when inserting sample_rate values. This fixes the 'Invalid column type Real' error that prevented the app from loading after the database migration.
This commit is contained in:
1 parent
4080cfbfc8
commit
88d4bc8471
2 files changed
+4
-4
No files matched your search
@@ -909,7 +909,7 @@ impl LibraryDatabase {
|
|||||||
&row.get::<_, Option<String>>(8)?.unwrap_or_default(),
|
&row.get::<_, Option<String>>(8)?.unwrap_or_default(),
|
||||||
),
|
),
|
||||||
bit_depth: row.get(9)?,
|
bit_depth: row.get(9)?,
|
||||||
sample_rate: row.get::<_, Option<u32>>(10)?.unwrap_or(44100),
|
sample_rate: row.get::<_, Option<f64>>(10)?.unwrap_or(44100.0),
|
||||||
directory_path: row
|
directory_path: row
|
||||||
.get::<_, Option<String>>(11)?
|
.get::<_, Option<String>>(11)?
|
||||||
.unwrap_or_else(|| group_key.clone()),
|
.unwrap_or_else(|| group_key.clone()),
|
||||||
@@ -2008,7 +2008,7 @@ impl LibraryDatabase {
|
|||||||
duration_secs as i64,
|
duration_secs as i64,
|
||||||
"flac", // Default format for downloads
|
"flac", // Default format for downloads
|
||||||
bit_depth.map(|v| v as i64),
|
bit_depth.map(|v| v as i64),
|
||||||
sample_rate.map(|v| v as i64).unwrap_or(44100),
|
sample_rate.unwrap_or(44100.0),
|
||||||
2, // Assume stereo
|
2, // Assume stereo
|
||||||
file_size_bytes,
|
file_size_bytes,
|
||||||
now,
|
now,
|
||||||
@@ -2079,7 +2079,7 @@ impl LibraryDatabase {
|
|||||||
duration_secs as i64,
|
duration_secs as i64,
|
||||||
"flac",
|
"flac",
|
||||||
bit_depth.map(|v| v as i64),
|
bit_depth.map(|v| v as i64),
|
||||||
sample_rate.unwrap_or(44100.0) as i64,
|
sample_rate.unwrap_or(44100.0),
|
||||||
2, // Assume stereo
|
2, // Assume stereo
|
||||||
file_size_bytes,
|
file_size_bytes,
|
||||||
now,
|
now,
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ pub struct LocalAlbum {
|
|||||||
pub total_duration_secs: u64,
|
pub total_duration_secs: u64,
|
||||||
pub format: AudioFormat,
|
pub format: AudioFormat,
|
||||||
pub bit_depth: Option<u32>,
|
pub bit_depth: Option<u32>,
|
||||||
pub sample_rate: u32,
|
pub sample_rate: f64, // Changed from u32 to f64 for decimal precision
|
||||||
pub directory_path: String,
|
pub directory_path: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user