allow user to choose restore point

This commit is contained in:
Rob Weber 2012-11-28 10:19:03 -06:00
parent 16e55bdd23
commit 042ed51ef3
2 changed files with 29 additions and 2 deletions

View File

@ -8,4 +8,14 @@ mode = xbmcgui.Dialog().select(utils.getString(30010) + " - " + utils.getString(
if(mode != -1): if(mode != -1):
#run the profile backup #run the profile backup
backup = XbmcBackup() backup = XbmcBackup()
if(mode == backup.Restore):
#allow user to select the backup to restore from
restorePoints = backup.listBackups()
selectedRestore = xbmcgui.Dialog().select(utils.getString(30010) + " - " + utils.getString(30021),restorePoints)
if(selectedRestore != -1):
backup.selectRestore(restorePoints[selectedRestore])
backup.run(mode) backup.run(mode)

View File

@ -99,6 +99,7 @@ class XbmcBackup:
filesTotal = 1 filesTotal = 1
fileManager = None fileManager = None
restore_point = None
def __init__(self): def __init__(self):
self.local_vfs = XBMCFileSystem() self.local_vfs = XBMCFileSystem()
@ -120,6 +121,20 @@ class XbmcBackup:
self.remote_vfs = DropboxFileSystem() self.remote_vfs = DropboxFileSystem()
self.remote_vfs.set_root('/') self.remote_vfs.set_root('/')
def listBackups(self):
result = list()
#get all the folders in the current root path
dirs,files = self.remote_vfs.listdir(self.remote_vfs.root_path)
for aDir in dirs:
result.append(aDir)
return result
def selectRestore(self,restore_point):
self.restore_point = restore_point
def run(self,mode=-1,runSilent=False): def run(self,mode=-1,runSilent=False):
#append backup folder name #append backup folder name
@ -129,11 +144,13 @@ class XbmcBackup:
#capture base path for backup rotation #capture base path for backup rotation
remote_base_path = self.remote_vfs.set_root(self.remote_vfs.root_path + time.strftime("%Y%m%d") + "/") remote_base_path = self.remote_vfs.set_root(self.remote_vfs.root_path + time.strftime("%Y%m%d") + "/")
progressBarTitle = progressBarTitle + utils.getString(30016) progressBarTitle = progressBarTitle + utils.getString(30016)
elif(mode == self.Restore and utils.getSetting("backup_name") != '' and self.remote_vfs.root_path != ''): 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 + utils.getSetting("backup_name") + "/") self.remote_vfs.set_root(self.remote_vfs.root_path + self.restore_point + "/")
progressBarTitle = progressBarTitle + utils.getString(30017) progressBarTitle = progressBarTitle + utils.getString(30017)
else: else:
#kill the program here
self.remote_vfs = None self.remote_vfs = None
return
utils.log(utils.getString(30047) + ": " + self.local_vfs.root_path) utils.log(utils.getString(30047) + ": " + self.local_vfs.root_path)
utils.log(utils.getString(30048) + ": " + self.remote_vfs.root_path) utils.log(utils.getString(30048) + ": " + self.remote_vfs.root_path)