Skip to content

Commit

Permalink
exclude packages dir by default, not needed closes #102
Browse files Browse the repository at this point in the history
  • Loading branch information
robweber committed Feb 10, 2017
1 parent 3fcc15e commit 2c634f9
Showing 1 changed file with 25 additions and 11 deletions.
36 changes: 25 additions & 11 deletions resources/lib/backup.py
Expand Up @@ -178,6 +178,7 @@ def run(self,mode=-1,progressOverride=False):
#go through each of the user selected items and write them to the backup store
if(utils.getSetting('backup_addons') == 'true'):
fileManager.addFile("-" + xbmc.translatePath('special://home/addons'))
fileManager.excludeFile(xbmc.translatePath('special://home/addons/packages'))
fileManager.walkTree(xbmc.translatePath('special://home/addons'))

fileManager.addFile("-" + xbmc.translatePath('special://home/userdata'))
Expand Down Expand Up @@ -580,7 +581,8 @@ def _createResumeBackupFile(self):

class FileManager:
not_dir = ['.zip','.xsp','.rar']

exclude_dir = []

def __init__(self,vfs):
self.vfs = vfs
self.fileArray = []
Expand All @@ -595,20 +597,22 @@ def walkTree(self,directory):

#create all the subdirs first
for aDir in dirs:
dirPath = xbmc.translatePath(directory + "/" + aDir)
dirPath = xbmc.validatePath(xbmc.translatePath(directory + "/" + aDir))
file_ext = aDir.split('.')[-1]

self.addFile("-" + dirPath)

#catch for "non directory" type files
shouldWalk = True
if(not dirPath in self.exclude_dir):

self.addFile("-" + dirPath)

#catch for "non directory" type files
shouldWalk = True

for s in file_ext:
if(s in self.not_dir):
shouldWalk = False
for s in file_ext:
if(s in self.not_dir):
shouldWalk = False

if(shouldWalk):
self.walkTree(dirPath)
if(shouldWalk):
self.walkTree(dirPath)

#copy all the files
for aFile in files:
Expand All @@ -625,6 +629,16 @@ def addFile(self,filename):
utils.log("Add File: " + filename,xbmc.LOGDEBUG)
self.fileArray.append(filename)

def excludeFile(self,filename):
try:
filename = filename.decode('UTF-8')
except UnicodeDecodeError:
filename = filename.decode('ISO-8859-2')

#write the full remote path name of this file
utils.log("Exclude File: " + filename,xbmc.LOGDEBUG)
self.exclude_dir.append(filename)

def getFiles(self):
result = self.fileArray
self.fileArray = []
Expand Down

0 comments on commit 2c634f9

Please sign in to comment.