Skip to content

Commit

Permalink
ref #297: mark import as failed when input file processing fails
Browse files Browse the repository at this point in the history
  • Loading branch information
Foxcapades committed May 14, 2024
1 parent ddc5758 commit ef9efb2
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,11 @@ fun createDataset(
// starting the new thread. Then the new thread will be forked and the
// target file downloaded into a temp directory in that thread before
// being uploaded to MinIO (also in that forked thread).
val (tempDirectory, uploadFile) = entity.getDatasetFile()
val (tempDirectory, uploadFile) = try { entity.getDatasetFile() }
catch (e: Throwable) {
CacheDB().withTransaction { it.updateImportControl(datasetID, DatasetImportStatus.Failed) }
throw e
}

Metrics.Upload.queueSize.inc()
WorkPool.submit {
Expand Down Expand Up @@ -374,8 +378,12 @@ private fun DatasetPostRequest.getDatasetFile(): Pair<Path, Path> =

// Try to establish a connection to the URL target (validating that the
// target is reachable)
val connection = try { url.openConnection() }
catch (e: Throwable) { throw BadRequestException("given source file URL was unreachable") }
val connection = try {
url.openConnection()
} catch (e: Throwable) {
paths.first.deleteRecursively()
throw BadRequestException("given source file URL was unreachable")
}

// Try to download the file from the source URL.
try {
Expand Down

0 comments on commit ef9efb2

Please sign in to comment.