From 4397e07d7fb8811ca13b609d2cd86def90d25985 Mon Sep 17 00:00:00 2001 From: Christian Mandel Date: Wed, 27 Apr 2016 17:18:41 +0200 Subject: [PATCH 1/2] Fix accidentally deleted first image during import. Lua is very picky about sparse table handling. --- official/import_filters.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/official/import_filters.lua b/official/import_filters.lua index e3d595c..9fa496d 100644 --- a/official/import_filters.lua +++ b/official/import_filters.lua @@ -50,6 +50,7 @@ dt.register_import_filter("prefer raw over jpeg", function(event, images) local current_base = "" local jpg_indices = {} local other_format_found = false + local last_index table.insert(images, "") for i, img in ipairs(images) do local extension = img:match("[^.]*$"):upper() @@ -74,8 +75,9 @@ dt.register_import_filter("prefer raw over jpeg", function(event, images) other_format_found = true end + last_index = i end - table.remove(images) + images[last_index] = nil end) -- vim: shiftwidth=2 expandtab tabstop=2 cindent From 2325d24d6fae2de60c32b999b0ee94ad059cf3cd Mon Sep 17 00:00:00 2001 From: Christian Mandel Date: Thu, 28 Apr 2016 10:27:25 +0200 Subject: [PATCH 2/2] Comments added for import-filters fix. --- official/import_filters.lua | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/official/import_filters.lua b/official/import_filters.lua index 9fa496d..584a271 100644 --- a/official/import_filters.lua +++ b/official/import_filters.lua @@ -1,6 +1,6 @@ --[[ This file is part of darktable, - copyright (c) 2015 Tobias Ellinghaus + copyright (c) 2015-2016 Tobias Ellinghaus & Christian Mandel darktable is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -50,8 +50,11 @@ dt.register_import_filter("prefer raw over jpeg", function(event, images) local current_base = "" local jpg_indices = {} local other_format_found = false + + -- add dummy image to force processing for the last image local last_index table.insert(images, "") + for i, img in ipairs(images) do local extension = img:match("[^.]*$"):upper() local base = img:match("^.*[.]") @@ -77,7 +80,12 @@ dt.register_import_filter("prefer raw over jpeg", function(event, images) last_index = i end + + -- remove dummy image from list (just to make sure, it works even with keeping + -- the dummy but that may break in the future), table.remove(images) does not + -- work reliable because it can fail for sparse tables images[last_index] = nil + end) -- vim: shiftwidth=2 expandtab tabstop=2 cindent