mirror of
https://github.com/robweber/xbmcbackup.git
synced 2025-11-23 11:41:30 +01:00
Merge branch 'master' into google_drive
Conflicts: resources/language/English/strings.xml resources/lib/backup.py
This commit is contained in:
@@ -5,6 +5,7 @@ import utils as utils
|
||||
import time
|
||||
import json
|
||||
from vfs import XBMCFileSystem,DropboxFileSystem,ZipFileSystem,GoogleDriveFilesystem
|
||||
from resources.lib.guisettings import GuiSettingsManager
|
||||
|
||||
def folderSort(aKey):
|
||||
result = aKey[0]
|
||||
@@ -156,7 +157,14 @@ class XbmcBackup:
|
||||
self.remote_vfs.mkdir(self.remote_vfs.root_path)
|
||||
|
||||
#create a validation file for backup rotation
|
||||
self._createValidationFile()
|
||||
writeCheck = self._createValidationFile()
|
||||
|
||||
if(not writeCheck):
|
||||
#we may not be able to write to this destination for some reason
|
||||
shouldContinue = xbmcgui.Dialog().yesno(utils.getString(30089),utils.getString(30090), utils.getString(30044),autoclose=25000)
|
||||
|
||||
if(not shouldContinue):
|
||||
return
|
||||
|
||||
utils.log(utils.getString(30051))
|
||||
allFiles = []
|
||||
@@ -240,7 +248,11 @@ class XbmcBackup:
|
||||
for fileGroup in allFiles:
|
||||
self.xbmc_vfs.set_root(fileGroup['source'])
|
||||
self.remote_vfs.set_root(fileGroup['dest'])
|
||||
self.backupFiles(fileGroup['files'],self.xbmc_vfs,self.remote_vfs)
|
||||
filesCopied = self.backupFiles(fileGroup['files'],self.xbmc_vfs,self.remote_vfs)
|
||||
|
||||
if(not filesCopied):
|
||||
utils.showNotification(utils.getString(30092))
|
||||
utils.log(utils.getString(30092))
|
||||
|
||||
#reset remote and xbmc vfs
|
||||
self.xbmc_vfs.set_root("special://home/")
|
||||
@@ -258,8 +270,12 @@ class XbmcBackup:
|
||||
|
||||
self.remote_vfs = self.saved_remote_vfs
|
||||
self.progressBar.updateProgress(98, utils.getString(30088))
|
||||
self.backupFiles(fileManager.getFiles(),self.xbmc_vfs, self.remote_vfs)
|
||||
fileCopied = self.backupFiles(fileManager.getFiles(),self.xbmc_vfs, self.remote_vfs)
|
||||
|
||||
if(not fileCopied):
|
||||
#zip archive copy filed, inform the user
|
||||
shouldContinue = xbmcgui.Dialog().ok(utils.getString(30089),utils.getString(30090), utils.getString(30091))
|
||||
|
||||
#delete the temp zip file
|
||||
self.xbmc_vfs.rmfile(xbmc.translatePath("special://temp/" + zip_name))
|
||||
|
||||
@@ -411,6 +427,11 @@ class XbmcBackup:
|
||||
self.xbmc_vfs.rmfile(xbmc.translatePath("special://temp/" + self.restore_point))
|
||||
self.xbmc_vfs.rmdir(self.remote_vfs.root_path)
|
||||
|
||||
if(utils.getSetting("backup_config") == "true"):
|
||||
#update the guisettings information (or what we can from it)
|
||||
gui_settings = GuiSettingsManager('special://home/userdata/guisettings.xml')
|
||||
gui_settings.run()
|
||||
|
||||
#call update addons to refresh everything
|
||||
xbmc.executebuiltin('UpdateLocalAddons')
|
||||
|
||||
@@ -422,6 +443,8 @@ class XbmcBackup:
|
||||
window.setProperty(utils.__addon_id__ + ".running","")
|
||||
|
||||
def backupFiles(self,fileList,source,dest):
|
||||
result = True
|
||||
|
||||
utils.log("Writing files to: " + dest.root_path)
|
||||
utils.log("Source: " + source.root_path)
|
||||
for aFile in fileList:
|
||||
@@ -432,12 +455,20 @@ class XbmcBackup:
|
||||
dest.mkdir(dest.root_path + aFile[len(source.root_path) + 1:])
|
||||
else:
|
||||
self._updateProgress()
|
||||
if(isinstance(source,DropboxFileSystem) or isinstance(source,GoogleDriveFilesystem)):
|
||||
#if copying from cloud storage we need the file handle, use get_file
|
||||
source.get_file(aFile,dest.root_path + aFile[len(source.root_path):])
|
||||
wroteFile = True
|
||||
if(isinstance(source,DropboxFileSystem)):
|
||||
#if copying from dropbox we need the file handle, use get_file
|
||||
wroteFile = source.get_file(aFile,dest.root_path + aFile[len(source.root_path):])
|
||||
else:
|
||||
#copy using normal method
|
||||
dest.put(aFile,dest.root_path + aFile[len(source.root_path):])
|
||||
wroteFile = dest.put(aFile,dest.root_path + aFile[len(source.root_path):])
|
||||
|
||||
#if result is still true but this file failed
|
||||
if(not wroteFile and result):
|
||||
result = False
|
||||
|
||||
|
||||
return result
|
||||
|
||||
def _createCRC(self,string):
|
||||
#create hash from string
|
||||
@@ -490,7 +521,9 @@ class XbmcBackup:
|
||||
vFile.write("")
|
||||
vFile.close()
|
||||
|
||||
self.remote_vfs.put(xbmc.translatePath(utils.data_dir() + "xbmcbackup.val"),self.remote_vfs.root_path + "xbmcbackup.val")
|
||||
success = self.remote_vfs.put(xbmc.translatePath(utils.data_dir() + "xbmcbackup.val"),self.remote_vfs.root_path + "xbmcbackup.val")
|
||||
|
||||
return success
|
||||
|
||||
def _checkValidationFile(self,path):
|
||||
result = False
|
||||
|
||||
Reference in New Issue
Block a user