diff options
| -rwxr-xr-x | mediawiki.lrdevplugin/MediaWikiExportServiceProvider.lua | 10 | ||||
| -rwxr-xr-x | mediawiki.lrdevplugin/MediaWikiInterface.lua | 11 | 
2 files changed, 13 insertions, 8 deletions
diff --git a/mediawiki.lrdevplugin/MediaWikiExportServiceProvider.lua b/mediawiki.lrdevplugin/MediaWikiExportServiceProvider.lua index b668918..edbcb5f 100755 --- a/mediawiki.lrdevplugin/MediaWikiExportServiceProvider.lua +++ b/mediawiki.lrdevplugin/MediaWikiExportServiceProvider.lua @@ -90,10 +90,7 @@ MediaWikiExportServiceProvider.processRenderedPhotos = function(functionContext,  			if not MediaWikiUtils.isStringEmpty(descriptionAdditional) then
  				description = description .. descriptionAdditional
  			end
 -			if MediaWikiUtils.isStringEmpty(description) then
 -				rendition:uploadFailed(LOC '$$$/LrMediaWiki/Export/NoDescription=No description given for this file!')
 -				return
 -			end
 +			local hasDescription = not MediaWikiUtils.isStringEmpty(description)
  			local source = exportSettings.info_source
  			local timestampSeconds = photo:getRawMetadata('dateTimeOriginal')
  			local timestamp = ''
 @@ -120,7 +117,10 @@ MediaWikiExportServiceProvider.processRenderedPhotos = function(functionContext,  			local fileDescription = MediaWikiInterface.buildFileDescription(description, source, timestamp, author, license, templates, other, categories, additionalCategories, permission)
 -			MediaWikiInterface.uploadFile(pathOrMessage, fileDescription)
 +			local message = MediaWikiInterface.uploadFile(pathOrMessage, fileDescription, hasDescription)
 +			if message then
 +				rendition:uploadFailed(message)
 +			end
  			LrFileUtils.delete(pathOrMessage)
  		else
  			-- rendering failed --> report failure
 diff --git a/mediawiki.lrdevplugin/MediaWikiInterface.lua b/mediawiki.lrdevplugin/MediaWikiInterface.lua index 2473406..5c68c1b 100755 --- a/mediawiki.lrdevplugin/MediaWikiInterface.lua +++ b/mediawiki.lrdevplugin/MediaWikiInterface.lua @@ -101,7 +101,7 @@ MediaWikiInterface._prompt = function(functionContext, title, label, default)  	return result
  end
 -MediaWikiInterface.uploadFile = function(filePath, description, fileName)
 +MediaWikiInterface.uploadFile = function(filePath, description, hasDescription, fileName)
  	if not MediaWikiInterface.loggedIn then
  		LrErrors.throwUserError(LOC '$$$/LrMediaWiki/Interface/Internal/NotLoggedIn=Internal error: not logged in before upload.')
  	end
 @@ -119,17 +119,22 @@ MediaWikiInterface.uploadFile = function(filePath, description, fileName)  		elseif continue == 'other' then
  			local newFileName = MediaWikiInterface.prompt(LOC '$$$/LrMediaWiki/Interface/Rename=Rename file', LOC '$$$/LrMediaWiki/Interface/Rename/NewName=New file name', targetFileName)
  			if not MediaWikiUtils.isStringEmpty(newFileName) and newFileName ~= targetFileName then
 -				MediaWikiInterface.uploadFile(filePath, description, newFileName)
 +				MediaWikiInterface.uploadFile(filePath, description, hasDescription, newFileName)
  			end
  			return
  		else
  			return
  		end
 +	else
 +		if not hasDescription then
 +			return LOC '$$$/LrMediaWiki/Export/NoDescription=No description given for this file!'
 +		end
  	end
  	local uploadResult = MediaWikiApi.upload(targetFileName, filePath, description, comment, ignorewarnings)
  	if uploadResult ~= true then
 -		LrErrors.throwUserError(LOC('$$$/LrMediaWiki/Interface/UploadFailed=Upload failed: ^1', uploadResult))
 +		return LOC('$$$/LrMediaWiki/Interface/UploadFailed=Upload failed: ^1', uploadResult)
  	end
 +	return nil
  end
  MediaWikiInterface.buildFileDescription = function(description, source, timestamp, author, license, templates, other, categories, additionalCategories, permission)
  | 
