![]() |
Ansel 0.0
A darktable fork - bloat + design vision
|
Reading and writing one dt_image_t to and from the library database. The SQL half of what used to be common/image_cache.c.
More...
Include dependency graph for image_repository.h:
This graph shows which files directly or indirectly include this file:Go to the source code of this file.
Data Structures | |
| struct | dt_image_version_t |
| One version of a file: which duplicate it is, its id, and the name the user gave it. More... | |
| struct | dt_image_xmp_row_t |
The main.images fields an XMP sidecar carries. More... | |
| struct | dt_image_timestamps_t |
| The four timestamps, each with whether it is set at all. More... | |
| struct | dt_image_geo_bounds_t |
| The extent of the collection's geotagged images. More... | |
| struct | dt_image_geo_point_t |
| One geotagged image, in degrees as stored. More... | |
| struct | dt_image_group_member_t |
| One member of a group, with what a tooltip needs to name it. More... | |
Typedefs | |
| typedef void(* | dt_image_repository_collected_cb) (void *user_data, const dt_image_t *info) |
One image of the current collection. info is borrowed: it lives until the callback returns. | |
| typedef struct dt_image_version_t | dt_image_version_t |
| One version of a file: which duplicate it is, its id, and the name the user gave it. | |
| typedef struct dt_image_xmp_row_t | dt_image_xmp_row_t |
The main.images fields an XMP sidecar carries. | |
| typedef struct dt_image_timestamps_t | dt_image_timestamps_t |
| The four timestamps, each with whether it is set at all. | |
| typedef void(* | dt_image_repository_path_row_cb) (const int32_t imgid, const int64_t write_timestamp, const int version, const char *image_path, const int flags, void *user_data) |
One row of dt_image_repository_foreach_with_path(). image_path is borrowed: it lives until the callback returns. | |
| typedef struct dt_image_geo_bounds_t | dt_image_geo_bounds_t |
| The extent of the collection's geotagged images. | |
| typedef struct dt_image_geo_point_t | dt_image_geo_point_t |
| One geotagged image, in degrees as stored. | |
| typedef enum dt_image_field_t | dt_image_field_t |
| typedef struct dt_image_group_member_t | dt_image_group_member_t |
| One member of a group, with what a tooltip needs to name it. | |
| typedef void(* | dt_image_repository_id_filename_cb) (const int32_t imgid, const char *filename, void *user_data) |
One row of dt_image_repository_foreach_in_id_range(). filename is borrowed. | |
Functions | |
| G_BEGIN_DECLS gboolean | dt_image_repository_load (const int32_t imgid, dt_image_t *img) |
Fill img from the main.images row for imgid. | |
| void | dt_image_repository_store (const dt_image_t *img) |
Write img back to main.images, plus its colour labels and history hash. | |
| void | dt_image_repository_foreach_collected (dt_image_repository_collected_cb cb, void *user_data) |
| Every image of the current collection, in collection order, already mapped. | |
| int32_t | dt_image_repository_duplicate (const int32_t imgid, const int32_t newversion) |
Duplicate imgid as a new version, returning the new image id (-1 on failure). | |
| void | dt_image_version_free (gpointer data) |
| Release one dt_image_version_t. Use with g_list_free_full(). | |
| GList * | dt_image_repository_get_versions (const int32_t film_id, const char *filename, const int name_keyid) |
Every version of the file (film_id, filename), in version order, each with the name stored under metadata key name_keyid. | |
| GList * | dt_image_repository_get_duplicate_ids (const int32_t imgid) |
Every image id sharing imgid's film roll and filename, itself included, in row order – an image and its duplicates. | |
| int32_t | dt_image_repository_copy_to_film (const int32_t imgid, const int32_t filmid, const char *new_filename, const char *old_filename) |
Copy imgid into film roll filmid under new_filename, returning the new id. | |
| gboolean | dt_image_repository_get_xmp_row (const int32_t imgid, dt_image_xmp_row_t *row) |
Read imgid's sidecar fields. FALSE when there is no such image. | |
| void | dt_image_repository_xmp_row_cleanup (dt_image_xmp_row_t *row) |
| Release what dt_image_repository_get_xmp_row() allocated. | |
| gboolean | dt_image_repository_get_timestamps (const int32_t imgid, dt_image_timestamps_t *ts) |
Read imgid's four timestamps. FALSE when there is no such image. | |
| int32_t | dt_image_repository_find_by_film_and_filename (const int32_t film_id, const char *filename) |
The image id for filename inside film roll film_id, or -1. | |
| int32_t | dt_image_repository_find_by_folder_and_filename (const char *folder, const char *filename) |
The image id for a full path, split into its folder and filename, or -1. | |
| int | dt_image_repository_get_version (const int32_t imgid) |
The duplicate version number of imgid, or 0. | |
| gboolean | dt_image_repository_set_version (const int32_t imgid, const int version) |
Set both version and max_version of imgid to version. | |
| int | dt_image_repository_count_others_with_flag (const int32_t imgid, const int flag) |
How many OTHER images share this image's film roll and filename and carry flag. | |
| GList * | dt_image_repository_get_ids_with_flag_among (GList *imgids, const int flag) |
Of the images in imgids, those whose flags carry flag, in row order. | |
| gboolean | dt_image_repository_set_flag_among (GList *imgids, const int flag) |
Set flag on every image in imgids. | |
| GList * | dt_image_repository_get_full_paths (GList *imgids) |
"<folder>/<filename>" for every image in imgids, distinct, in row order. Caller owns the strings. | |
| GList * | dt_image_repository_get_ids_with_flag (const int flag) |
Every image id whose flags carry flag, in row order. | |
| gboolean | dt_image_repository_set_flags (const int32_t imgid, const int flags) |
Replace imgid's whole flags word. | |
| void | dt_image_repository_foreach_with_path (dt_image_repository_path_row_cb cb, void *user_data) |
| Walk every image in the library, film roll by film roll, filename within each. | |
| gboolean | dt_image_repository_get_collected_geo_bounds (dt_image_geo_bounds_t *bounds) |
| Bounding box of every collected image carrying coordinates. | |
| dt_image_geo_point_t * | dt_image_repository_get_collected_geo_points (const double lon1, const double lon2, const double lat1, const double lat2, int *count) |
| Collected images inside the box, ordered by longitude ascending. | |
| int * | dt_image_repository_count_distinct_fields (GList *imgids) |
How many DISTINCT values each dt_image_field_t takes over imgids. | |
| int64_t | dt_image_repository_get_write_timestamp (const int32_t imgid) |
main.images.write_timestamp for imgid, or 0. | |
| void | dt_image_repository_touch_write_timestamp (const int32_t imgid) |
Set write_timestamp of imgid to now. | |
| gboolean | dt_image_repository_set_write_timestamp (const int32_t imgid, const int64_t timestamp) |
Set write_timestamp of imgid to timestamp (seconds since the epoch). Bound as a 64-bit integer; the caller this replaced bound it as an int. | |
| gboolean | dt_image_repository_delete (const int32_t imgid) |
Delete imgid from main.images and main.meta_data. | |
| GList * | dt_image_repository_get_group_members (const int32_t group_id, const int32_t exclude_imgid) |
Image ids in group group_id. | |
| void | dt_image_group_member_free (gpointer data) |
| Free one dt_image_group_member_t. Suits g_list_free_full(). | |
| GList * | dt_image_repository_get_group_member_rows (const int32_t group_id) |
Every member of group_id, in row order, named. Free with g_list_free_full(list, dt_image_group_member_free). | |
| int | dt_image_repository_count_in_id_range (const int32_t min_imgid, const int32_t max_imgid) |
How many images have an id in [min_imgid, max_imgid]. -1 when unreadable. | |
| void | dt_image_repository_foreach_in_id_range (const int32_t min_imgid, const int32_t max_imgid, dt_image_repository_id_filename_cb cb, void *user_data) |
Walk the images whose id falls in [min_imgid, max_imgid], in row order. | |
| gboolean | dt_image_repository_insert_import (const int32_t film_id, const char *filename, const int flags, const int64_t import_timestamp) |
| Insert a bare row for a file being imported, returning TRUE on success. | |
| int32_t | dt_image_repository_find_group_for_pattern (const int32_t film_id, const char *filename_pattern, const gboolean leader_only, const int32_t exclude_imgid) |
The group leader of an existing image in film_id matching filename_pattern (a LIKE pattern), or -1. | |
| gboolean | dt_image_repository_set_group (const int32_t imgid, const int32_t group_id) |
Set imgid's group_id. | |
| void | dt_image_repository_reassign_group (const int32_t from_group_id, const int32_t to_group_id, const int32_t exclude_imgid) |
Move every member of from_group_id into to_group_id, except exclude_imgid. | |
| GList * | dt_image_repository_get_ratings (const int32_t imgid) |
Star ratings, as main.images.flags encodes them: the low three bits, minus one. | |
| void | dt_image_repository_cleanup (void) |
| Finalise the prepared statements. Called at shutdown, after the last cache release and before the database connection closes. | |
Reading and writing one dt_image_t to and from the library database. The SQL half of what used to be common/image_cache.c.
The image cache was two things wearing one name: an LRU of dt_image_t structs with refcounting and per-entry locking, and the only code in the tree that knows the shape of the main.images row. The second is not a cache, it is a repository – 107 of the file's lines were SQL – and keeping them together meant every consumer of the cache also had a translation unit that could reach the database.
They are separate now. caches/image_cache.c holds the LRU and calls in here whenever it needs a row read or written; this file holds every sqlite3_* call and the prepared statements behind them, and knows nothing about caching, refcounting or eviction.
Definition in file image_repository.h.
Fields dt_image_repository_count_distinct_fields() reports on, IN THE ORDER IT RETURNS THEM. This enumeration is the contract: its one consumer is a metadata panel whose own row enumeration runs in the same order, and it checks the length it gets back against its own before reading a single value. Append here and there, never insert.
The extent of the collection's geotagged images.
One geotagged image, in degrees as stored.
One member of a group, with what a tooltip needs to name it.
| typedef void(* dt_image_repository_collected_cb) (void *user_data, const dt_image_t *info) |
One image of the current collection. info is borrowed: it lives until the callback returns.
Definition at line 77 of file image_repository.h.
| typedef void(* dt_image_repository_id_filename_cb) (const int32_t imgid, const char *filename, void *user_data) |
One row of dt_image_repository_foreach_in_id_range(). filename is borrowed.
Definition at line 449 of file image_repository.h.
| typedef void(* dt_image_repository_path_row_cb) (const int32_t imgid, const int64_t write_timestamp, const int version, const char *image_path, const int flags, void *user_data) |
One row of dt_image_repository_foreach_with_path(). image_path is borrowed: it lives until the callback returns.
Definition at line 271 of file image_repository.h.
The four timestamps, each with whether it is set at all.
One version of a file: which duplicate it is, its id, and the name the user gave it.
The main.images fields an XMP sidecar carries.
Fields dt_image_repository_count_distinct_fields() reports on, IN THE ORDER IT RETURNS THEM. This enumeration is the contract: its one consumer is a metadata panel whose own row enumeration runs in the same order, and it checks the length it gets back against its own before reading a single value. Append here and there, never insert.
Definition at line 346 of file image_repository.h.
| void dt_image_group_member_free | ( | gpointer | data | ) |
Free one dt_image_group_member_t. Suits g_list_free_full().
Definition at line 381 of file image_repository.c.
References dt_free, IS_NULL_PTR, and L.
Referenced by _image_update_group_tooltip(), and test_group_member_rows().
Finalise the prepared statements. Called at shutdown, after the last cache release and before the database connection closes.
Definition at line 1578 of file image_repository.c.
References _image_load_stmt, _image_set_flags_stmt, _image_stmt_mutex, _image_stmt_mutex_inited, _image_write_history_hash_stmt, _image_write_timestamp_select_stmt, _image_write_timestamp_update_stmt, dt_pthread_mutex_destroy(), and L.
Referenced by dt_image_cache_cleanup(), and testdb_teardown().
| int32_t dt_image_repository_copy_to_film | ( | const int32_t | imgid, |
| const int32_t | filmid, | ||
| const char * | new_filename, | ||
| const char * | old_filename | ||
| ) |
Copy imgid into film roll filmid under new_filename, returning the new id.
The database half of "copy an image to another folder": the row, its three satellite tables, the version and max_version of every duplicate sharing the destination name, and the group the copy joins. Moving the file and copying its history are the caller's.
| old_filename | imgid's current filename, needed to tell the freshly inserted row apart from any pre-existing image of the same name in the destination roll. |
Definition at line 1219 of file image_repository.c.
References dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_BIND_TEXT, DT_DEBUG_SQLITE3_PREPARE_V2, dt_free, and L.
Referenced by dt_image_copy_rename().
| int * dt_image_repository_count_distinct_fields | ( | GList * | imgids | ) |
How many DISTINCT values each dt_image_field_t takes over imgids.
One value per field, so a caller can grey out whatever the images disagree on. A count above 1 means they disagree; 0 means nothing was read.
The id set is built into the statement as integers, never bound to an IN (?) – SQLite reads a bound comma-joined string as ONE value, which matches a lone id and matches nothing at all for two or more.
Definition at line 751 of file image_repository.c.
References _id_set(), dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_PREPARE_V2, dt_free, DT_IMAGE_FIELD_COUNT, i, IS_NULL_PTR, and L.
Referenced by _concatenate_multiple_images(), and test_count_distinct_fields().
How many images have an id in [min_imgid, max_imgid]. -1 when unreadable.
Definition at line 420 of file image_repository.c.
References dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_PREPARE_V2, IS_NULL_PTR, and L.
Referenced by generate_thumbnail_cache(), and test_id_range().
How many OTHER images share this image's film roll and filename and carry flag.
Used to decide whether removing one local copy would orphan the others. Counts rows other than imgid itself; answers 1 when the query cannot be read, which is the conservative "assume someone else has one" the caller relied on.
Definition at line 579 of file image_repository.c.
References dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_PREPARE_V2, flag, and L.
Referenced by _nb_other_local_copy_for().
| gboolean dt_image_repository_delete | ( | const int32_t | imgid | ) |
Delete imgid from main.images and main.meta_data.
Foreign keys added in schema version 33 cascade the delete to every other table referencing the image, so these two statements are the whole removal. main.meta_data is listed explicitly because it predates the constraint.
Definition at line 977 of file image_repository.c.
References dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_PREPARE_V2, L, and TRUE.
Referenced by dt_image_remove().
Duplicate imgid as a new version, returning the new image id (-1 on failure).
| newversion | the version to give the duplicate, or -1 for "one past the current max". If that version already exists for this file, its id is returned and NOTHING is written – the call is idempotent per version. |
Definition at line 999 of file image_repository.c.
References dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_BIND_TEXT, DT_DEBUG_SQLITE3_PREPARE_V2, dt_free, L, MAX, and UNKNOWN_IMAGE.
Referenced by _image_duplicate_with_version(), and dt_image_read_duplicates().
| int32_t dt_image_repository_find_by_film_and_filename | ( | const int32_t | film_id, |
| const char * | filename | ||
| ) |
The image id for filename inside film roll film_id, or -1.
Definition at line 509 of file image_repository.c.
References dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_BIND_TEXT, DT_DEBUG_SQLITE3_PREPARE_V2, IS_NULL_PTR, and L.
Referenced by dt_image_get_id(), and testdb_make_image().
| int32_t dt_image_repository_find_by_folder_and_filename | ( | const char * | folder, |
| const char * | filename | ||
| ) |
The image id for a full path, split into its folder and filename, or -1.
Joins main.film_rolls on its folder rather than taking a film id, because the caller has a path and not a roll.
Definition at line 525 of file image_repository.c.
References dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_TEXT, DT_DEBUG_SQLITE3_PREPARE_V2, IS_NULL_PTR, and L.
Referenced by dt_image_get_id_full_path().
| int32_t dt_image_repository_find_group_for_pattern | ( | const int32_t | film_id, |
| const char * | filename_pattern, | ||
| const gboolean | leader_only, | ||
| const int32_t | exclude_imgid | ||
| ) |
The group leader of an existing image in film_id matching filename_pattern (a LIKE pattern), or -1.
Used at import to decide whether the file joins an existing group of same-basename images. Two questions, one per caller: leader_only TRUE asks for a row that IS its own group leader; FALSE asks for any row's group, excluding exclude_imgid.
Definition at line 1425 of file image_repository.c.
References dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_BIND_TEXT, DT_DEBUG_SQLITE3_PREPARE_V2, and L.
Referenced by _image_import_internal().
| void dt_image_repository_foreach_collected | ( | dt_image_repository_collected_cb | cb, |
| void * | user_data | ||
| ) |
Every image of the current collection, in collection order, already mapped.
One bulk query instead of one image-cache miss per thumbnail, which is what keeps scrolling a large collection predictable. It selects the same columns dt_image_repository_load() does and maps them with the same private mapper, so the column list and the mapper cannot drift apart – they used to sit in two files, with the caller running its own copy of the query and calling the mapper on each row.
The statement is prepared and finalised around the walk rather than cached, and no internal lock is held while the callback runs. Callbacks here reach the selection and the image cache, either of which can raise a signal that lands back in this same function; a single shared statement stepped re-entrantly would have its cursor pulled out from under the outer walk. One prepare per collection reload is the price, and a collection reload is not a per-frame event.
Definition at line 227 of file image_repository.c.
References dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_PREPARE_V2, dt_image_from_stmt(), dt_image_init(), IS_NULL_PTR, and L.
Referenced by _dt_collection_lut().
| void dt_image_repository_foreach_in_id_range | ( | const int32_t | min_imgid, |
| const int32_t | max_imgid, | ||
| dt_image_repository_id_filename_cb | cb, | ||
| void * | user_data | ||
| ) |
Walk the images whose id falls in [min_imgid, max_imgid], in row order.
Same prepare-and-finalise, no-lock-held contract as dt_image_repository_foreach_collected(): its one caller generates a thumbnail per row, which goes back through the image and mipmap caches.
Definition at line 436 of file image_repository.c.
References dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_PREPARE_V2, IS_NULL_PTR, and L.
Referenced by generate_thumbnail_cache().
| void dt_image_repository_foreach_with_path | ( | dt_image_repository_path_row_cb | cb, |
| void * | user_data | ||
| ) |
Walk every image in the library, film roll by film roll, filename within each.
Hands the callback what is needed to find an image's files on disk and compare them against the row: its path, its version (for the sidecar's _NN suffix), the write_timestamp a sidecar's mtime is checked against, and the flags word recording which companion files it had last time.
The statement is prepared and finalised around the walk rather than cached, and no internal lock is held while the callback runs: the callback is expected to write back through this same repository (dt_image_repository_set_flags()), and a cached statement under the shared statement mutex would deadlock on that re-entry.
Definition at line 722 of file image_repository.c.
References dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_PREPARE_V2, IS_NULL_PTR, and L.
Referenced by dt_control_crawler_run().
| gboolean dt_image_repository_get_collected_geo_bounds | ( | dt_image_geo_bounds_t * | bounds | ) |
Bounding box of every collected image carrying coordinates.
bounds is seeded with an empty extent (mins at +INFINITY, maxes at -INFINITY, count 0) – the caller's original locals – so the numbers mean something ONLY when count is positive. A count of 0 means the collection has nothing geotagged, and the extent fields must not be read. Definition at line 823 of file image_repository.c.
References dt_image_geo_bounds_t::count, dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_PREPARE_V2, FALSE, IS_NULL_PTR, L, dt_image_geo_bounds_t::max_latitude, dt_image_geo_bounds_t::max_longitude, dt_image_geo_bounds_t::min_latitude, and dt_image_geo_bounds_t::min_longitude.
Referenced by _view_map_center_on_image_list().
| dt_image_geo_point_t * dt_image_repository_get_collected_geo_points | ( | const double | lon1, |
| const double | lon2, | ||
| const double | lat1, | ||
| const double | lat2, | ||
| int * | count | ||
| ) |
Collected images inside the box, ordered by longitude ascending.
The order is not cosmetic: the caller's DBSCAN clustering sweeps the array in longitude order and would cluster differently without it.
| count | out: how many points the array holds. Never NULL. |
count points, or NULL when there are none. Free with dt_free(). Definition at line 859 of file image_repository.c.
References dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_DOUBLE, DT_DEBUG_SQLITE3_PREPARE_V2, FALSE, dt_image_geo_point_t::imgid, IS_NULL_PTR, L, p, and TRUE.
Referenced by _view_map_changed_callback_delayed().
Every image id sharing imgid's film roll and filename, itself included, in row order – an image and its duplicates.
Definition at line 1194 of file image_repository.c.
References dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_PREPARE_V2, and L.
Referenced by _get_base_value(), dt_control_delete_images_job_run(), and dt_image_rename().
"<folder>/<filename>" for every image in imgids, distinct, in row order. Caller owns the strings.
Definition at line 656 of file image_repository.c.
References _id_set(), dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_PREPARE_V2, dt_free, IS_NULL_PTR, and L.
Referenced by dt_control_delete_images_job_run(), dt_control_remove_images_job_run(), and test_full_paths().
Every member of group_id, in row order, named. Free with g_list_free_full(list, dt_image_group_member_free).
Definition at line 389 of file image_repository.c.
References dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_PREPARE_V2, dt_image_group_member_t::imgid, IS_NULL_PTR, and L.
Referenced by _image_update_group_tooltip(), and test_group_member_rows().
| GList * dt_image_repository_get_group_members | ( | const int32_t | group_id, |
| const int32_t | exclude_imgid | ||
| ) |
Image ids in group group_id.
| exclude_imgid | an image to leave out, or -1 to leave nothing out. |
GList of ids as GINT_TO_POINTER, in database order. Free with g_list_free(). Definition at line 372 of file image_repository.c.
References _collect_ids(), dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_PREPARE_V2, and L.
Referenced by _image_import_internal(), dt_grouping_change_representative(), dt_grouping_get_group_images(), and dt_grouping_remove_from_group().
Every image id whose flags carry flag, in row order.
Definition at line 677 of file image_repository.c.
References dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_PREPARE_V2, flag, and L.
Referenced by dt_image_local_copy_synch().
Of the images in imgids, those whose flags carry flag, in row order.
The id set is built into the statement as integers. Callers used to pass a comma-joined STRING bound to a single IN (?) parameter, which SQLite reads as ONE value: it matched a lone id and matched NOTHING for two or more.
Definition at line 622 of file image_repository.c.
References _id_set(), dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_PREPARE_V2, dt_free, flag, IS_NULL_PTR, and L.
Referenced by dt_control_remove_images_job_run(), and test_flag_among_multi_image().
Star ratings, as main.images.flags encodes them: the low three bits, minus one.
| imgid | the image, or a negative value for every selected image – the convention dt_metadata_get() uses, which is this function's only caller. |
GList of ratings as GINT_TO_POINTER, one per image. Free with g_list_free(). Definition at line 472 of file image_repository.c.
References dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_PREPARE_V2, and L.
Referenced by dt_metadata_get().
| gboolean dt_image_repository_get_timestamps | ( | const int32_t | imgid, |
| dt_image_timestamps_t * | ts | ||
| ) |
Read imgid's four timestamps. FALSE when there is no such image.
Definition at line 1533 of file image_repository.c.
References dt_image_timestamps_t::change_timestamp, dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_PREPARE_V2, dt_image_timestamps_t::export_timestamp, FALSE, dt_image_timestamps_t::has_change, dt_image_timestamps_t::has_export, dt_image_timestamps_t::has_import, dt_image_timestamps_t::has_print, dt_image_timestamps_t::import_timestamp, IS_NULL_PTR, L, dt_image_timestamps_t::print_timestamp, and TRUE.
Referenced by set_xmp_timestamps().
| int dt_image_repository_get_version | ( | const int32_t | imgid | ) |
The duplicate version number of imgid, or 0.
Definition at line 553 of file image_repository.c.
References dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_PREPARE_V2, and L.
Referenced by dt_image_path_append_version().
| GList * dt_image_repository_get_versions | ( | const int32_t | film_id, |
| const char * | filename, | ||
| const int | name_keyid | ||
| ) |
Every version of the file (film_id, filename), in version order, each with the name stored under metadata key name_keyid.
Which key holds the version name is the caller's vocabulary, so it is passed in. The whole list is materialised: the one caller builds a GTK widget per row and would otherwise re-enter the database from inside its own open cursor.
Definition at line 1157 of file image_repository.c.
References dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_BIND_TEXT, DT_DEBUG_SQLITE3_PREPARE_V2, IS_NULL_PTR, L, name, and v.
Referenced by _lib_duplicate_init_callback().
| int64_t dt_image_repository_get_write_timestamp | ( | const int32_t | imgid | ) |
main.images.write_timestamp for imgid, or 0.
Definition at line 907 of file image_repository.c.
References _image_stmt_mutex, _image_stmt_mutex_ensure(), _image_write_timestamp_select_stmt, dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_PREPARE_V2, dt_pthread_mutex_lock(), dt_pthread_mutex_unlock(), IS_NULL_PTR, and L.
Referenced by _sidecar_is_up_to_date(), and test_write_timestamp_is_64bit().
| gboolean dt_image_repository_get_xmp_row | ( | const int32_t | imgid, |
| dt_image_xmp_row_t * | row | ||
| ) |
Read imgid's sidecar fields. FALSE when there is no such image.
Definition at line 1479 of file image_repository.c.
References dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_PREPARE_V2, f, FALSE, IS_NULL_PTR, L, row, and TRUE.
Referenced by _exif_xmp_read_data(), and _exif_xmp_read_data_export().
| gboolean dt_image_repository_insert_import | ( | const int32_t | film_id, |
| const char * | filename, | ||
| const int | flags, | ||
| const int64_t | import_timestamp | ||
| ) |
Insert a bare row for a file being imported, returning TRUE on success.
Everything but the identity is left at its default and filled in later from EXIF and the sidecar. position takes the next free slot at the end of the collection order. The row's id is not returned: the caller finds it with dt_image_repository_find_by_film_and_filename(), which is what the original did.
Definition at line 1399 of file image_repository.c.
References dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_BIND_INT64, DT_DEBUG_SQLITE3_BIND_TEXT, DT_DEBUG_SQLITE3_PREPARE_V2, flags, and L.
Referenced by _image_import_internal(), and testdb_make_image().
| G_BEGIN_DECLS gboolean dt_image_repository_load | ( | const int32_t | imgid, |
| dt_image_t * | img | ||
| ) |
Fill img from the main.images row for imgid.
| imgid | image to read. |
| img | destination. On failure its id is set to -1, which is what dt_image_invalid() tests, and the rest is left as the caller had it. |
Definition at line 199 of file image_repository.c.
References _image_get_stmt(), _image_stmt_mutex, _image_stmt_mutex_ensure(), dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_INT, dt_image_from_stmt(), dt_pthread_mutex_lock(), dt_pthread_mutex_unlock(), FALSE, dt_image_t::id, IS_NULL_PTR, L, and TRUE.
Referenced by _image_cache_reload_from_db().
| void dt_image_repository_reassign_group | ( | const int32_t | from_group_id, |
| const int32_t | to_group_id, | ||
| const int32_t | exclude_imgid | ||
| ) |
Move every member of from_group_id into to_group_id, except exclude_imgid.
Definition at line 456 of file image_repository.c.
References dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_PREPARE_V2, and L.
Referenced by dt_grouping_remove_from_group().
Set flag on every image in imgids.
Definition at line 640 of file image_repository.c.
References _id_set(), dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_PREPARE_V2, dt_free, FALSE, flag, IS_NULL_PTR, and L.
Referenced by dt_control_delete_images_job_run(), dt_control_remove_images_job_run(), and test_flag_among_multi_image().
Replace imgid's whole flags word.
Definition at line 694 of file image_repository.c.
References _image_set_flags_stmt, _image_stmt_mutex, _image_stmt_mutex_ensure(), dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_PREPARE_V2, dt_pthread_mutex_lock(), dt_pthread_mutex_unlock(), FALSE, flags, IS_NULL_PTR, and L.
Referenced by _crawl_image().
Set imgid's group_id.
Definition at line 1465 of file image_repository.c.
References dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_PREPARE_V2, and L.
Referenced by _image_import_internal(), and test_group_member_rows().
Set both version and max_version of imgid to version.
Definition at line 566 of file image_repository.c.
References dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_PREPARE_V2, and L.
Referenced by dt_image_read_duplicates().
Set write_timestamp of imgid to timestamp (seconds since the epoch). Bound as a 64-bit integer; the caller this replaced bound it as an int.
Definition at line 959 of file image_repository.c.
References dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_BIND_INT64, DT_DEBUG_SQLITE3_PREPARE_V2, FALSE, IS_NULL_PTR, and L.
Referenced by sync_newest_to_oldest(), sync_oldest_to_newest(), sync_xmp_to_db(), and test_write_timestamp_is_64bit().
| void dt_image_repository_store | ( | const dt_image_t * | img | ) |
Write img back to main.images, plus its colour labels and history hash.
Three tables carry one image's state: the row itself, main.color_labels (through dt_colorlabel_repository_set()/dt_colorlabel_repository_remove(), one call per colour) and main.history_hash. A caller that wrote only the first would leave an image whose labels and hash describe its previous contents.
| img | image to persist. Ignored when NULL or when its id is not positive. |
Definition at line 272 of file image_repository.c.
References _image_write_history_hash(), dt_image_t::change_timestamp, color, dt_image_t::color_labels, dt_image_t::colorspace, dt_image_t::d65_color_matrix, dt_colorlabel_repository_remove(), dt_colorlabel_repository_set(), dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_BLOB, DT_DEBUG_SQLITE3_BIND_DOUBLE, DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_BIND_INT64, DT_DEBUG_SQLITE3_BIND_TEXT, DT_DEBUG_SQLITE3_PREPARE_V2, dt_image_geoloc_t::elevation, dt_image_t::exif_aperture, dt_image_t::exif_crop, dt_image_t::exif_datetime_taken, dt_image_t::exif_exposure, dt_image_t::exif_exposure_bias, dt_image_t::exif_focal_length, dt_image_t::exif_focus_distance, dt_image_t::exif_iso, dt_image_t::exif_lens, dt_image_t::exif_maker, dt_image_t::exif_model, dt_image_t::export_timestamp, dt_image_t::filename, dt_image_t::film_id, dt_image_t::flags, flip, dt_image_t::geoloc, dt_image_t::group_id, dt_image_t::height, dt_image_t::id, dt_image_t::import_timestamp, IS_NULL_PTR, L, dt_image_geoloc_t::latitude, dt_image_t::legacy_flip, dt_image_geoloc_t::longitude, dt_image_t::orientation, dt_image_t::print_timestamp, dt_image_t::raw_black_level, dt_image_t::raw_white_point, and dt_image_t::width.
Referenced by dt_image_cache_write_release().
Set write_timestamp of imgid to now.
Definition at line 936 of file image_repository.c.
References _image_stmt_mutex, _image_stmt_mutex_ensure(), _image_write_timestamp_update_stmt, dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_PREPARE_V2, dt_pthread_mutex_lock(), dt_pthread_mutex_unlock(), and L.
Referenced by _write_sidecar_file_from_image_locked().
| void dt_image_repository_xmp_row_cleanup | ( | dt_image_xmp_row_t * | row | ) |
Release what dt_image_repository_get_xmp_row() allocated.
Definition at line 1526 of file image_repository.c.
References dt_free, IS_NULL_PTR, L, and row.
Referenced by _exif_xmp_read_data(), and _exif_xmp_read_data_export().
| void dt_image_version_free | ( | gpointer | data | ) |
Release one dt_image_version_t. Use with g_list_free_full().
Definition at line 1149 of file image_repository.c.
References dt_free, IS_NULL_PTR, and v.
Referenced by _lib_duplicate_init_callback().