need to reset vfs to default root dirs before copying zip

This commit is contained in:
Rob Weber 2014-08-01 13:54:22 -05:00
parent 5dfa9d9b76
commit b3bbdd6911

View File

@ -68,7 +68,7 @@ class XbmcBackup:
#get all the folders in the current root path #get all the folders in the current root path
dirs,files = self.remote_vfs.listdir(self.remote_base_path) dirs,files = self.remote_vfs.listdir(self.remote_base_path)
for aDir in dirs: for aDir in dirs:
if(self.remote_vfs.exists(self.remote_base_path + aDir + "/xbmcbackup.val")): if(self.remote_vfs.exists(self.remote_base_path + aDir + "/xbmcbackup.val")):
@ -199,6 +199,8 @@ class XbmcBackup:
self.filesTotal = fileManager.size() self.filesTotal = fileManager.size()
allFiles.append({"source":self.xbmc_vfs.root_path,"dest":self.remote_vfs.root_path,"files":fileManager.getFiles()}) allFiles.append({"source":self.xbmc_vfs.root_path,"dest":self.remote_vfs.root_path,"files":fileManager.getFiles()})
orig_base_path = self.remote_vfs.root_path
#check if there are custom directories #check if there are custom directories
if(utils.getSetting('custom_dir_1_enable') == 'true' and utils.getSetting('backup_custom_dir_1') != ''): if(utils.getSetting('custom_dir_1_enable') == 'true' and utils.getSetting('backup_custom_dir_1') != ''):
@ -229,6 +231,10 @@ class XbmcBackup:
self.xbmc_vfs.set_root(fileGroup['source']) self.xbmc_vfs.set_root(fileGroup['source'])
self.remote_vfs.set_root(fileGroup['dest']) self.remote_vfs.set_root(fileGroup['dest'])
self.backupFiles(fileGroup['files'],self.xbmc_vfs,self.remote_vfs) self.backupFiles(fileGroup['files'],self.xbmc_vfs,self.remote_vfs)
#reset remote and xbmc vfs
self.xbmc_vfs.set_root(xbmc.translatePath("special://home"))
self.remote_vfs.set_root(orig_base_path)
if(utils.getSetting("compress_backups") == 'true'): if(utils.getSetting("compress_backups") == 'true'):
#send the zip file to the real remote vfs #send the zip file to the real remote vfs
@ -241,7 +247,7 @@ class XbmcBackup:
self.xbmc_vfs.set_root(xbmc.translatePath("special://temp/")) self.xbmc_vfs.set_root(xbmc.translatePath("special://temp/"))
self.remote_vfs = self.saved_remote_vfs self.remote_vfs = self.saved_remote_vfs
self.progressBar.updateProgress(0, "Copying Zip Archive") self.progressBar.updateProgress(98, "Copying Zip Archive")
self.backupFiles(fileManager.getFiles(),self.xbmc_vfs, self.remote_vfs) self.backupFiles(fileManager.getFiles(),self.xbmc_vfs, self.remote_vfs)
#delete the temp zip file #delete the temp zip file
@ -269,13 +275,14 @@ class XbmcBackup:
self.backupFiles(zipFile,self.remote_vfs, self.xbmc_vfs) self.backupFiles(zipFile,self.remote_vfs, self.xbmc_vfs)
else: else:
utils.log("zip file exists already") utils.log("zip file exists already")
#extract the zip file #extract the zip file
zip_vfs = ZipFileSystem(xbmc.translatePath("special://temp/"+ self.restore_point),'r') zip_vfs = ZipFileSystem(xbmc.translatePath("special://temp/"+ self.restore_point),'r')
zip_vfs.extract(xbmc.translatePath("special://temp/")) zip_vfs.extract(xbmc.translatePath("special://temp/"))
#set the new remote vfs #set the new remote vfs and fix xbmc path
self.remote_vfs = XBMCFileSystem(xbmc.translatePath("special://temp/" + self.restore_point.split(".")[0] + "/")) self.remote_vfs = XBMCFileSystem(xbmc.translatePath("special://temp/" + self.restore_point.split(".")[0] + "/"))
self.xbmc_vfs.set_root(xbmc.translatePath("special://home"))
#for restores remote path must exist #for restores remote path must exist