copy zip file and open in write mode

This commit is contained in:
Rob Weber 2014-07-31 17:29:59 -05:00
parent c49aebeba1
commit 933fdbdf09
2 changed files with 18 additions and 8 deletions

View File

@ -117,7 +117,7 @@ class XbmcBackup:
if(utils.getSetting("compress_backups") == 'true'): if(utils.getSetting("compress_backups") == 'true'):
#save the remote file system and use the zip vfs #save the remote file system and use the zip vfs
self.saved_remote_vfs = self.remote_vfs self.saved_remote_vfs = self.remote_vfs
self.remote_vfs = ZipFileSystem("","w") self.remote_vfs = ZipFileSystem(xbmc.translatePath(utils.data_dir() + "xbmc_backup_temp.zip"),"w")
self.remote_vfs.set_root(self.remote_vfs.root_path + time.strftime("%Y%m%d%H%M") + "/") self.remote_vfs.set_root(self.remote_vfs.root_path + time.strftime("%Y%m%d%H%M") + "/")
progressBarTitle = progressBarTitle + utils.getString(30016) progressBarTitle = progressBarTitle + utils.getString(30016)
@ -256,12 +256,22 @@ class XbmcBackup:
#catch for if the restore point is actually a zip file #catch for if the restore point is actually a zip file
if(self.restore_point.split('.')[-1] == 'zip'): if(self.restore_point.split('.')[-1] == 'zip'):
#copy just this file from the remote vfs #copy just this file from the remote vfs
pass zipFile = []
zipFile.append(self.restore_point)
#for restores remote path must exist #set root to data dir home
if(not self.remote_vfs.exists(self.remote_vfs.root_path)): self.xbmc_vfs.set_root(xbmc.translatePath(utils.data_dir()))
xbmcgui.Dialog().ok(utils.getString(30010),utils.getString(30045),self.remote_vfs.root_path)
return self.progressBar.updateProgress(0, "Copying Zip Archive")
self.backupFiles(zipFile,self.remote_vfs, self.xbmc_vfs)
#set the new remote vfs
self.remote_vfs = ZipFileSystem(xbmc.translatePath(utils.data_dir() + self.restore_point),'r')
else:
#for restores remote path must exist
if(not self.remote_vfs.exists(self.remote_vfs.root_path)):
xbmcgui.Dialog().ok(utils.getString(30010),utils.getString(30045),self.remote_vfs.root_path)
return
if(not self._checkValidationFile(self.remote_vfs.root_path)): if(not self._checkValidationFile(self.remote_vfs.root_path)):
#don't continue #don't continue

View File

@ -78,7 +78,7 @@ class ZipFileSystem(Vfs):
def __init__(self,rootString,mode): def __init__(self,rootString,mode):
self.root_path = "" self.root_path = ""
self.zip = zipfile.ZipFile(xbmc.translatePath(utils.data_dir() + "xbmc_backup_temp.zip"),mode=mode) self.zip = zipfile.ZipFile(rootString,mode=mode)
def listdir(self,directory): def listdir(self,directory):