[niepce/gtk4] library: upgrade schema to 10
- From: Hubert Figuière <hub src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [niepce/gtk4] library: upgrade schema to 10
- Date: Sat, 14 May 2022 02:46:25 +0000 (UTC)
commit 18f34ab7178860511985aa7feccc4f8d8123d008
Author: Hubert Figuière <hub figuiere net>
Date: Fri May 13 00:29:54 2022 -0400
library: upgrade schema to 10
- set files.xmp_file and files.jpeg_file to default to 0 instead of NULL
- Make sure in case of error xmp_file is 0 and not NULL
for the case where rewrite_xmp_for_id() need to create a new
crates/npc-engine/src/db/library.rs | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
---
diff --git a/crates/npc-engine/src/db/library.rs b/crates/npc-engine/src/db/library.rs
index 672115f..545b2ba 100644
--- a/crates/npc-engine/src/db/library.rs
+++ b/crates/npc-engine/src/db/library.rs
@@ -49,7 +49,7 @@ pub enum Managed {
YES = 1,
}
-const DB_SCHEMA_VERSION: i32 = 9;
+const DB_SCHEMA_VERSION: i32 = 10;
const DATABASENAME: &str = "niepcelibrary.db";
#[derive(Debug)]
@@ -261,8 +261,8 @@ impl Library {
file_date INTEGER, rating INTEGER DEFAULT 0, \
label INTEGER, flag INTEGER DEFAULT 0, \
import_date INTEGER, mod_date INTEGER, \
- xmp TEXT, xmp_date INTEGER, xmp_file INTEGER,\
- jpeg_file INTEGER)",
+ xmp TEXT, xmp_date INTEGER, xmp_file INTEGER DEFAULT 0,\
+ jpeg_file INTEGER DEFAULT 0)",
[],
)
.unwrap();
@@ -1078,7 +1078,8 @@ impl Library {
while let Ok(Some(row)) = rows.next() {
let xmp_buffer: String = row.get(0)?;
let main_file_id: LibraryId = row.get(1)?;
- let xmp_file_id: LibraryId = row.get(2)?;
+ // In case of error we assume 0.
+ let xmp_file_id: LibraryId = row.get(2).unwrap_or(0);
let p = self.get_fs_file(main_file_id);
let spath = if let Ok(ref p) = p {
PathBuf::from(p)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]