196
196
public bool is_already_imported() {
197
197
string? preview_md5 = get_import_source().get_preview_md5();
199
// ignore trashed duplicates
200
return (preview_md5 != null)
201
? LibraryPhoto.has_nontrash_duplicate(null, preview_md5, null,
202
get_import_source().get_file_format()) : false;
198
PhotoFileFormat file_format = get_import_source().get_file_format();
200
// ignore trashed duplicates
201
if (!is_string_empty(preview_md5)
202
&& LibraryPhoto.has_nontrash_duplicate(null, preview_md5, null, file_format)) {
206
// Because gPhoto doesn't reliably return thumbnails for RAW files, and because we want
207
// to avoid downloading huge RAW files during an "import all" only to determine they're
208
// duplicates, use the image's basename and filesize to do duplicate detection
209
if (file_format == PhotoFileFormat.RAW) {
210
uint64 filesize = get_import_source().get_filesize();
211
// unlikely to be a problem, but what the hay
212
if (filesize <= int64.MAX) {
213
if (LibraryPhoto.global.has_basename_filesize_duplicate(
214
get_import_source().get_filename(), (int64) filesize)) {
205
223
public ImportSource get_import_source() {
344
362
get_view().monitor_source_collection(import_sources, new ImportViewManager(this));
346
364
// sort by exposure time
347
get_view().set_comparator(preview_comparator);
365
get_view().set_comparator(preview_comparator, preview_comparator_predicate);
349
367
// monitor selection for UI
350
368
get_view().items_state_changed.connect(on_view_changed);
432
450
return Resources.ICON_SINGLE_PHOTO;
435
private int64 preview_comparator(void *a, void *b) {
453
private static int64 preview_comparator(void *a, void *b) {
436
454
return ((ImportPreview *) a)->get_import_source().get_exposure_time()
437
455
- ((ImportPreview *) b)->get_import_source().get_exposure_time();
458
private static bool preview_comparator_predicate(DataObject object, Alteration alteration) {
459
return alteration.has_detail("metadata", "exposure-time");
440
462
private int64 import_job_comparator(void *a, void *b) {
441
463
return ((CameraImportJob *) a)->get_exposure_time() - ((CameraImportJob *) b)->get_exposure_time();
1049
1068
jobs.add(new CameraImportJob(null_context, import_file));
1071
debug("Importing %d files from %s", jobs.size, camera_name);
1052
1073
if (jobs.size > 0) {
1053
1074
// see import_reporter() to see why this is held during the duration of the import
1054
1075
assert(local_ref == null);
1351
1372
private void on_fatal_error(ImportResult result, string message) {
1352
1373
AppWindow.error_message(message);
1376
public override string? get_icon_name() {
1377
return Resources.ICON_IMPORTING;