removed file handle and restore.txt file. now the filenames are written to a list in memory

This commit is contained in:
Rob Weber 2012-05-21 21:12:37 -05:00
parent 0081169d11
commit bc9cc7d345
3 changed files with 15 additions and 17 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="script.xbmcbackup"
name="XBMC Backup" version="0.0.6" provider-name="robweber">
name="XBMC Backup" version="0.0.7" provider-name="robweber">
<requires>
<import addon="xbmc.python" version="2.0"/>
</requires>

View File

@ -15,7 +15,11 @@ Finished code for restore mode.
Added option to manually type a path rather than browse for one (only one used)
Show progress bar right away so you know this is doing something
[b]Version 0.0.6/b]
[b]Version 0.0.6[/b]
Added the vfs module created by paddycarey
File Selection is now followed for both backup and restore options
[b]Version 0.0.7[/b]
removed "restore.txt" file and now write file listing to memory list instead

View File

@ -7,7 +7,7 @@ import os
class FileManager:
walk_path = ''
addonDir = ''
fHandle = None
fileArray = None
def __init__(self,path,addon_dir):
self.walk_path = path
@ -18,7 +18,7 @@ class FileManager:
os.makedirs(unicode(xbmc.translatePath(self.addonDir),'utf-8'))
def createFileList(self,Addon):
self.fHandle = open(unicode(xbmc.translatePath(self.addonDir + "restore.txt"),'utf-8'),"w")
self.fileArray = []
#figure out which syncing options to run
if(Addon.getSetting('backup_addons') == 'true'):
@ -50,9 +50,6 @@ class FileManager:
if(aFile.endswith(".xml")):
self.addFile("userdata/" + aFile)
if(self.fHandle != None):
self.fHandle.close()
def walkTree(self,directory):
for (path, dirs, files) in vfs.walk(directory):
@ -66,13 +63,10 @@ class FileManager:
def addFile(self,filename):
#write the full remote path name of this file
if(self.fHandle != None):
self.fHandle.write(str(filename) + "\n")
self.fileArray.append(filename)
def readFileList(self):
allFiles = open(unicode(xbmc.translatePath(self.addonDir + "restore.txt"),'utf-8'),"r").read().splitlines()
return allFiles
def getFileList(self):
return self.fileArray
class XbmcBackup:
__addon_id__ = 'script.xbmcbackup'
@ -131,7 +125,7 @@ class XbmcBackup:
self.fileManager.createFileList(self.Addon)
allFiles = self.fileManager.readFileList()
allFiles = self.fileManager.getFileList()
#write list from local to remote
self.writeFiles(allFiles,self.local_path,self.remote_path)
@ -139,7 +133,7 @@ class XbmcBackup:
def restoreFiles(self):
self.fileManager.createFileList(self.Addon)
allFiles = self.fileManager.readFileList()
allFiles = self.fileManager.getFileList()
#write list from remote to local
self.writeFiles(allFiles,self.remote_path,self.local_path)