private async Task CopyAndAdopt(MigrationJob job) { _bucketProvider.SetBucketKeyFromOld(job.bucket.BucketKey); OssBucket bucketNew = await _userResolver.GetBucketAsync(true); string signedUrlOld = await job.bucket.CreateSignedUrlAsync(job.projectUrl, ObjectAccess.Read); string signedUrlNew = await bucketNew.CreateSignedUrlAsync(job.projectUrl, ObjectAccess.ReadWrite); try { await _projectWork.FileTransferAsync(signedUrlOld, signedUrlNew); } catch (Exception e) { _logger.LogError(e, $"Project {job.projectInfo.Name} cannot be copied."); return; } try { await _projectWork.AdoptAsync(job.projectInfo, signedUrlNew); _logger.LogInformation($"Project {job.projectInfo.Name} was adopted"); } catch (Exception e) { _logger.LogError(e, $"Project {job.projectInfo.Name} was not adopted"); } }
private async Task ProcessJobs(List <MigrationJob> jobs, int logIdStart, int logIdTotalCount) { int taskIndex = 0; int parallelCount = Int16.Parse(_configuration.GetValue <string>("MigrationParallelCount") ?? "15"); int jobIndex = 0; Task[] tasks = new Task[parallelCount]; for (int i = 0; i < parallelCount; i++) { tasks[i] = Task.CompletedTask; } while (jobIndex < jobs.Count) { if (tasks[taskIndex].IsCompleted) { MigrationJob job = jobs[jobIndex]; string logId = $"{logIdStart+jobIndex+1}/{logIdTotalCount}"; tasks[taskIndex] = job.Process(logId); jobIndex++; } await Task.Delay(1000); taskIndex = (taskIndex + 1) % parallelCount; } // wait for completion of all tasks await Task.WhenAll(tasks); }
private async Task RemoveNew(MigrationJob job) { List <string> projectList = new List <string>() { job.projectInfo.Name }; await _projectService.DeleteProjects(projectList, job.bucket); }