private void BackupCurrentVersion(string sourcePath, string destPath) { if (!Directory.Exists(sourcePath)) { throw new ArgumentException($"The path {sourcePath} is either not a directory or does not exist"); } IOUtilities.CopyFolderTo(sourcePath, destPath, true); }
public async Task UpdateVersion(ConfigurationItem configItem, IProgress <double> progress = null) { configItem.AssertNotNull(nameof(configItem)); string appDataOldVersionBackupPath = CommonBLL.CreateTempAppDataFolder(); string appDataPath = CommonBLL.CreateTempAppDataFolder(); string appDataUnzippedPath = Path.Combine(appDataPath, "unzipped"); try { Task <byte[]> zipArchiveTask = RetrieveZipFileWithBackup(configItem.Architecture, appDataPath, progress); Task backupTask = Task.Run(() => { Logger.Info($"Creating a backup of the current version at {appDataOldVersionBackupPath}"); BackupCurrentVersion(configItem.DBeaverInstallPath, appDataOldVersionBackupPath); Logger.Info($"The backup has been created"); }); await Task.WhenAll(zipArchiveTask, backupTask); Logger.Info("Unzipping the downloaded archive"); byte[] zipArchive = zipArchiveTask.Result; UnzipArchive(zipArchive, appDataUnzippedPath, progress); Logger.Info("The archive has been successfully unzipped"); Logger.Info($"Patching DBeaver current version at {configItem.DBeaverInstallPath}"); IOUtilities.EmptyFolder(configItem.DBeaverInstallPath); IOUtilities.CopyFolderTo(Path.Combine(appDataUnzippedPath, "dbeaver"), configItem.DBeaverInstallPath, true); Logger.Info("Patching successful"); } finally { Logger.Info("Deleting temp data"); IOUtilities.DeleteFolder(appDataPath); IOUtilities.DeleteFolder(appDataOldVersionBackupPath); Logger.Info("Temp data deleted successfully"); } }
public void IOUtilities_CopyDirectory_Test() { IOUtilities.CopyFolderTo(@"C:\temp\folder1", @"C:\temp\folder2", true, true); }