![]() |
Ansel 0.0
A darktable fork - bloat + design vision
|
#include "system/mem_alloc.h"#include "common/paths.h"#include "common/conf.h"#include "import_jobs.h"#include "import_sequence.h"#include "common/collection.h"#include "common/datetime.h"#include "metadata/exif.h"#include "develop/history_merge.h"#include "metadata/metadata.h"#include "common/styles.h"#include "control/control.h"#include "common/film.h"#include "common/image.h"#include "control/jobs/control_jobs.h"#include <string.h>#include <glib/gstdio.h>#include "common/utility.h"#include "osx/osx.h"
Include dependency graph for import_jobs.c:Go to the source code of this file.
Functions | |
| gboolean | _create_dir (const char *path) |
| Creates folders from path. Returns TRUE if success. | |
| gchar * | _path_cleanup (gchar *path_in) |
| Replaces separator depending of the current OS and removes whitespaces. | |
| gchar * | dt_build_filename_from_pattern (const char *const filename, const int index, dt_image_t *img, dt_control_import_t *data) |
| Build a full path for a given image file, given a pattern. | |
| gboolean | _file_exist (const char *dest_file_path) |
| Tests if file exist. Returns 1 if so. | |
| gboolean | _copy_file (const char *filename, const char *dest_file_path) |
| Just copy a file. Returns 1 if success. | |
| const int32_t | _import_job (dt_control_import_t *data, gchar *img_path_to_db) |
| Add an image entry in the database and returns its imgID. | |
| void | dt_import_duplicate_get_dest_name (char *xmp_dest_name, const char *dest_file_path, const int counter) |
Gets the computed xmp file name with apropriate number for import copy. It computes a duplicate name based on the counter value. The first path in the list ALWAYS become the default xmp. So in case the default xmp was not found, the first one in the list is used as default. Else, it's a duplicate. | |
| int | _import_copy_xmp (const char *const filename, const gchar *dest_file_path) |
| Attempt to find all sidecar XMP files along an image file and import (copy) it to destination. | |
| int | _import_copy_txt (const char *const filename, const char *dest_file_path) |
| int | _import_copy_file (const char *const filename, const char *const dest_file_path, dt_control_import_t *data, gchar *img_path_to_db, size_t pathname_len, GList **discarded) |
| copy a file to a destination path after checking if everything is allright. | |
| void | _write_xmp_id (const char *filename, int32_t imgid) |
| int32_t | _import_image (const GList *img, dt_control_import_t *data, const char *final_destination, GList **discarded, int *xmps) |
| process to copy (or not) and import an image to database. | |
| static void | _refresh_progress_counter (dt_job_t *job, const int elements, const int index, const gboolean folder_survey) |
| Update import progress with wording matching the import origin. | |
| static int32_t | _control_import_job_run (dt_job_t *job) |
| void | dt_control_import_data_free (dt_control_import_t *data) |
| void | dt_control_import_set_discarded_files_handler (dt_control_import_discarded_handler_t handler) |
| static void | _control_import_job_cleanup (void *p) |
| static void * | _control_import_alloc () |
| static dt_job_t * | _control_import_job_create (dt_control_import_t data) |
| int | dt_control_import (dt_control_import_t data) |
| Process a list of images to import with or without copying the files on an arbitrary hard-drive. | |
Variables | |
| static dt_control_import_discarded_handler_t | _discarded_files_handler = NULL |
|
static |
Definition at line 700 of file import_jobs.c.
References dt_control_image_enumerator_alloc(), dt_control_image_enumerator_cleanup(), IS_NULL_PTR, and params.
Referenced by _control_import_job_create().
Definition at line 679 of file import_jobs.c.
References _discarded_files_handler, dt_control_import_t::discarded, dt_control_image_enumerator_cleanup(), dt_control_import_data_free(), dt_free, p, and params.
Referenced by _control_import_job_create().
|
static |
Definition at line 714 of file import_jobs.c.
References _control_import_alloc(), _control_import_job_cleanup(), _control_import_job_run(), dt_control_job_add_progress(), dt_control_job_create(), dt_control_job_dispose(), dt_control_job_set_params(), FALSE, IS_NULL_PTR, and params.
Referenced by dt_control_import().
|
static |
Reserve expanded copy destinations before any filesystem work.
Siblings preserve their capture sequence while their destinations differ. A sibling reservation with that shared sequence consumes one new global sequence and receives one replacement expansion. The replacement is never retried: an unchanged or already-reserved result reaches the configured conflict policy without replacing its first reservation owner. Tables stay alive until after the loop so failed copies and database imports permanently consume their sequence and reservation for this job.
Definition at line 505 of file import_jobs.c.
References _import_image(), _refresh_progress_counter(), dt_control_import_t::callback_data, dt_import_sequence_t::captures, dt_control_import_t::copy, dt_import_sequence_t::destinations, dt_control_import_t::discarded, dt_alloc_align(), DT_COLLECTION_CHANGE_NEW_QUERY, dt_collection_get_global(), DT_COLLECTION_IMPORT_VIEW_GRID, DT_COLLECTION_IMPORT_VIEW_IMAGE, DT_COLLECTION_IMPORT_VIEW_KEEP, dt_collection_load_filmroll(), dt_collection_notify_imported(), DT_COLLECTION_PROP_UNDEF, dt_collection_update_query(), dt_conf_set_int(), dt_control_job_get_params(), dt_control_log(), DT_DEBUG_IMPORT, dt_exif_read(), dt_free, dt_free_align, dt_free_gpointer(), dt_image_init(), dt_import_sequence_assign(), dt_import_sequence_destination(), dt_print(), dt_control_import_t::elements, dt_control_import_t::file_imported, dt_control_import_t::folder_survey, dt_control_import_t::imgs, IS_NULL_PTR, params, dt_control_import_t::target_file_pattern, dt_control_import_t::target_subfolder_pattern, TRUE, and UNKNOWN_IMAGE.
Referenced by _control_import_job_create().
| gboolean _copy_file | ( | const char * | filename, |
| const char * | dest_file_path | ||
| ) |
Just copy a file. Returns 1 if success.
| filename | |
| dest_file_path |
Definition at line 160 of file import_jobs.c.
References DT_DEBUG_IMPORT, dt_print(), out, and res.
Referenced by _import_copy_file(), _import_copy_txt(), and _import_copy_xmp().
| gboolean _create_dir | ( | const char * | path | ) |
Creates folders from path. Returns TRUE if success.
| path | a valid folders path to create. |
Definition at line 54 of file import_jobs.c.
References dt_control_log(), FALSE, and TRUE.
Referenced by _import_copy_file().
| gboolean _file_exist | ( | const char * | dest_file_path | ) |
Tests if file exist. Returns 1 if so.
| dest_file_path |
Definition at line 148 of file import_jobs.c.
References IS_NULL_PTR.
Referenced by _import_copy_file().
| int _import_copy_file | ( | const char *const | filename, |
| const char *const | dest_file_path, | ||
| dt_control_import_t * | data, | ||
| gchar * | img_path_to_db, | ||
| size_t | pathname_len, | ||
| GList ** | discarded | ||
| ) |
copy a file to a destination path after checking if everything is allright.
| filename | source file path. |
| dest_file_path | final borrowed destination selected before import. |
| data | import module information. |
| img_path_to_db | will be set to the file path for import. |
| pathname_len | the img_path_to_db size. |
| discarded | the list of file pathes discarded because the target already exists |
Definition at line 289 of file import_jobs.c.
References _copy_file(), _create_dir(), _file_exist(), _import_copy_txt(), _import_copy_xmp(), cleanup(), DT_DEBUG_IMPORT, DT_DEBUG_PRINT, dt_free, DT_IMPORT_ONCONFLICT_OVERWRITE, DT_IMPORT_ONCONFLICT_UNIQUE, dt_print(), dt_util_dir_exist(), dt_util_test_writable_dir(), FALSE, dt_control_import_t::on_conflict, and dt_control_import_t::target_dir.
Referenced by _import_image(), and _test_copy_directory_failure_reports_only_its_cause().
| int _import_copy_txt | ( | const char *const | filename, |
| const char * | dest_file_path | ||
| ) |
Definition at line 258 of file import_jobs.c.
References _copy_file(), DT_DEBUG_IMPORT, dt_free, dt_image_build_text_path_from_path(), dt_image_get_text_path_from_path(), dt_print(), and IS_NULL_PTR.
Referenced by _import_copy_file().
| int _import_copy_xmp | ( | const char *const | filename, |
| const gchar * | dest_file_path | ||
| ) |
Attempt to find all sidecar XMP files along an image file and import (copy) it to destination.
| filename | full path of original image file |
| dest_file_path | full path of destination image file |
Definition at line 232 of file import_jobs.c.
References _copy_file(), DT_DEBUG_IMPORT, dt_free, dt_image_find_xmps(), dt_import_duplicate_get_dest_name(), DT_PATH_MAX, and dt_print().
Referenced by _import_copy_file().
| int32_t _import_image | ( | const GList * | img, |
| dt_control_import_t * | data, | ||
| const char * | final_destination, | ||
| GList ** | discarded, | ||
| int * | xmps | ||
| ) |
process to copy (or not) and import an image to database.
Sidecars are read only after database import succeeds. Source deletion requires a successful copy and complete byte equality; stream errors preserve the source. Styles are applied in their configured order using one merge batch, followed by cache and thumbnail invalidation because the history was written to the DB.
| img | the current image. |
| data | info from import module. |
| final_destination | final borrowed copy destination, ignored without copy. |
Definition at line 406 of file import_jobs.c.
References _import_copy_file(), _import_job(), dt_control_import_t::copy, dt_control_import_t::delete_source, dt_control_alert(), DT_DEBUG_IMPORT, DT_HISTORY_MERGE_APPEND, dt_hm_batch_state_cleanup(), dt_image_history_changed(), dt_image_read_duplicates(), DT_PATH_MAX, dt_print(), dt_styles_apply_to_image_merge(), dt_styles_get_id_by_name(), dt_util_streams_equal(), FALSE, IS_NULL_PTR, dt_control_import_t::styles, TRUE, and UNKNOWN_IMAGE.
Referenced by _control_import_job_run().
| const int32_t _import_job | ( | dt_control_import_t * | data, |
| gchar * | img_path_to_db | ||
| ) |
Add an image entry in the database and returns its imgID.
| data | informations from the import module |
| img_path_to_db | the file path to import |
Definition at line 181 of file import_jobs.c.
References dt_film_new(), dt_free, dt_image_import(), dt_util_path_get_dirname(), and dt_control_import_t::folder_survey.
Referenced by _import_image().
| gchar * _path_cleanup | ( | gchar * | path_in | ) |
Replaces separator depending of the current OS and removes whitespaces.
| path |
Definition at line 72 of file import_jobs.c.
References dt_cleanup_separators(), dt_free, and dt_util_remove_whitespace().
Referenced by dt_build_filename_from_pattern().
|
static |
Update import progress with wording matching the import origin.
Definition at line 487 of file import_jobs.c.
References double(), dt_control_job_set_progress(), and dt_control_job_set_progress_message().
Referenced by _control_import_job_run().
| void _write_xmp_id | ( | const char * | filename, |
| int32_t | imgid | ||
| ) |
Definition at line 364 of file import_jobs.c.
References DT_DATETIME_EXIF_LENGTH, dt_datetime_unix_to_exif(), dt_free_gpointer(), dt_metadata_get(), dt_metadata_set(), error(), FALSE, IS_NULL_PTR, and res.
| gchar * dt_build_filename_from_pattern | ( | const char *const | filename, |
| const int | index, | ||
| dt_image_t * | img, | ||
| dt_control_import_t * | data | ||
| ) |
Build a full path for a given image file, given a pattern.
| filename | Full path of the original file |
| index | Incremental number in a sequence |
| img | dt_image_t object. Needs to be inited with EXIF fields prior to calling this function, otherwise EXIF variables are expanded to defaults/fallback. |
| data | Import options |
Definition at line 80 of file import_jobs.c.
References _path_cleanup(), dt_control_import_t::base_folder, dt_control_import_t::datetime, DT_DEBUG_PRINT, dt_free, dt_print(), dt_util_normalize_path(), dt_variables_expand(), dt_variables_params_destroy(), dt_variables_params_init(), dt_variables_set_datetime(), FALSE, IS_NULL_PTR, dt_control_import_t::jobcode, params, res, dt_control_import_t::target_dir, dt_control_import_t::target_file_pattern, dt_control_import_t::target_subfolder_pattern, and UNKNOWN_IMAGE.
Referenced by _set_test_path(), _test_pattern_expansion_rejects_missing_patterns(), dt_folder_survey_destination_preview(), and dt_import_sequence_destination().
| int dt_control_import | ( | dt_control_import_t | data | ) |
Process a list of images to import with or without copying the files on an arbitrary hard-drive.
| data | import informations to transmit through the functions |
Definition at line 731 of file import_jobs.c.
References _control_import_job_create(), dt_control_import_t::callback_data, dt_control_add_job(), dt_control_get_global(), dt_control_import_data_free(), DT_JOB_QUEUE_USER_FG, FALSE, dt_control_import_t::file_imported, dt_control_import_t::imgs, and IS_NULL_PTR.
Referenced by _dnd_folder_import_job_run(), _folder_survey_job_run(), _process_file_list(), _test_public_copy_failure_reservation_forces_sibling_fallback(), _test_public_database_failure_reservation_forces_sibling_fallback(), _test_public_delete_source_requires_successful_copy(), _test_public_failures_consume_sequences_and_complete_once(), _test_public_fixed_destination_follows_all_policies(), _test_public_in_place_import_preserves_source(), _test_public_reserved_fallback_reaches_policy_without_third_expansion(), _test_public_sibling_collision_reexpands_once(), _test_public_siblings_keep_sequence_for_distinct_destinations(), _test_public_unrelated_collision_has_no_sibling_fallback(), and _thumbtable_dnd_import().
| void dt_control_import_data_free | ( | dt_control_import_t * | data | ) |
Definition at line 636 of file import_jobs.c.
References dt_control_import_t::base_folder, dt_control_import_t::callback_data, dt_control_import_t::callback_data_free, dt_control_import_t::datetime, dt_control_import_t::discarded, dt_free, dt_free_gpointer(), dt_control_import_t::imgs, IS_NULL_PTR, dt_control_import_t::jobcode, dt_control_import_t::styles, dt_control_import_t::target_dir, dt_control_import_t::target_file_pattern, and dt_control_import_t::target_subfolder_pattern.
Referenced by _control_import_job_cleanup(), _import_discarded_files_popup(), _set_test_path(), dt_control_import(), and dt_folder_survey_destination_preview().
| void dt_control_import_set_discarded_files_handler | ( | dt_control_import_discarded_handler_t | handler | ) |
Definition at line 670 of file import_jobs.c.
References _discarded_files_handler.
Referenced by dt_gui_import_init_handlers().
| void dt_import_duplicate_get_dest_name | ( | char * | xmp_dest_name, |
| const char * | dest_file_path, | ||
| const int | counter | ||
| ) |
Gets the computed xmp file name with apropriate number for import copy. It computes a duplicate name based on the counter value. The first path in the list ALWAYS become the default xmp. So in case the default xmp was not found, the first one in the list is used as default. Else, it's a duplicate.
| xmp_dest_name | the destination name. |
| dest_file_path | the full filename path of the destination image. |
| counter | the number of duplicates. |
Definition at line 208 of file import_jobs.c.
References DT_DEBUG_IMPORT, dt_free, DT_PATH_MAX, dt_print(), dt_util_normalize_path(), and safe_strlen().
Referenced by _import_copy_xmp().
|
static |
Definition at line 668 of file import_jobs.c.
Referenced by _control_import_job_cleanup(), and dt_control_import_set_discarded_files_handler().