![]() |
Ansel 0.0
A darktable fork - bloat + design vision
|
memory.removed_*: the staging area behind "undo remove from library".
More...
#include <glib.h>#include <stdint.h>
Include dependency graph for removed_image_repository.h:
This graph shows which files directly or indirectly include this file:Go to the source code of this file.
Functions | |
| G_BEGIN_DECLS int | dt_removed_image_repository_create (const int32_t imgid) |
Copy every row imgid owns out of main, so the removal about to happen can be undone. | |
| gboolean | dt_removed_image_repository_restore (const int snap_id, const int32_t imgid) |
Copy snapshot snap_id of imgid back into main, film roll included. | |
| void | dt_removed_image_repository_clear (const int snap_id, const int32_t imgid) |
Drop snapshot snap_id of imgid, making the removal permanent. | |
memory.removed_*: the staging area behind "undo remove from library".
Removing an image from the library deletes its main.images row, and the foreign keys take its history, masks, tags, colour labels, metadata and module order down with it. Nothing about that is recoverable from the file on disk – the raw is still there, but the edit is not – so the rows are copied into memory. twins first and copied back to undo the removal. Every function here is a bulk table-to-table copy, which is why the rows never become C structs: the same reason database/history_snapshot_repository.h gives.
The twins are declared in database.c by CREATE TABLE ... AS SELECT over the live tables, so their columns follow whatever main holds and a schema migration needs no edit here. Each carries two extra leading columns, snap_id and undo_imgid, which is the key every function below takes.
common/image.c keeps the undo bookkeeping – when a snapshot is taken, what the undo and redo halves do with it, and when it is dropped.
Definition in file removed_image_repository.h.
| void dt_removed_image_repository_clear | ( | const int | snap_id, |
| const int32_t | imgid | ||
| ) |
Drop snapshot snap_id of imgid, making the removal permanent.
Definition at line 264 of file removed_image_repository.c.
References _debug_memory(), _removed_tables, _run(), dt_free, i, and name.
Referenced by _remove_undo_data_free(), and test_clear_drops_the_snapshot().
| G_BEGIN_DECLS int dt_removed_image_repository_create | ( | const int32_t | imgid | ) |
Copy every row imgid owns out of main, so the removal about to happen can be undone.
Call this BEFORE anything touches the image: the group membership of the images staying behind is part of the snapshot, and removing a group's leader rewrites it.
The snapshot id is allocated here rather than asked for separately, so that reading the highest id an image already has and writing rows under the next one happen inside the same transaction.
Definition at line 138 of file removed_image_repository.c.
References _columns_of(), _debug_memory(), _next_id(), _removed_tables, _run(), dt_database_release_transaction, dt_database_rollback_transaction(), dt_database_start_transaction, dt_free, i, IS_NULL_PTR, name, and TRUE.
Referenced by _image_remove(), test_clear_drops_the_snapshot(), test_film_roll_comes_back_with_its_last_image(), test_group_leader_restores_membership(), test_partial_undo_repoints_a_departed_leader(), test_round_trip_restores_every_table(), test_successive_snapshots_do_not_collide(), and test_whole_group_removed_and_fully_undone_keeps_one_group().
| gboolean dt_removed_image_repository_restore | ( | const int | snap_id, |
| const int32_t | imgid | ||
| ) |
Copy snapshot snap_id of imgid back into main, film roll included.
Foreign keys are deferred to the commit, because an image is restored before the group leader it points at may be: a group removed in one go comes back one image per undo record, in whatever order the undo list holds. Any group_id still dangling at the end of the restore is repointed at the image itself rather than left to fail the commit.
Definition at line 193 of file removed_image_repository.c.
References _columns_of(), _removed_tables, _run(), dt_database_get_sqlite3_global(), dt_database_release_transaction, dt_database_rollback_transaction(), dt_database_start_transaction, dt_free, i, IS_NULL_PTR, name, and TRUE.
Referenced by _pop_undo(), test_clear_drops_the_snapshot(), test_film_roll_comes_back_with_its_last_image(), test_group_leader_restores_membership(), test_partial_undo_repoints_a_departed_leader(), test_round_trip_restores_every_table(), test_successive_snapshots_do_not_collide(), and test_whole_group_removed_and_fully_undone_keeps_one_group().