So far it seems that the re-publish is triggere because the "someKey" is present in the metadataThatTriggersRepublish table. If I remove it from there, calling the setPropertyForPlugin() method and then calling recordPublishedPhotoId() works just fine.
Is there a way aroudn this? I still want the "someKey" custom metadata to trigger a republish when the user changes it via the Lightroom UI, however I don't want the republish to happen when the actual plugin is changing it via photo:setPropertyForPlugin() inside the processRenderedPhotos() method.
After setting the property and returning from the catalog-with-do method, reset the modified-for-republish flag to what it was before, or what you want it to be (hint: publishedPhoto:setEditedFlag( desiredValue ). Note: you'll have to go back into another catalog-with-do method.
This multi-stage catalog updating became so common in my code that I built it into a single multi-phased catalog-access-wrapper method - maybe that was overkill, but food for thought...
That makes sense, thank you. Did not spot the setEditedFlag() method inside the LrPublishedPhoto class. I've tried to do it your way and it seems to work, the only annoying thing is the UI refresh: when a new photo is added to a published collection and the user presses "Publish", 1st the image is uploaded to the remote service, then the metadata is set based on the service reply: this cause the image to go into the "modified photos for re-publish" queue for a tiny bit, until the other catalog-with-do method kicks in and sets the flag back to false.
Before reading your reply, I fixed this by using exportContext.publishedCollection:addPhotoByRemoteId() called from the 1st (and only, in this case) catalog-with-do method. In the documentation it states that if the photo is already published, it will just update the remoteId property, but actually it's also setting the edited flag to false. This causes no jumping of the image inside the "modified photos for re-publish" queue and it makes it go straight into the "published" one... however, it is a hack and not the right way of doing it
Did you try doing it (reseting edited flag) in the same with-do invocation? - there is a small chance that might work, depending on how it's coded...
I don't think I can because the writing of the catalog changes needs to happen first. According to the docs:
As of version 3.0, changes you make to the database within this call do not have immediate effect, but are written to the database upon successful completion of the callback function. This means, in general, that if you create a new item (for instance, by calling
catalog:createCollection()), you cannot retrieve information about that item until the
From what I understand, that means I cannot retrieve the published photos (LrPublishedPhoto instances) from that collection because the new photos are not actually "published" until the catalog-with-write method finishes. I've tried doing something like:
LrFunctionContext.postAsyncTaskWithContext( "wefwefwefwef", function( context )
for k,obj in pairs(exportContext.publishedCollection:getPublishedPhotos()) do
obj:setEditedFlag( false )
essentially 1) doing the upload to the service 2) setting the extra metadata returned by the service 3) calling rendition:recordPublishedPhotoId 4) getting all published photos inside the collection and marking them via setEditedFlag(false)... but it doesn't seem to work.
Edited: to make things even more complicated, I had to start an async task because publishedCollection:getPublishedPhotos() only works in an async task.
Right - my suggestion for trying would only apply if photo was already published, and even then it would be a long shot.
Yeah, however, I did eventually find a way: instead of uploading the photo to the service and setting the custom metadata right after, I'm now updating all photos from the queue and I'm storing the metadata for each image in a table variable. After finishing with the uploads and marking all the images via rendition:recordPublishedPhotoId( remoteId ) , the images end up in the "Published" section. After this I start to iterate over the table storing the metadata and within another catalog-with-write method I write the custom metadata and immediately call publishedPhoto:setEditedFlag( false )
Doing so causes the images to go directly to the "Published" section and to stay there
Thanks for helping!
Where there's a will, there's (sometimes) a way - congrats (and you're welcome).