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

Use zip name when uploading hybrid/volume/collection #4222

Merged
merged 8 commits into from
Aug 12, 2019
Merged
Show file tree
Hide file tree
Changes from 4 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.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.md).
-

### Changed
-
- When uploading a zipped annotation (such as volume / hybrid / collection), the zip name is used for the resulting explorative annotation, rather than the name of the contained NML file. [#4222](https://github.com/scalableminds/webknossos/pull/4222)

### Fixed
- Data for disabled or invisible layers will no longer be downloaded, saving bandwidth and speeding up webKnossos in general. [#4202](https://github.com/scalableminds/webknossos/pull/4202)
Expand Down
5 changes: 2 additions & 3 deletions app/controllers/AnnotationIOController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class AnnotationIOController @Inject()(nmlWriter: NmlWriter,

private def nameForNmls(fileNames: Seq[String]) =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private def nameForNmls(fileNames: Seq[String]) =
private def nameForUpload(fileNames: Seq[String]) =

if (fileNames.size == 1)
fileNames.headOption.map(_.replaceAll("\\.nml$", ""))
fileNames.headOption.map(_.replaceAll("\\.nml$", "").replaceAll("\\.zip", ""))
else
None

Expand Down Expand Up @@ -99,10 +99,9 @@ class AnnotationIOController @Inject()(nmlWriter: NmlWriter,
request.body.dataParts("createGroupForEachFile").headOption.contains("true")

val parsedFiles = request.body.files.foldLeft(NmlResults.ZipParseResult()) {
case (acc, next) => {
case (acc, next) =>
val file = new File(next.ref.path.toString)
acc.combineWith(nmlService.extractFromFile(file, next.filename))
}
}

val tracingsProcessed =
Expand Down
4 changes: 4 additions & 0 deletions app/models/annotation/nml/NmlResults.scala
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ object NmlResults extends LazyLogging {
case _ =>
Fox.failure("Couldn’t parse file")
}

def withName(name: String): NmlParseResult = this
}

case class NmlParseSuccess(fileName: String,
Expand All @@ -44,6 +46,8 @@ object NmlResults extends LazyLogging {
override def description = Some(_description)

override def organizationName: Option[String] = organizationNameOpt

override def withName(name: String): NmlParseResult = this.copy(fileName = name)
}

case class NmlParseFailure(fileName: String, error: String) extends NmlParseResult {
Expand Down
2 changes: 1 addition & 1 deletion app/models/annotation/nml/NmlService.scala
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class NmlService @Inject()(temporaryFileCreator: TemporaryFileCreator)(implicit
ZipIO.withUnziped(file, includeHiddenFiles = false) { (filename, file) =>
if (filename.toString.endsWith(".nml")) {
val result = extractFromNml(file, filename.toString)
parseResults ::= result
parseResults ::= result.withName(name)
} else {
val tempFile = temporaryFileCreator.create(filename.toString)
Files.copy(file, tempFile.path, StandardCopyOption.REPLACE_EXISTING)
Expand Down