[shotwell] Always create faces database
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [shotwell] Always create faces database
- Date: Sat, 23 Feb 2019 19:03:29 +0000 (UTC)
commit 646dd9c2a92aba1ac9a872d3debffe56a4baae12
Author: Jens Georg <mail jensge org>
Date: Fri Feb 22 11:55:43 2019 +0100
Always create faces database
With the map support merged, we need to have a consistent database numbering.
Faces support + extension will be 21, map extension is 22
src/db/DatabaseTable.vala | 13 ++++---------
src/db/Db.vala | 38 ++++++++++++++++++++------------------
src/db/FaceLocationTable.vala | 4 ----
src/db/FaceTable.vala | 2 --
src/faces/Face.vala | 4 ++--
src/faces/FaceLocation.vala | 3 ---
src/meson.build | 10 +++++-----
7 files changed, 31 insertions(+), 43 deletions(-)
---
diff --git a/src/db/DatabaseTable.vala b/src/db/DatabaseTable.vala
index dc69f2c5..6e1a5b2f 100644
--- a/src/db/DatabaseTable.vala
+++ b/src/db/DatabaseTable.vala
@@ -21,17 +21,12 @@ public abstract class DatabaseTable {
* tables are created on demand and tables and columns are easily ignored when already present.
* However, the change should be noted in upgrade_database() as a comment.
***/
- public const int SCHEMA_VERSION = 21;
-#if ENABLE_FACES
- public const int SCHEMA_VERSION = 21;
-#else
- public const int SCHEMA_VERSION = 20;
-#endif
-
+ public const int SCHEMA_VERSION = 22;
+
protected static Sqlite.Database db;
-
+
private static int in_transaction = 0;
-
+
public string table_name = null;
private static void prepare_db(string filename) {
diff --git a/src/db/Db.vala b/src/db/Db.vala
index 34646324..e56c7298 100644
--- a/src/db/Db.vala
+++ b/src/db/Db.vala
@@ -350,13 +350,30 @@ private VerifyResult upgrade_database(int input_version) {
version = 20;
-#if ENABLE_FACES
+
//
// Version 21:
+ // * Add has_gps, gps_lat and gps_lon columns to PhotoTable
+
+ if (!DatabaseTable.ensure_column("PhotoTable", "has_gps", "INTEGER DEFAULT -1",
+ "upgrade_database: adding gps_lat column to PhotoTable")
+ || !DatabaseTable.ensure_column("PhotoTable", "gps_lat", "REAL",
+ "upgrade_database: adding gps_lat column to PhotoTable")
+ || !DatabaseTable.ensure_column("PhotoTable", "gps_lon", "REAL",
+ "upgrade_database: adding gps_lon column to PhotoTable")) {
+ return VerifyResult.UPGRADE_ERROR;
+ }
+
+ version = 21;
+
+ //
+ // Version 22:
+ // * Create face detection tables even if feasture is not enabled
// * Added face pixels column to FaceLocationTable
// * Added face vector column to FaceTable
//
-
+ FaceTable.get_instance();
+ FaceLocationTable.get_instance();
if (!DatabaseTable.has_column("FaceLocationTable", "vec")) {
message("upgrade_database: adding vec column to FaceLocationTable");
if (!DatabaseTable.add_column("FaceLocationTable", "vec", "TEXT"))
@@ -373,23 +390,8 @@ private VerifyResult upgrade_database(int input_version) {
return VerifyResult.UPGRADE_ERROR;
}
- version = 21;
-#endif
-
- //
- // Version 21:
- // * Add has_gps, gps_lat and gps_lon columns to PhotoTable
+ version = 22;
- if (!DatabaseTable.ensure_column("PhotoTable", "has_gps", "INTEGER DEFAULT -1",
- "upgrade_database: adding gps_lat column to PhotoTable")
- || !DatabaseTable.ensure_column("PhotoTable", "gps_lat", "REAL",
- "upgrade_database: adding gps_lat column to PhotoTable")
- || !DatabaseTable.ensure_column("PhotoTable", "gps_lon", "REAL",
- "upgrade_database: adding gps_lon column to PhotoTable")) {
- return VerifyResult.UPGRADE_ERROR;
- }
-
- version = 21;
//
// Finalize the upgrade process
//
diff --git a/src/db/FaceLocationTable.vala b/src/db/FaceLocationTable.vala
index 991786ad..989c2941 100644
--- a/src/db/FaceLocationTable.vala
+++ b/src/db/FaceLocationTable.vala
@@ -4,8 +4,6 @@
* (version 2.1 or later). See the COPYING file in this distribution.
*/
-#if ENABLE_FACES
-
public struct FaceLocationID {
public const int64 INVALID = -1;
@@ -266,5 +264,3 @@ public class FaceLocationTable : DatabaseTable {
return rows;
}
}
-
-#endif
diff --git a/src/db/FaceTable.vala b/src/db/FaceTable.vala
index be53515f..8de7663e 100644
--- a/src/db/FaceTable.vala
+++ b/src/db/FaceTable.vala
@@ -4,7 +4,6 @@
* (version 2.1 or later). See the COPYING file in this distribution.
*/
-#if ENABLE_FACES
public struct FaceID {
public const int64 INVALID = -1;
@@ -212,4 +211,3 @@ public class FaceTable : DatabaseTable {
return rows;
}
}
-#endif
diff --git a/src/faces/Face.vala b/src/faces/Face.vala
index 338c98e7..b2249076 100644
--- a/src/faces/Face.vala
+++ b/src/faces/Face.vala
@@ -4,7 +4,6 @@
* (version 2.1 or later). See the COPYING file in this distribution.
*/
-#if ENABLE_FACES
public class FaceSourceCollection : ContainerSourceCollection {
private Gee.HashMap<string, Face> name_map = new Gee.HashMap<string, Face>
((Gee.HashDataFunc)Face.hash_name_string, (Gee.EqualDataFunc)Face.equal_name_strings);
@@ -354,11 +353,13 @@ public class Face : DataSource, ContainerSource, Proxyable, Indexable {
#endif
}
+#if ENABLE_FACES
public static void terminate() {
try {
FaceDetect.interface.terminate();
} catch(Error e) {}
}
+#endif
public static int compare_names(void *a, void *b) {
Face *aface = (Face *) a;
@@ -705,4 +706,3 @@ public class Face : DataSource, ContainerSource, Proxyable, Indexable {
}
}
-#endif
diff --git a/src/faces/FaceLocation.vala b/src/faces/FaceLocation.vala
index 48abd2d4..f222cae2 100644
--- a/src/faces/FaceLocation.vala
+++ b/src/faces/FaceLocation.vala
@@ -4,8 +4,6 @@
* (version 2.1 or later). See the COPYING file in this distribution.
*/
-#if ENABLE_FACES
-
// Encapsulate geometry and pixels of a Face
public struct FaceLocationData {
public string geometry;
@@ -224,4 +222,3 @@ public class FaceLocation : Object {
}
}
-#endif
diff --git a/src/meson.build b/src/meson.build
index 1eed90b5..3844a5b3 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -28,14 +28,10 @@ face_obj = ''
if get_option('face-detection')
face_sources = (['faces/FacesBranch.vala',
- 'faces/FaceLocation.vala',
'faces/FacePage.vala',
'faces/FaceShape.vala',
- 'faces/Faces.vala',
- 'faces/Face.vala',
'faces/FaceDetect.vala',
- 'db/FaceLocationTable.vala',
- 'db/FaceTable.vala',
+ 'faces/Faces.vala',
'faces/FacesTool.vala'])
endif
@@ -67,6 +63,8 @@ executable('shotwell',
'db/DatabaseTable.vala',
'db/PhotoTable.vala',
'db/EventTable.vala',
+ 'db/FaceLocationTable.vala',
+ 'db/FaceTable.vala',
'db/TagTable.vala',
'db/TombstoneTable.vala',
'db/VideoTable.vala',
@@ -75,6 +73,8 @@ executable('shotwell',
'editing_tools/EditingTools.vala',
'editing_tools/RGBHistogramManipulator.vala',
'editing_tools/StraightenTool.vala',
+ 'faces/Face.vala',
+ 'faces/FaceLocation.vala',
'slideshow/Slideshow.vala',
'slideshow/TransitionEffects.vala',
'photos/Photos.vala',
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]