Skip to content

Commit

Permalink
Merge #16: Properly handle CR in RandomWin UUID parsing
Browse files Browse the repository at this point in the history
Fixes #15 

Also add observation UUID logging in uploadPhoto to potentially help diagnose similar issues in the future.
  • Loading branch information
rcloran authored Mar 2, 2024
2 parents 8ce8ece + 376e124 commit 64b1293
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lr-inaturalist-publish.lrdevplugin/RandomWin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ end
local function getUUIDs()
local vbs = LrPathUtils.child(_PLUGIN.path, "uuid.vbs")
local output = execWithOutput('cscript /NoLogo "' .. vbs .. '"')
for line in output:gmatch("([^\n]+)\n") do
for line in output:gmatch("([^\r\n]+)\r?\n") do
if not isUUID(line) then
return false
end
Expand Down
3 changes: 3 additions & 0 deletions lr-inaturalist-publish.lrdevplugin/Upload.lua
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ local function uploadPhoto(api, observations, rendition, path, exportSettings)
local observationUUID = rendition.photo:getPropertyForPlugin(_PLUGIN, MetadataConst.ObservationUUID)

if observationUUID and observations[observationUUID] then
logger:tracef("Updating observation %s", observationUUID)
-- There's already an observation that was created this session. It's
-- faster to add an observation photo than upload photo then update the
-- observation.
Expand All @@ -68,13 +69,15 @@ local function uploadPhoto(api, observations, rendition, path, exportSettings)
-- this obs yet this session.
-- In either case, POST /observations with local_photos set is safe. In
-- the latter case it will be added to the list of observation_photos.
logger:tracef("Creating photo and observation with UUID %s", observationUUID)
local photo = api:createPhoto(path)
LrFileUtils.delete(path)
local observation = updateObservation(photo.to_observation, rendition.photo, exportSettings)
-- Weirdly the `to_observation` included in the photo response doesn't
-- include the photo ID
observation.local_photos = { [0] = { photo.id } }
observation = api:createObservation(observation)
logger:tracef("createObservation returned UUID: %s", observation.uuid)

return photo, observation
end
Expand Down

0 comments on commit 64b1293

Please sign in to comment.