7 Replies Latest reply on Jul 14, 2015 8:08 PM by TigrouMeow

    Can’t update this collection in processRenderedPhotos

    TigrouMeow Level 1

      Hello,

       

      I am working on a Publish Service.

       

      Now I am trying to retrieve information about a certain collection within a "processRenderedPhotos" process.

      I am using catalog:getPublishedCollectionByLocalIdentifier(). However, it ends up with this error:

       

      Can’t update this collection.

      An internal error has occurred: Can't get collection information after creating collection inside the same withWriteAccessDo function

       

      I don't know why it is written "Can't update" because I am only getting a collection. Seems like it is impossible to do this within a processRenderedPhotos but why? Any way I can go around this?

       

      Thanks a lot!

        • 1. Re: Can’t update this collection in processRenderedPhotos
          johnrellis Most Valuable Participant

          Without seeing your code, I don't have any ideas why you might be getting that error.

           

          However, what information about which collection do you need? An LrExportContext object (passed to processRenderedPhotos()) has lots of information about the current LrPublishedCollection.

          • 2. Re: Can’t update this collection in processRenderedPhotos
            TigrouMeow Level 1

            Hello John,

             

            The code is long but if you have a processRenderedPhotos function somewhere, drop a call to getPublishedCollectionByLocalIdentifier() and you will see it doesn't work.

             

            I need information not only about the current LrPublishedCollection but about the parents. I also want to setRemoteId on all those. Now, I wonder, isn't it the place to set the remote ID for the collections and sets?


            I was thinking I could setRemoteID when the collections are created but what if the user does this in the train, without connection? And choose to Publish later?

            • 3. Re: Can’t update this collection in processRenderedPhotos
              johnrellis Most Valuable Participant

              exportContext.publishedCollection is the current published collection.  Does the method :getParent() work properly within processRenderedPhotos()?  And does :setRemoteId() also work in that context?

              • 4. Re: Can’t update this collection in processRenderedPhotos
                TigrouMeow Level 1

                Basically, my code is this:

                function exportServiceProvider.processRenderedPhotos( functionContext, exportContext )

                  LrDialogs.message( inspect( exportContext.publishedCollection.localIdentifier ) )

                  LrDialogs.message( inspect( exportContext.publishedCollection.getName() ) )

                  if ( 1 ) then

                    return

                  end

                end

                I can get the localIndentifier (of course) but any attempt to any function in the publishCollection fails to "An internal error has occurred: assertion failed!". getParent generates exactly the same error.

                 

                Now it seems we can't setRemoteId on the collections at all (we cannot even get them all), where am I supposed to publish those collections if the other side doesn't even know about then yet? My plan was to check with the servers if it knows about those collections first, create them there if they don't exist, and set the RemoteIds.

                 

                It seems it is not possible?

                 

                I am using LR CC (5.7.1).

                • 5. Re: Can’t update this collection in processRenderedPhotos
                  johnrellis Most Valuable Participant
                  exportContext.publishedCollection.getName()

                  You need a ":" there, not a "." -- it's such a common mistake, and LR's error message is particularly unhelpful.

                  • 6. Re: Can’t update this collection in processRenderedPhotos
                    TigrouMeow Level 1

                    I guess I forgot about this too quick. Indeed, I did the same mistake before! Anyway, here is what I finally did:

                    function getHierarchy( currentCollection, arr )

                      arr = arr or {}

                      local parent = currentCollection:getParent()

                      if parent then

                        arr = getHierarchy( parent, arr )

                      end

                      table.insert( arr, {

                        remoteId = currentCollection:getRemoteId(),

                        localId = currentCollection.localIdentifier,

                        type = ( currentCollection:type() == 'LrPublishedCollection' ) and 'collection' or 'folder',

                        name = currentCollection:getName()

                      } )

                      return arr

                    end

                     

                     

                    local hierarchy = getHierarchy( exportContext.publishedCollection )

                    catalog:withWriteAccessDo( "updateCollectionRemoteId", function()

                      local col = catalog:getPublishedCollectionByLocalIdentifier( 1596 )

                      col:setRemoteId(5)

                    end )

                     

                    The last part is only for testing, of course, but that works. This whole code is in the processRenderedPhotos. It works fine! Thanks a lot for your help! If you have any thoughts about my getHierarchy function, feel free...

                    • 7. Re: Can’t update this collection in processRenderedPhotos
                      TigrouMeow Level 1

                      Another thing. Realized that the catalog:getPublishedCollectionByLocalIdentifier() argument must absolutely be an integer. If it is a string, then the "Can't get collection information after creating collection inside the same withWriteAccessDo function" appears. That's not really a helpful message, haha.