From 23b70af3dc4b20263698e41e4c84ea716f848fca Mon Sep 17 00:00:00 2001 From: "robweberjr@gmail.com" Date: Tue, 6 May 2014 13:44:00 -0500 Subject: [PATCH] closes #51 --- addon.xml | 2 +- changelog.txt | 4 ++++ resources/language/English/strings.xml | 2 ++ resources/lib/backup.py | 32 +++++++++++++++++++++++++- 4 files changed, 38 insertions(+), 2 deletions(-) diff --git a/addon.xml b/addon.xml index d42e12f..898930d 100644 --- a/addon.xml +++ b/addon.xml @@ -1,6 +1,6 @@  + name="XBMC Backup" version="0.5.4" provider-name="robweber"> diff --git a/changelog.txt b/changelog.txt index 71f0636..f6a17bc 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,7 @@ +Version 0.5.4 + +check xbmc version when doing a restore + Version 0.5.3 updated python version diff --git a/resources/language/English/strings.xml b/resources/language/English/strings.xml index 979df3c..db98316 100644 --- a/resources/language/English/strings.xml +++ b/resources/language/English/strings.xml @@ -76,4 +76,6 @@ Progress Bar Background Progress Bar None (Silent) + Version Warning + This version of XBMC is different than the one used to create the archive diff --git a/resources/lib/backup.py b/resources/lib/backup.py index 4e1bbba..29a2d9d 100644 --- a/resources/lib/backup.py +++ b/resources/lib/backup.py @@ -4,6 +4,7 @@ import xbmcvfs import utils as utils import os.path import time +import json from vfs import XBMCFileSystem,DropboxFileSystem def folderSort(aKey): @@ -218,6 +219,10 @@ class XbmcBackup: xbmcgui.Dialog().ok(utils.getString(30010),utils.getString(30045),self.remote_vfs.root_path) return + if(not self._checkValidationFile(self.remote_vfs.root_path)): + #don't continue + return + utils.log(utils.getString(30051)) allFiles = [] fileManager = FileManager(self.remote_vfs) @@ -382,11 +387,36 @@ class XbmcBackup: def _createValidationFile(self): vFile = xbmcvfs.File(xbmc.translatePath(utils.data_dir() + "xbmcbackup.val"),'w') - vFile.write("XBMC Backup Validation File") + vFile.write(json.dumps({"name":"XBMC Backup Validation File","xbmc_version":xbmc.getInfoLabel('System.BuildVersion')})) + vFile.write("") vFile.close() self.remote_vfs.put(xbmc.translatePath(utils.data_dir() + "xbmcbackup.val"),self.remote_vfs.root_path + "xbmcbackup.val") + def _checkValidationFile(self,path): + result = False + + #copy the file and open it + self.xbmc_vfs.put(path + "xbmcbackup.val",xbmc.translatePath(utils.data_dir() + "xbmcbackup.val")) + + vFile = xbmcvfs.File(xbmc.translatePath(utils.data_dir() + "xbmcbackup.val"),'r') + jsonString = vFile.read() + vFile.close() + + try: + json_dict = json.loads(jsonString) + + if(xbmc.getInfoLabel('System.BuildVersion') == json_dict['xbmc_version']): + result = True + else: + result = xbmcgui.Dialog().yesno(utils.getString(30085),utils.getString(30086),utils.getString(30044)) + + except ValueError: + #may fail on older archives + result = True + + return result + def _createResumeBackupFile(self): rFile = xbmcvfs.File(xbmc.translatePath(utils.data_dir() + "resume.txt"),'w') rFile.write(self.restore_point)