/// <summary>Backup the current project.</summary> /// <returns>True if the backup was successful.</returns> public static bool Backup() { isBusy = true; OnBackupStart?.Invoke(); bool success = false; if (Util.Config.COPY_ASSETS || Util.Config.COPY_LIBRARY || Util.Config.COPY_SETTINGS || Util.Config.COPY_PACKAGES) { success = Util.Config.USE_LEGACY ? Util.Helper.Backup() : Util.Helper.BackupNew(); } else { Debug.LogError("No folders selected - backup not possible!"); #if UNITY_2018_2_OR_NEWER if (Application.isBatchMode) #else if (UnityEditorInternal.InternalEditorUtility.inBatchMode) #endif { throw new System.Exception("No folders selected - backup not possible!"); } //EditorApplication.Exit(0); } OnBackupComplete?.Invoke(success); isBusy = false; return(success); }
public async Task BackupAsync(Regions regions, string TargetPath, string source, string _user, LogOptions _logOptions, LogState _logstate, LogOperation _logoperation, CancellationToken token) { Logger.assignLogPath(TargetPath, _logstate, _logoperation); BackupCopyHandler objbackuphandler = new BackupCopyHandler(); objbackuphandler.OnAtomicCurrent += DataBackup_OnAtomicCurrent; OnBackupStart?.Invoke(this, new StringEventArgs("Data Backup Started")); if (!string.IsNullOrEmpty(source)) { PathValidator validator = new PathValidator(); if (validator.Validate(source)) { OnCalculationStart?.Invoke(this, true); EnumData countModel = new EnumData(); //CountModel counts = await countModel.GetCountAsync(new DirectoryInfo(source)); int counts = await countModel.TotalCountsAsync(source); //OnAtomicTotalCounts?.Invoke(this, (counts.FileCount + counts.DirCount)); OnAtomicTotalCounts?.Invoke(this, counts); await objbackuphandler.CopyRecursiveAsync(new DirectoryInfo(source), new DirectoryInfo(TargetPath), _logOptions, token); } else { Logger.log(source, "path not found", _logOptions); } } else { foreach (var path in regions.GetPaths(_user)) { PathValidator validator = new PathValidator(); if (validator.Validate(path)) { OnCalculationStart?.Invoke(this, true); EnumData countModel = new EnumData(); //CountModel counts = await countModel.GetCountAsync(new DirectoryInfo(path)); // OnAtomicTotalCounts?.Invoke(this, (counts.FileCount + counts.DirCount)); int counts = await countModel.TotalCountsAsync(source); OnAtomicTotalCounts?.Invoke(this, counts); await objbackuphandler.CopyRecursiveAsync(new DirectoryInfo(path), new DirectoryInfo(TargetPath), _logOptions, token); } else { Logger.log(path, "path not found", _logOptions); } } } OnBackupComplete?.Invoke(this, new StringEventArgs("Data Backup Completed")); }
public async Task DifferenceBackupPartialParallelAsync(Regions regions, string TargetPath, string source, string _user, LogOptions _logOptions, LogState _logstate, LogOperation _logoperation, CancellationToken token) { Logger.assignLogPath(TargetPath, _logstate, _logoperation); BackupCopyHandler objbackuphandler = new BackupCopyHandler(); objbackuphandler.OnAtomicCurrent += DataBackup_OnAtomicCurrent; OnBackupStart?.Invoke(this, new StringEventArgs("Data Backup Started")); if (!string.IsNullOrEmpty(source)) { PathValidator validator = new PathValidator(); if (validator.Validate(source)) { OnCalculationStart?.Invoke(this, true); int counts = await SafeNativeMethods.FilesAndDirectoryListCountAsync(source); OnAtomicTotalCounts?.Invoke(this, counts); await objbackuphandler.DifferenceCopyPartialParallelAsync(new DirectoryInfo(source), new DirectoryInfo(TargetPath), _logOptions, token); } else { Logger.log(source, "path not found", _logOptions); } } else { foreach (var path in regions.GetPaths(_user)) { PathValidator validator = new PathValidator(); if (validator.Validate(path)) { OnCalculationStart?.Invoke(this, true); int counts = await SafeNativeMethods.FilesAndDirectoryListCountAsync(path); OnAtomicTotalCounts?.Invoke(this, counts); await objbackuphandler.DifferenceCopyPartialParallelAsync(new DirectoryInfo(path), new DirectoryInfo(TargetPath), _logOptions, token); } else { Logger.log(path, "path not found", _logOptions); } } } OnBackupComplete?.Invoke(this, new StringEventArgs("Data Backup Completed")); }