Skip to content

Commit

Permalink
Add observation UUID logging in uploadPhoto
Browse files Browse the repository at this point in the history
  • Loading branch information
rcloran committed Mar 1, 2024
1 parent 8ce8ece commit a66063a
Showing 1 changed file with 3 additions and 0 deletions.
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 a66063a

Please sign in to comment.