From ffc819355032db2547e9b03d07a1b800885d60b4 Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Sat, 27 Jun 2015 21:28:27 +0200 Subject: Add configuration for snapshot creation. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The creation of snapshots after the export now depends on a new setting. The snapshots now are created after the successful export instead of before any export. - move the preferences handling to MediaWikiUtils - add the ‘Snapshot creation’ setting to MediaWikiPluginInfoProvider and MediaWikiUtils - move the snapshot creation in MediaWikiExportServiceProvider.processRenderedPhotos after the successful upload - check the ‘Snapshot creation’ setting before creating the snapshot in MediaWikiExportServiceProvider.processRenderedPhotos - update the internationalization --- .../MediaWikiExportServiceProvider.lua | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'mediawiki.lrdevplugin/MediaWikiExportServiceProvider.lua') diff --git a/mediawiki.lrdevplugin/MediaWikiExportServiceProvider.lua b/mediawiki.lrdevplugin/MediaWikiExportServiceProvider.lua index accbf88..f2ddfc3 100755 --- a/mediawiki.lrdevplugin/MediaWikiExportServiceProvider.lua +++ b/mediawiki.lrdevplugin/MediaWikiExportServiceProvider.lua @@ -67,15 +67,6 @@ MediaWikiExportServiceProvider.processRenderedPhotos = function(functionContext, local photo = rendition.photo local catalog = photo.catalog - -- create new snapshot - local currentTimeStamp = LrDate.currentTime() - local currentDate = LrDate.formatShortDate(currentTimeStamp) - local currentTime = LrDate.formatShortTime(currentTimeStamp) - local snapshotTitle = LOC('$$$/LrMediaWiki/Export/Snapshot=MediaWiki export, ^1 ^2, ^3', currentDate, currentTime, exportSettings.api_path) - catalog:withWriteAccessDo('CreateDevelopSnapshot', function(context) - photo:createDevelopSnapshot(snapshotTitle, true) - end) - -- do upload to MediaWiki local descriptionEn = photo:getPropertyForPlugin(Info.LrToolkitIdentifier, 'description_en') local descriptionDe = photo:getPropertyForPlugin(Info.LrToolkitIdentifier, 'description_de') @@ -120,6 +111,17 @@ MediaWikiExportServiceProvider.processRenderedPhotos = function(functionContext, local message = MediaWikiInterface.uploadFile(pathOrMessage, fileDescription, hasDescription) if message then rendition:uploadFailed(message) + else + -- create new snapshot if the upload was successful + if MediaWikiUtils.getCreateSnapshots() then + local currentTimeStamp = LrDate.currentTime() + local currentDate = LrDate.formatShortDate(currentTimeStamp) + local currentTime = LrDate.formatShortTime(currentTimeStamp) + local snapshotTitle = LOC('$$$/LrMediaWiki/Export/Snapshot=MediaWiki export, ^1 ^2, ^3', currentDate, currentTime, exportSettings.api_path) + catalog:withWriteAccessDo('CreateDevelopSnapshot', function(context) + photo:createDevelopSnapshot(snapshotTitle, true) + end) + end end LrFileUtils.delete(pathOrMessage) else -- cgit v1.2.1