diff options
author | Robin Krahl <me@robin-krahl.de> | 2014-11-08 18:53:29 +0100 |
---|---|---|
committer | Robin Krahl <me@robin-krahl.de> | 2014-11-08 18:53:29 +0100 |
commit | e75ab2a20d770c23e1bae8b4258640f033f4f7db (patch) | |
tree | 575f2a90c639f8d20f040cb9eb245473de181295 /mediawiki.lrdevplugin/MediaWikiExportServiceProvider.lua | |
parent | 72b25b8b434e065c9bbb5c1e1fcb4c11a7474f83 (diff) | |
download | LrMediaWiki-e75ab2a20d770c23e1bae8b4258640f033f4f7db.tar.gz LrMediaWiki-e75ab2a20d770c23e1bae8b4258640f033f4f7db.tar.bz2 |
Allow empty descriptions for reuploads
There is no need for descriptions if an existing file is overwritten.
Therefore the check and the error message are moved at a point where we
know whether it is an initial upload or a reupload.
- refactor MediaWikiInterface.uploadFile:
- add the parameter hasDescription that describes whether there is a
valid description
- return a string (error message) if there is an error
- store description status in
MediaWikiExportServiceProvider.prepareUpload
- check the return value of MediaWikiInterface.uploadFile in
MediaWikiExportServiceProvider.prepareUpload
Fix https://github.com/ireas/LrMediaWiki/issues/30
Diffstat (limited to 'mediawiki.lrdevplugin/MediaWikiExportServiceProvider.lua')
-rwxr-xr-x | mediawiki.lrdevplugin/MediaWikiExportServiceProvider.lua | 10 |
1 files changed, 5 insertions, 5 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
|