@@ -1435,7 +1435,7 @@ function PiwigoAPI.getInfos(propertyTable)
14351435 log :info (" PiwigoAPI.getInfos - headers\n " .. utils .serialiseVar (headers ))
14361436 log :info (" PiwigoAPI.getInfos - getResponse\n " .. utils .serialiseVar (getResponse ))
14371437 LrDialogs .message (" PiwigoAPI.getInfos - Cannot get host information from Piwigo - " ..
1438- (getResponse .errorMessage or " Unknown error" ))
1438+ (getResponse .errorMessage or " Unknown error" ))
14391439 return false
14401440 end
14411441
@@ -2142,36 +2142,43 @@ function PiwigoAPI.dissociateImageFromCategory(propertyTable, imageId, categoryI
21422142 end
21432143
21442144 log :info (" PiwigoAPI.dissociateImageFromCategory - remaining categories: " .. # newCategoryIds )
2145-
2145+ callStatus . deletedImage = false
21462146 -- If image would be orphaned (no remaining categories), delete it entirely
21472147 if # newCategoryIds == 0 then
21482148 log :info (" PiwigoAPI.dissociateImageFromCategory - image would be orphaned, deleting entirely" )
2149- return PiwigoAPI .deletePhoto (propertyTable , categoryId , imageId , callStatus )
2150- end
2151-
2152- -- Update image with new categories list (replaces all associations)
2153- local categoriesStr = table.concat (newCategoryIds , " ;" )
2149+ local delcallStatus = PiwigoAPI .deletePhoto (propertyTable , categoryId , imageId , callStatus )
2150+ if delcallStatus .status then
2151+ callStatus .status = true
2152+ callStatus .statusMsg = " Image removed from category and deleted (was orphaned)"
2153+ else
2154+ callStatus .statusMsg = delcallStatus .statusMsg or " Failed to delete orphaned image"
2155+ end
21542156
2155- local params = {
2156- { name = " method" , value = " pwg.images.setInfo" },
2157- { name = " image_id" , value = tostring (imageId ) },
2158- { name = " categories" , value = categoriesStr },
2159- { name = " multiple_value_mode" , value = " replace" },
2160- { name = " pwg_token" , value = propertyTable .token }
2161- }
2157+ callStatus .deletedImage = true
2158+ else
2159+ -- Update image with new categories list (replaces all associations)
2160+ local categoriesStr = table.concat (newCategoryIds , " ;" )
2161+
2162+ local params = {
2163+ { name = " method" , value = " pwg.images.setInfo" },
2164+ { name = " image_id" , value = tostring (imageId ) },
2165+ { name = " categories" , value = categoriesStr },
2166+ { name = " multiple_value_mode" , value = " replace" },
2167+ { name = " pwg_token" , value = propertyTable .token }
2168+ }
21622169
2163- log :info (" PiwigoAPI.dissociateImageFromCategory - new categories string: " .. categoriesStr )
2170+ log :info (" PiwigoAPI.dissociateImageFromCategory - new categories string: " .. categoriesStr )
21642171
2165- local postResponse = PiwigoAPI .httpPostMultiPart (propertyTable , params )
2172+ local postResponse = PiwigoAPI .httpPostMultiPart (propertyTable , params )
21662173
2167- if postResponse .status then
2168- callStatus .status = true
2169- log :info (" PiwigoAPI.dissociateImageFromCategory - success" )
2170- else
2171- callStatus .statusMsg = postResponse .statusMsg or " Dissociation failed"
2172- log :info (" PiwigoAPI.dissociateImageFromCategory - failed: " .. callStatus .statusMsg )
2174+ if postResponse .status then
2175+ callStatus .status = true
2176+ log :info (" PiwigoAPI.dissociateImageFromCategory - success" )
2177+ else
2178+ callStatus .statusMsg = postResponse .statusMsg or " Dissociation failed"
2179+ log :info (" PiwigoAPI.dissociateImageFromCategory - failed: " .. callStatus .statusMsg )
2180+ end
21732181 end
2174-
21752182 return callStatus
21762183end
21772184
@@ -2326,10 +2333,10 @@ function PiwigoAPI.updateGallery(propertyTable, exportFilename, metaData)
23262333 end
23272334 if not (uploadSuccess ) then
23282335 if httpHeaders .error then
2329- statusDes = httpHeaders .error .name
2336+ statusDes = httpHeaders .error .name or " "
23302337 status = httpHeaders .error .errorCode
23312338 else
2332- statusDes = httpHeaders .statusDes
2339+ statusDes = httpHeaders .statusDes or " "
23332340 status = httpHeaders .status
23342341 end
23352342 LrDialogs .message (" Cannot upload - " .. metaData .fileName .. " to Piwigo - " .. status , statusDes )
@@ -2523,15 +2530,17 @@ function PiwigoAPI.deletePhoto(propertyTable, pwCatID, pwImageID, callStatus)
25232530 callStatus .status = true
25242531 callStatus .statusMsg = " "
25252532 else
2526- log :info (" PiwigoAPI.deletePhoto - propertyTable \n " .. utils .serialiseVar (utils .anonymisePropertyTable (propertyTable )))
2533+ log :info (" PiwigoAPI.deletePhoto - propertyTable \n " ..
2534+ utils .serialiseVar (utils .anonymisePropertyTable (propertyTable )))
25272535 log :info (" PiwigoAPI.deletePhoto - params \n " .. utils .serialiseVar (params ))
25282536 log :info (" PiwigoAPI.deletePhoto - httpResponse \n " .. utils .serialiseVar (httpResponse ))
25292537 log :info (" PiwigoAPI.deletePhoto - httpHeaders \n " .. utils .serialiseVar (httpHeaders ))
25302538 callStatus .status = false
25312539 callStatus .statusMsg = body .message or " "
25322540 end
25332541 else
2534- log :info (" PiwigoAPI.deletePhoto - propertyTable \n " .. utils .serialiseVar (utils .anonymisePropertyTable (propertyTable )))
2542+ log :info (" PiwigoAPI.deletePhoto - propertyTable \n " ..
2543+ utils .serialiseVar (utils .anonymisePropertyTable (propertyTable )))
25352544 log :info (" PiwigoAPI.deletePhoto - params \n " .. utils .serialiseVar (params ))
25362545 log :info (" PiwigoAPI.deletePhoto - httpResponse \n " .. utils .serialiseVar (httpResponse ))
25372546 log :info (" PiwigoAPI.deletePhoto - httpHeaders \n " .. utils .serialiseVar (httpHeaders ))
@@ -2635,7 +2644,8 @@ function PiwigoAPI.addComment(publishSettings, metaData)
26352644 -- get antispam token from image details (unique for each image)
26362645 local rtnStatus = PiwigoAPI .checkPhoto (publishSettings , metaData .remoteId )
26372646 if not rtnStatus .status then
2638- log :info (" PiwigoAPI.addComment - unanble to retrieve token\n " .. utils .serialiseVar (utils .anonymisePropertyTable (publishSettings )))
2647+ log :info (" PiwigoAPI.addComment - unanble to retrieve token\n " ..
2648+ utils .serialiseVar (utils .anonymisePropertyTable (publishSettings )))
26392649 return false
26402650 end
26412651 local imageDets = rtnStatus .imageDets
@@ -2658,11 +2668,13 @@ function PiwigoAPI.addComment(publishSettings, metaData)
26582668 return false
26592669 end
26602670 if utils .nilOrEmpty (author ) then
2661- log :info (" PiwigoAPI.addComment - missing author\n " .. utils .serialiseVar (utils .anonymisePropertyTable (publishSettings )))
2671+ log :info (" PiwigoAPI.addComment - missing author\n " ..
2672+ utils .serialiseVar (utils .anonymisePropertyTable (publishSettings )))
26622673 return false
26632674 end
26642675 if utils .nilOrEmpty (key ) then
2665- log :info (" PiwigoAPI.addComment - missing key\n " .. utils .serialiseVar (utils .anonymisePropertyTable (publishSettings )))
2676+ log :info (" PiwigoAPI.addComment - missing key\n " ..
2677+ utils .serialiseVar (utils .anonymisePropertyTable (publishSettings )))
26662678 return false
26672679 end
26682680 -- Piwigo antispam forces a delay between the key being created and used
@@ -2759,7 +2771,7 @@ function PiwigoAPI.setAlbumCover(publishService)
27592771 log :info (" publishservice" .. publishService :getName ())
27602772 local catalog = LrApplication .activeCatalog ()
27612773 local publishSettings = publishService :getPublishSettings ()
2762- log :info (" publishSettings\n " .. utils .serialiseVar (utils .anonymisePropertyTable (publishSettings )))
2774+ log :info (" publishSettings\n " .. utils .serialiseVar (utils .anonymisePropertyTable (publishSettings )))
27632775
27642776 if not publishSettings then
27652777 LrDialogs .message (" PiwigoAPI.setAlbumCover - Can't find PublishSettings for this publish collection" , " " ,
0 commit comments