Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dataset upload for >2GB files #5889

Merged
merged 1 commit into from
Dec 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.released
-

### Fixed
-
- Fixed a bug where dataset uploads that contained files larger than 2 GB failed. [#5889](https://github.com/scalableminds/webknossos/pull/5889)

### Removed
-
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import play.api.libs.json.{Json, OFormat}
import scala.collection.mutable
import scala.concurrent.ExecutionContext.Implicits.global

case class ResumableUploadInformation(chunkSize: Int, totalChunkCount: Long)
case class ResumableUploadInformation(chunkSize: Long, totalChunkCount: Long)

case class UploadInformation(uploadId: String,
organization: String,
Expand All @@ -38,7 +38,7 @@ class UploadService @Inject()(dataSourceRepository: DataSourceRepository, dataSo
private val uploadingDir: String = ".uploading"

// structure: uploadId → (fileCount, fileName → (totalChunkCount, receivedChunkIndices))
val allSavedChunkIds: mutable.HashMap[String, (Long, mutable.HashMap[String, (Long, mutable.HashSet[Int])])] =
val allSavedChunkIds: mutable.HashMap[String, (Long, mutable.HashMap[String, (Long, mutable.HashSet[Long])])] =
mutable.HashMap.empty

cleanUpOrphanUploads()
Expand All @@ -54,8 +54,8 @@ class UploadService @Inject()(dataSourceRepository: DataSourceRepository, dataSo
def handleUploadChunk(uploadFileId: String,
datasourceId: DataSourceId,
resumableUploadInformation: ResumableUploadInformation,
currentChunkNumber: Int,
totalFileCount: Int,
currentChunkNumber: Long,
totalFileCount: Long,
chunkFile: File): Fox[Unit] = {
val uploadId = extractDatasetUploadId(uploadFileId)
val uploadDir = uploadDirectory(datasourceId.team, uploadId)
Expand All @@ -71,14 +71,14 @@ class UploadService @Inject()(dataSourceRepository: DataSourceRepository, dataSo
case None =>
savedChunkIdsForUpload.put(
filePath,
(resumableUploadInformation.totalChunkCount, mutable.HashSet[Int](currentChunkNumber)))
(resumableUploadInformation.totalChunkCount, mutable.HashSet[Long](currentChunkNumber)))
true // isNewChunk
}
case None =>
val uploadChunksForUpload: mutable.HashMap[String, (Long, mutable.HashSet[Int])] = mutable.HashMap.empty
val uploadChunksForUpload: mutable.HashMap[String, (Long, mutable.HashSet[Long])] = mutable.HashMap.empty
uploadChunksForUpload.put(
filePath,
(resumableUploadInformation.totalChunkCount, mutable.HashSet[Int](currentChunkNumber)))
(resumableUploadInformation.totalChunkCount, mutable.HashSet[Long](currentChunkNumber)))
allSavedChunkIds.put(uploadId, (totalFileCount, uploadChunksForUpload))
true // isNewChunk
}
Expand Down Expand Up @@ -150,7 +150,7 @@ class UploadService @Inject()(dataSourceRepository: DataSourceRepository, dataSo
allSavedChunkIds.get(uploadId) match {
case Some((fileCountForUpload, savedChunkIdsForUpload)) =>
val allFilesPresent = fileCountForUpload == savedChunkIdsForUpload.keySet.size
val allFilesComplete = savedChunkIdsForUpload.forall { entry: (String, (Long, mutable.HashSet[Int])) =>
val allFilesComplete = savedChunkIdsForUpload.forall { entry: (String, (Long, mutable.HashSet[Long])) =>
val chunkNumber = entry._2._1
val savedChunksSet = entry._2._2
savedChunksSet.size == chunkNumber
Expand Down