@@ -38,7 +38,8 @@ function PublishTask.processRenderedPhotos(functionContext, exportContext)
3838 local publishService = publishedCollection :getService ()
3939 local rv
4040 if not publishService then
41- log :info (' PublishTask.processRenderedPhotos - publishSettings:\n ' .. utils .serialiseVar (propertyTable ))
41+ log :info (' PublishTask.processRenderedPhotos - propertyTable:\n ' ..
42+ utils .serialiseVar (utils .anonymisePropertyTable (propertyTable )))
4243 LrErrors .throwUserError (' Publish photos to Piwigo - cannot connect find publishService' )
4344 return nil
4445 end
@@ -77,7 +78,8 @@ function PublishTask.processRenderedPhotos(functionContext, exportContext)
7778 if not (propertyTable .Connected ) then
7879 rv = PiwigoAPI .login (propertyTable )
7980 if not rv then
80- log :info (' PublishTask.processRenderedPhotos - publishSettings:\n ' .. utils .serialiseVar (propertyTable ))
81+ log :info (' PublishTask.processRenderedPhotos - propertyTable:\n ' ..
82+ utils .serialiseVar (utils .anonymisePropertyTable (propertyTable )))
8183 PWStatusManager .setPiwigoBusy (publishService , false )
8284 LrErrors .throwUserError (' Publish photos to Piwigo - cannot connect to piwigo at ' .. propertyTable .host )
8385 return nil
@@ -264,8 +266,6 @@ function PublishTask.processRenderedPhotos(functionContext, exportContext)
264266 end
265267
266268 -- store / update custom metadata
267-
268-
269269 PiwigoAPI .storeMetaData (catalog , lrPhoto , pluginData )
270270
271271 -- photo was uploaded with keywords included, but existing keywords aren't replaced by this process,
@@ -285,13 +285,36 @@ function PublishTask.processRenderedPhotos(functionContext, exportContext)
285285 LrDialogs .message (" Unable to set metadata for uploaded photo - " .. callStatus .statusMsg )
286286 end
287287 else
288- log :info (" Upload failed for photo " .. lrPhoto :getFormattedMetadata (" fileName" ))
289- log :info (" Upload failed - renditionSettings\n " .. utils .serialiseVar (renditionParams ))
290- log :info (" Upload failed - metaData\n " .. utils .serialiseVar (metaData ))
291- log :info (" Upload failed - propertyTable\n " .. utils .serialiseVar (propertyTable ))
288+ local sourcePhotoName = lrPhoto :getFormattedMetadata (" fileName" )
289+ local anonymiseRenditionParams = utils .anonymiseRenditionParams (renditionParams )
290+ local expRenditionParams = utils .serialiseVar (anonymiseRenditionParams )
291+ local expMetaData = utils .serialiseVar (metaData )
292+ log :info (" Upload failed for photo: " .. sourcePhotoName )
293+ log :info (" Upload failed - renditionParams\n " .. expRenditionParams )
294+ log :info (" Upload failed - metaData\n " .. expMetaData )
295+ log :info (" Upload failed - propertyTable\n " .. utils .serialiseVar (utils .anonymisePropertyTable (propertyTable )))
292296 log :info (" Upload failed - callStatus\n " .. utils .serialiseVar (callStatus ))
293297 log :info (" Upload failed - pathOrMessage\n " .. tostring (pathOrMessage ))
294298
299+ local debugDir = LrPathUtils .child (LrPathUtils .getStandardFilePath (' desktop' ),
300+ " PiwigoPublishDebugIssue17" )
301+ LrFileUtils .createAllDirectories (debugDir )
302+ local leafName = LrPathUtils .leafName (pathOrMessage )
303+ local debugPath = LrPathUtils .child (debugDir , leafName )
304+ LrFileUtils .copy (pathOrMessage , debugPath )
305+
306+ local debugFileName = debugPath .. " _debug.txt"
307+ local debugFile = io.open (debugFileName , " w" )
308+ debugFile :write (" Upload failed for photo: " .. sourcePhotoName .. " \n " )
309+ debugFile :write (" Rendition params:\n " .. expRenditionParams .. " \n " )
310+ debugFile :write (" Metadata:\n " .. expMetaData .. " \n " )
311+ debugFile :write (" PropertyTable:\n " .. utils .serialiseVar (utils .anonymisePropertyTable (propertyTable )) .. " \n " )
312+ debugFile :write (" CallStatus:\n " .. utils .serialiseVar (callStatus ) .. " \n " )
313+ debugFile :write (" PathOrMessage:\n " .. tostring (pathOrMessage ) .. " \n " )
314+ debugFile :close ()
315+
316+ log :warn (" DEBUG: preserved failed upload file to " .. debugPath )
317+
295318 rendition :uploadFailed (callStatus .message or " Upload failed" )
296319 end
297320
@@ -377,7 +400,7 @@ function PublishTask.deletePhotosFromPublishedCollection(publishSettings, arrayO
377400 local publishedPhotos = publishedCollection :getPublishedPhotos ()
378401 local publishService = publishedCollection :getService ()
379402 if not publishService then
380- log :info (' deletePhotosFromPublishedCollection - publishSettings:\n ' .. utils .serialiseVar (publishSettings ))
403+ log :info (' deletePhotosFromPublishedCollection - publishSettings:\n ' .. utils .serialiseVar (utils . anonymisePropertyTable ( publishSettings ) ))
381404 LrErrors .throwUserError (' Publish photos to Piwigo - cannot connect find publishService' )
382405 return nil
383406 end
@@ -494,7 +517,7 @@ function PublishTask.getCommentsFromPublishedCollection(publishSettings, arrayOf
494517 local rv , publishService = PiwigoAPI .getPublishService (publishSettings )
495518 if not (publishService ) or not (rv ) then
496519 log :info (' PublishTask.getCommentsFromPublishedCollection - publishSettings:\n ' ..
497- utils .serialiseVar (publishSettings ))
520+ utils .serialiseVar (utils . anonymisePropertyTable ( publishSettings ) ))
498521 LrErrors .throwUserError (' PublishTask.getCommentsFromPublishedCollection - cannot find publishService' )
499522 return nil
500523 end
@@ -956,7 +979,7 @@ function PublishTask.updateCollectionSettings(publishSettings, info)
956979
957980
958981 if not publishService then
959- log :info (' updateCollectionSettings - publishSettings:\n ' .. utils .serialiseVar (publishSettings ))
982+ log :info (' updateCollectionSettings - publishSettings:\n ' .. utils .serialiseVar (utils . anonymisePropertyTable ( publishSettings ) ))
960983 LrErrors .throwUserError (' updateCollectionSettings - cannot connect find publishService' )
961984 return nil
962985 end
@@ -1167,7 +1190,7 @@ function PublishTask.updateCollectionSetSettings(publishSettings, info)
11671190 local publishService = info .publishService
11681191
11691192 if not publishService then
1170- log :info (' updateCollectionSettings - publishSettings:\n ' .. utils .serialiseVar (publishSettings ))
1193+ log :info (' updateCollectionSettings - publishSettings:\n ' .. utils .serialiseVar (utils . anonymisePropertyTable ( publishSettings ) ))
11711194 LrErrors .throwUserError (' updateCollectionSettings - cannot connect find publishService' )
11721195 return nil
11731196 end
@@ -1264,7 +1287,7 @@ function PublishTask.reparentPublishedCollection(publishSettings, info)
12641287
12651288 local publishService = info .publishService
12661289 if not publishService then
1267- log :info (' reparentPublishedCollection - publishSettings:\n ' .. utils .serialiseVar (publishSettings ))
1290+ log :info (' reparentPublishedCollection - publishSettings:\n ' .. utils .serialiseVar (utils . anonymisePropertyTable ( publishSettings ) ))
12681291 LrErrors .throwUserError (' reparentPublishedCollection - cannot connect find publishService' )
12691292 return nil
12701293 end
@@ -1316,7 +1339,7 @@ function PublishTask.renamePublishedCollection(publishSettings, info)
13161339 -- called for both collections and collectionsets
13171340 local publishService = info .publishService
13181341 if not publishService then
1319- log :info (' renamePublishedCollection - publishSettings:\n ' .. utils .serialiseVar (publishSettings ))
1342+ log :info (' renamePublishedCollection - publishSettings:\n ' .. utils .serialiseVar (utils . anonymisePropertyTable ( publishSettings ) ))
13201343 LrErrors .throwUserError (' renamePublishedCollection - cannot connect find publishService' )
13211344 return nil
13221345 end
@@ -1398,7 +1421,7 @@ function PublishTask.deletePublishedCollection(publishSettings, info)
13981421 local publishService = info .publishService
13991422 local publishCollection = info .publishedCollection
14001423 if not publishService then
1401- log :info (' deletePublishedCollection - publishSettings:\n ' .. utils .serialiseVar (publishSettings ))
1424+ log :info (' deletePublishedCollection - publishSettings:\n ' .. utils .serialiseVar (utils . anonymisePropertyTable ( publishSettings ) ))
14021425 LrErrors .throwUserError (' deletePublishedCollection - cannot connect find publishService' )
14031426 return nil
14041427 end
0 commit comments