From 545843e9491b9a9723d68901c8017b40b5eb447d Mon Sep 17 00:00:00 2001 From: Rob Weber Date: Fri, 1 Aug 2014 13:12:43 -0500 Subject: [PATCH] need to treat backup zips as files --- resources/lib/backup.py | 12 +++++++++--- resources/lib/vfs.py | 16 ++++++++++++++++ 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/resources/lib/backup.py b/resources/lib/backup.py index f428165..57e888c 100644 --- a/resources/lib/backup.py +++ b/resources/lib/backup.py @@ -245,7 +245,7 @@ class XbmcBackup: self.backupFiles(fileManager.getFiles(),self.xbmc_vfs, self.remote_vfs) #delete the temp zip file - self.xbmc_vfs.rmdir(xbmc.translatePath(utils.data_dir() + zip_name)) + self.xbmc_vfs.rmfile(xbmc.translatePath(utils.data_dir() + zip_name)) #remove old backups self._rotateBackups() @@ -387,7 +387,7 @@ class XbmcBackup: if(self.restore_point.split('.')[-1] == 'zip'): #delete the zip file and the extracted directory - self.xbmc_vfs.rmdir(xbmc.translatePath("special://temp/" + self.restore_point)) + self.xbmc_vfs.rmfile(xbmc.translatePath("special://temp/" + self.restore_point)) self.xbmc_vfs.rmdir(self.remote_vfs.root_path) #call update addons to refresh everything @@ -453,7 +453,13 @@ class XbmcBackup: while(remove_num < (len(dirs) - total_backups) and not self.progressBar.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] + "/") + + if(dirs[remove_num][0].split('.')[-1] == 'zip'): + #this is a file, remove it that way + self.remote_vfs.rmfile(self.remote_base_path + dirs[remove_num][0]) + else: + self.remote_vfs.rmdir(self.remote_base_path + dirs[remove_num][0] + "/") + remove_num = remove_num + 1 def _createValidationFile(self): diff --git a/resources/lib/vfs.py b/resources/lib/vfs.py index ddb4da4..fc49d9d 100644 --- a/resources/lib/vfs.py +++ b/resources/lib/vfs.py @@ -44,6 +44,9 @@ class Vfs: def rmdir(self,directory): return True + def rmfile(self,aFile): + return True + def exists(self,aFile): return True @@ -68,6 +71,9 @@ class XBMCFileSystem(Vfs): def rmdir(self,directory): return xbmcvfs.rmdir(directory,True) + def rmfile(self,aFile): + return xbmcvfs.delete(aFile) + def rename(self,aFile,newName): return xbmcvfs.rename(aFile, newName) @@ -181,6 +187,16 @@ class DropboxFileSystem(Vfs): #finally remove the root directory self.client.file_delete(directory) + + return True + else: + return False + + def rmFile(self,aFile): + aFile = self._fix_slashes(aFile) + if(self.client != None and self.exists(aFile)): + self.client.file_delete(aFile) + return True else: return False