diff --git a/CHANGELOG.unreleased.md b/CHANGELOG.unreleased.md index d0651a050f5..370f142ae8d 100644 --- a/CHANGELOG.unreleased.md +++ b/CHANGELOG.unreleased.md @@ -17,7 +17,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.released - ### Fixed -- +- Fixed a bug where dataset uploads of zips with just one file inside failed. [#5534](https://github.com/scalableminds/webknossos/pull/5534) ### Removed - diff --git a/util/src/main/scala/com/scalableminds/util/io/PathUtils.scala b/util/src/main/scala/com/scalableminds/util/io/PathUtils.scala index e16f9c85cce..404a8876d56 100644 --- a/util/src/main/scala/com/scalableminds/util/io/PathUtils.scala +++ b/util/src/main/scala/com/scalableminds/util/io/PathUtils.scala @@ -148,12 +148,17 @@ trait PathUtils extends LazyLogging { def isFileNameInPrefix(prefix: Path, fileName: String) = prefix.endsWith(Paths.get(fileName).getFileName) fileNames match { - case head :: tl if tl.isEmpty && isFileNameInPrefix(prefix, head) => - prefix.subpath(0, prefix.getNameCount - 1) + case head :: tail if tail.isEmpty && isFileNameInPrefix(prefix, head) => + removeOneName(prefix) case _ => prefix } } + private def removeOneName(path: Path): Path = + if (path.getNameCount == 1) { + Paths.get("") + } else path.subpath(0, path.getNameCount - 1) + def deleteDirectoryRecursively(path: Path): Box[Unit] = { val directory = new Directory(new File(path.toString)) if (!directory.exists) return Full(())