Skip to main content
Inspiring
June 16, 2010
Question

Accecc violation

  • June 16, 2010
  • 1 reply
  • 597 views

Hi,

currently, I try to write my own publish service. Unfortunately, because LR does not support any kind of "sync" (there are already several 1000 of photos uploaded) I'm trying to write such a sync service. In principle it works fine. How does it work: In the publishing manager is a button sync. when pressing a connection to my server is beeing established and all photo-filenames (folderwise) will be returned. Now LR will try to find these files in the catalog. If found, then the photo will be added to the pubCollection.

So far so good - and in principle it works. BUT: when the sync process is finished and I close the publishing manager, LR crashes with an access vialoation (VISTA all updates). Beside of this crash behaviour it doesn't happen in any case. Sometimes LR keeps alive and sometimes it crashes. So I assume it is a LR3 problem, or did I something wrong???

Please see below my code fragments:

function publishServiceExtention.getImages( publishService )
local catalog = import 'LrApplication'.activeCatalog()

LrTasks.startAsyncTask( function()
  local collections = publishService:getChildCollections()

  catalog:withWriteAccessDo('sync', function()
     
   for i, collection in pairs (collections) do
    collection:removeAllPhotos()
    folder = trim(string.match(collection:getName(), "%d%d%d%d.%d%d.%d%d."))

    local images = MyAPI.getImagesFromFolder(folder)

    for i, image in pairs ( images ) do
     image = trim(Utils.getFilenameNoExt(image))
    
     photos = catalog:findPhotos {
      searchDesc = {
        criteria = 'filename',
        operation = 'any',
        value = image,
      },
     }

     for k, photo in ipairs( photos ) do
      info("add to collection: " .. photo:getFormattedMetadata( 'fileName' ))    
      photoinfo = MyAPI.getImageInfo(image)
      collection:addPhotoByRemoteId( photo, photoinfo['id'], photoinfo['url'], true )
     end
    end
   end

  end)
end)

end

Does anybody has an idea whether it is a problem of my code and how to fix it or is it a problem of LR.

Thanks,

Lars

This topic has been closed for replies.

1 reply

areohbee
Legend
June 28, 2010

Lars,

Thank you - its entirely possible that this  has something to do with the mysterious crashing my plugins have been  experiencing when operating for extended periods.

I  will check and report...

PS - Worthy of a double-posting, me-thinks!

Rob