Exemplo n.º 1
0
        protected override async Task RunJob(JobInfo jobInfo, UserAccount userInfo)
        {
            var targetDirectory = Path.Combine(Configuration.RepoBaseDir, jobInfo.JobId);

            Log.Information("Using local directory {localDirPath}", targetDirectory);
            Log.Information("Clone Repository: {gitRepositoryUrl} => {targetDirectory}", jobInfo.GitRepositoryUrl, targetDirectory);
            await _git.CloneRepository(jobInfo.GitRepositoryUrl, targetDirectory, AuthenticationToken, userInfo);

            var datasetIri = new Uri(jobInfo.DatasetIri);

            DeleteCsvAndMetadata(targetDirectory, jobInfo.DatasetId, ProgressLog);
            var dataDockRepository = _repositoryFactory.GetRepositoryForJob(jobInfo, ProgressLog);

            dataDockRepository.DeleteDataset(datasetIri);
            await UpdateHtmlPagesAsync(dataDockRepository, null);

            if (await _git.CommitChanges(targetDirectory, $"Deleted dataset {datasetIri}", userInfo))
            {
                await _git.PushChanges(jobInfo.GitRepositoryUrl, targetDirectory, AuthenticationToken);
            }

            try
            {
                await _datasetStore.DeleteDatasetAsync(jobInfo.OwnerId, jobInfo.RepositoryId, jobInfo.DatasetId);
            }
            catch (Exception ex)
            {
                Log.Error(ex, "Failed to remove dataset record.");
                throw new WorkerException(ex, "Failed to remove dataset record. Your repository is updated but the dataset may still show in the main lodlab portal");
            }

            Log.Information("Dataset Deleted: {OwnerId}/RepositoryId/{DatasetId}",
                            jobInfo.OwnerId, jobInfo.RepositoryId, jobInfo.DatasetId);
            ProgressLog.DatasetDeleted(jobInfo.OwnerId, jobInfo.RepositoryId, jobInfo.DatasetId);
        }