From 405bbc08b5fbcf097fd5aa51426a4f7da7beec17 Mon Sep 17 00:00:00 2001 From: Rob Weber Date: Sun, 9 Feb 2014 13:56:25 -0600 Subject: [PATCH 1/2] added hour and minute to backup folder names --- default.py | 8 ++++++-- resources/lib/backup.py | 36 +++++++++++++++++++++++++++--------- 2 files changed, 33 insertions(+), 11 deletions(-) diff --git a/default.py b/default.py index 723559e..b2bd2ad 100644 --- a/default.py +++ b/default.py @@ -25,11 +25,15 @@ if(mode != -1): if(mode == backup.Restore): #allow user to select the backup to restore from restorePoints = backup.listBackups() + pointNames = [] - selectedRestore = xbmcgui.Dialog().select(utils.getString(30010) + " - " + utils.getString(30021),restorePoints) + for aDir in restorePoints: + pointNames.append(aDir[1]) + + selectedRestore = xbmcgui.Dialog().select(utils.getString(30010) + " - " + utils.getString(30021),pointNames) if(selectedRestore != -1): - backup.selectRestore(restorePoints[selectedRestore]) + backup.selectRestore(restorePoints[selectedRestore][0]) backup.run(mode) else: diff --git a/resources/lib/backup.py b/resources/lib/backup.py index 1e3d45e..db0ce73 100644 --- a/resources/lib/backup.py +++ b/resources/lib/backup.py @@ -6,6 +6,15 @@ import os.path import time from vfs import XBMCFileSystem,DropboxFileSystem +def folderSort(aKey): + result = aKey[0] + + if(len(result) < 8): + result = result + "0000" + + return result + + class XbmcBackup: #constants for initiating a back or restore Backup = 0 @@ -60,8 +69,18 @@ class XbmcBackup: for aDir in dirs: if(self.remote_vfs.exists(self.remote_base_path + aDir + "/xbmcbackup.val")): - result.append(aDir) + #folder may or may not contain time, older versions didn't include this + folderName = '' + if(len(aDir) > 8): + folderName = aDir[6:8] + '-' + aDir[4:6] + '-' + aDir[0:4] + " " + aDir[8:10] + ":" + aDir[10:12] + else: + folderName = aDir[6:8] + '-' + aDir[4:6] + '-' + aDir[0:4] + + result.append((aDir,folderName)) + + result.sort(key=folderSort) + return result def selectRestore(self,restore_point): @@ -74,7 +93,7 @@ class XbmcBackup: #append backup folder name progressBarTitle = utils.getString(30010) + " - " if(mode == self.Backup and self.remote_vfs.root_path != ''): - self.remote_vfs.set_root(self.remote_vfs.root_path + time.strftime("%Y%m%d") + "/") + self.remote_vfs.set_root(self.remote_vfs.root_path + time.strftime("%Y%m%d%H%M") + "/") progressBarTitle = progressBarTitle + utils.getString(30016) elif(mode == self.Restore and self.restore_point != None and self.remote_vfs.root_path != ''): self.remote_vfs.set_root(self.remote_vfs.root_path + self.restore_point + "/") @@ -355,16 +374,15 @@ class XbmcBackup: if(len(dirs) > total_backups): #remove backups to equal total wanted - dirs.sort() - remove_num = len(dirs) - total_backups - 1 + remove_num = 0 self.filesTotal = self.filesTotal + remove_num + 1 #update the progress bar if it is available - while(remove_num >= 0 and not self._checkCancel()): - self._updateProgress(utils.getString(30054) + " " + dirs[remove_num]) - utils.log("Removing backup " + dirs[remove_num]) - self.remote_vfs.rmdir(self.remote_base_path + dirs[remove_num] + "/") - remove_num = remove_num - 1 + while(remove_num < total_backups and not self._checkCancel()): + self._updateProgress(utils.getString(30054) + " " + dirs[remove_num][1]) + utils.log("Removing backup " + dirs[remove_num][0]) + self.remote_vfs.rmdir(self.remote_base_path + dirs[remove_num][0] + "/") + remove_num = remove_num + 1 def _createValidationFile(self): vFile = xbmcvfs.File(xbmc.translatePath(utils.data_dir() + "xbmcbackup.val"),'w') From 70ced05cd51eb29b8ffe51794c64e14fbe4512e6 Mon Sep 17 00:00:00 2001 From: Rob Weber Date: Sun, 9 Feb 2014 14:02:04 -0600 Subject: [PATCH 2/2] version bump --- addon.xml | 2 +- changelog.txt | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/addon.xml b/addon.xml index da1695d..6258c19 100644 --- a/addon.xml +++ b/addon.xml @@ -1,6 +1,6 @@  + name="XBMC Backup" version="0.4.6" provider-name="robweber"> diff --git a/changelog.txt b/changelog.txt index 3becb42..04a6c65 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,7 @@ +Version 0.4.6 + +modified backup folder names to include time, also modified display listing + Version 0.4.5 added version info to logs