Skip to content
This repository has been archived by the owner on May 16, 2022. It is now read-only.

Commit

Permalink
Add check for empty output from imgsum
Browse files Browse the repository at this point in the history
In some cases like if no photos were available it's
possible to get empty output back which would cause
exception from Lua side. This patch fixes such behaviour.

Signed-off-by: Igor Shishkin <me@teran.ru>
  • Loading branch information
teran committed Oct 16, 2017
1 parent 6357554 commit 65e6f79
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions deduplicator.lrdevplugin/FindDuplicates.lua
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,19 @@ function FindDuplicates()
local s = assert(f:read('*a'))
f:close()

local imgsum_output = json:decode(s)

if imgsum_output["duplicates"] ~= nil then
catalog:withWriteAccessDo("Create collection", function()
for _, photo in pairs(imgsum_output["duplicates"]) do
for _, file in pairs(photo) do
p = catalog:findPhotoByPath(file)
collection:addPhotos({p})
if s ~= "" then
local imgsum_output = json:decode(s)

if imgsum_output["duplicates"] ~= nil then
catalog:withWriteAccessDo("Create collection", function()
for _, photo in pairs(imgsum_output["duplicates"]) do
for _, file in pairs(photo) do
p = catalog:findPhotoByPath(file)
collection:addPhotos({p})
end
end
end
end)
end)
end
end
end

Expand Down

0 comments on commit 65e6f79

Please sign in to comment.