mirror of
				https://github.com/robweber/xbmcbackup.git
				synced 2025-10-31 09:31:02 +01:00 
			
		
		
		
	removed file handle and restore.txt file. now the filenames are written to a list in memory
This commit is contained in:
		| @@ -1,6 +1,6 @@ | |||||||
| <?xml version="1.0" encoding="UTF-8" standalone="yes"?> | <?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||||||
| <addon id="script.xbmcbackup" | <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> |   <requires> | ||||||
|     <import addon="xbmc.python" version="2.0"/> |     <import addon="xbmc.python" version="2.0"/> | ||||||
|   </requires> |   </requires> | ||||||
|   | |||||||
| @@ -15,7 +15,11 @@ Finished code for restore mode. | |||||||
| Added option to manually type a path rather than browse for one (only one used) | 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 | 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 | Added the vfs module created by paddycarey | ||||||
| File Selection is now followed for both backup and restore options | 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 | ||||||
|   | |||||||
							
								
								
									
										22
									
								
								default.py
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								default.py
									
									
									
									
									
								
							| @@ -7,8 +7,8 @@ import os | |||||||
| class FileManager: | class FileManager: | ||||||
|     walk_path = '' |     walk_path = '' | ||||||
|     addonDir = '' |     addonDir = '' | ||||||
|     fHandle = None |     fileArray = None | ||||||
|  | 	 | ||||||
|     def __init__(self,path,addon_dir): |     def __init__(self,path,addon_dir): | ||||||
|         self.walk_path = path |         self.walk_path = path | ||||||
|         self.addonDir = addon_dir |         self.addonDir = addon_dir | ||||||
| @@ -18,7 +18,7 @@ class FileManager: | |||||||
|             os.makedirs(unicode(xbmc.translatePath(self.addonDir),'utf-8')) |             os.makedirs(unicode(xbmc.translatePath(self.addonDir),'utf-8')) | ||||||
|  |  | ||||||
|     def createFileList(self,Addon): |     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 |         #figure out which syncing options to run | ||||||
|         if(Addon.getSetting('backup_addons') == 'true'): |         if(Addon.getSetting('backup_addons') == 'true'): | ||||||
| @@ -49,9 +49,6 @@ class FileManager: | |||||||
| 	    for aFile in configFiles: | 	    for aFile in configFiles: | ||||||
| 		if(aFile.endswith(".xml")): | 		if(aFile.endswith(".xml")): | ||||||
| 		    self.addFile("userdata/" + aFile) | 		    self.addFile("userdata/" + aFile) | ||||||
|  |  | ||||||
| 	if(self.fHandle != None): |  | ||||||
|             self.fHandle.close() |  | ||||||
|          |          | ||||||
|     def walkTree(self,directory): |     def walkTree(self,directory): | ||||||
|         for (path, dirs, files) in vfs.walk(directory): |         for (path, dirs, files) in vfs.walk(directory): | ||||||
| @@ -66,13 +63,10 @@ class FileManager: | |||||||
|                      |                      | ||||||
|     def addFile(self,filename): |     def addFile(self,filename): | ||||||
|         #write the full remote path name of this file |         #write the full remote path name of this file | ||||||
|         if(self.fHandle != None): |         self.fileArray.append(filename) | ||||||
|             self.fHandle.write(str(filename) + "\n") |  | ||||||
|  |  | ||||||
|     def readFileList(self): |     def getFileList(self): | ||||||
|         allFiles = open(unicode(xbmc.translatePath(self.addonDir + "restore.txt"),'utf-8'),"r").read().splitlines() |        return self.fileArray | ||||||
|  |  | ||||||
|         return allFiles |  | ||||||
|  |  | ||||||
| class XbmcBackup: | class XbmcBackup: | ||||||
|     __addon_id__ = 'script.xbmcbackup' |     __addon_id__ = 'script.xbmcbackup' | ||||||
| @@ -131,7 +125,7 @@ class XbmcBackup: | |||||||
|          |          | ||||||
|         self.fileManager.createFileList(self.Addon) |         self.fileManager.createFileList(self.Addon) | ||||||
|  |  | ||||||
|         allFiles = self.fileManager.readFileList() |         allFiles = self.fileManager.getFileList() | ||||||
|  |  | ||||||
|         #write list from local to remote |         #write list from local to remote | ||||||
|         self.writeFiles(allFiles,self.local_path,self.remote_path) |         self.writeFiles(allFiles,self.local_path,self.remote_path) | ||||||
| @@ -139,7 +133,7 @@ class XbmcBackup: | |||||||
|     def restoreFiles(self): |     def restoreFiles(self): | ||||||
|         self.fileManager.createFileList(self.Addon) |         self.fileManager.createFileList(self.Addon) | ||||||
|          |          | ||||||
|         allFiles = self.fileManager.readFileList() |         allFiles = self.fileManager.getFileList() | ||||||
|  |  | ||||||
|         #write list from remote to local |         #write list from remote to local | ||||||
|         self.writeFiles(allFiles,self.remote_path,self.local_path) |         self.writeFiles(allFiles,self.remote_path,self.local_path) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Rob Weber
					Rob Weber