Skip to content

Commit

Permalink
added dict key to designate files instead of '-' sign
Browse files Browse the repository at this point in the history
  • Loading branch information
robweber committed Jan 24, 2024
1 parent 76a6aa3 commit 780f0f8
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions resources/lib/backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,9 +414,9 @@ def _copyFiles(self, fileList, source, dest):
if(utils.getSettingBool('verbose_logging')):
utils.log('Writing file: ' + aFile['file'])

if(aFile['file'].startswith("-")):
if(aFile['is_dir']):
self._updateProgress('%s remaining\nwriting %s' % (utils.diskString(self.transferLeft), os.path.basename(aFile['file'][len(source.root_path):]) + "/"))
dest.mkdir(dest.root_path + aFile['file'][len(source.root_path) + 1:])
dest.mkdir(dest.root_path + aFile['file'][len(source.root_path):])
else:
self._updateProgress('%s remaining\nwriting %s' % (utils.diskString(self.transferLeft), os.path.basename(aFile['file'][len(source.root_path):])))
self.transferLeft = self.transferLeft - aFile['size']
Expand All @@ -426,6 +426,7 @@ def _copyFiles(self, fileList, source, dest):

# if result is still true but this file failed
if(not wroteFile and result):
utils.log("Failed to write " + aFile['file'])
result = False

return result
Expand Down Expand Up @@ -583,7 +584,7 @@ def __init__(self, vfs):
def walk(self):

for aDir in self.root_dirs:
self.addFile('-' + xbmcvfs.translatePath(aDir['path']))
self.addFile(xbmcvfs.translatePath(aDir['path']), True)
self.walkTree(xbmcvfs.translatePath(aDir['path']), aDir['recurse'])

def walkTree(self, directory, recurse=True):
Expand All @@ -605,7 +606,7 @@ def walkTree(self, directory, recurse=True):
# check if directory is excluded
if(not any(dirPath.startswith(exDir) for exDir in self.exclude_dir)):

self.addFile("-" + dirPath)
self.addFile(dirPath, True)

# catch for "non directory" type files
shouldWalk = True
Expand All @@ -628,7 +629,7 @@ def addDir(self, dirMeta):
else:
self.excludeFile(xbmcvfs.translatePath(dirMeta['path']))

def addFile(self, filename):
def addFile(self, filename, is_dir = False):
# write the full remote path name of this file
if(utils.getSettingBool('verbose_logging')):
utils.log("Add File: " + filename)
Expand All @@ -637,7 +638,7 @@ def addFile(self, filename):
fSize = self.vfs.fileSize(filename)
self.totalSize = self.totalSize + fSize

self.fileArray.append({'file': filename, 'size': fSize})
self.fileArray.append({'file': filename, 'size': fSize, 'is_dir': is_dir})

def excludeFile(self, filename):
# remove trailing slash
Expand Down

0 comments on commit 780f0f8

Please sign in to comment.