Skip to content

Commit 8d14be3

Browse files
committed
Handle deletion of fully linked layer with all mags seperately linked
1 parent 6572e32 commit 8d14be3

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

util/src/main/scala/com/scalableminds/util/mvc/Formatter.scala

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,12 @@ trait Formatter {
9292
case _ => ""
9393
}
9494

95+
def firstException(failure: Failure): String =
96+
failure.exception match {
97+
case Full(exception) => exception.toString + ": "
98+
case _ => ""
99+
}
100+
95101
def formatNextChain(chainBox: Box[Failure]): String = chainBox match {
96102
case Full(chainFailure) =>
97103
" <~ " + formatFailureChain(chainFailure, includeStackTraces, includeTime = false, messagesProviderOpt)
@@ -108,7 +114,8 @@ trait Formatter {
108114
}
109115

110116
val serverTimeMsg = if (includeTime) s"[Server Time ${Instant.now}] " else ""
111-
serverTimeMsg + formatOneFailure(failure) + formatStackTrace(failure) + formatNextChain(failure.chain)
117+
serverTimeMsg + firstException(failure) + formatOneFailure(failure) + formatStackTrace(failure) + formatNextChain(
118+
failure.chain)
112119
}
113120

114121
}

webknossos-datastore/app/com/scalableminds/webknossos/datastore/helpers/DatasetDeleter.scala

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import com.scalableminds.webknossos.datastore.services.DSRemoteWebknossosClient
1010
import com.scalableminds.webknossos.datastore.storage.DataVaultService
1111
import com.typesafe.scalalogging.LazyLogging
1212
import net.liftweb.common.Box.tryo
13-
import net.liftweb.common.{Box, EmptyBox, Full}
13+
import net.liftweb.common.{Box, Full}
14+
import org.apache.commons.io.FileUtils
1415

1516
import java.io.File
1617
import java.nio.file.{Files, Path}
@@ -192,6 +193,11 @@ trait DatasetDeleter extends LazyLogging with DirectoryConstants {
192193
if (Files.exists(targetPath) && Files.isSymbolicLink(targetPath)) {
193194
Files.delete(targetPath)
194195
}
196+
if (Files.exists(targetPath) && Files.isDirectory(targetPath)) {
197+
// This happens when the fully linked layer consists of mag symlinks. The directory exists and is full of symlinked mags.
198+
// We need to delete the directory before moving the layer.
199+
FileUtils.deleteDirectory(targetPath.toFile)
200+
}
195201
Files.move(layerPath, targetPath)
196202

197203
// All symlinks are now broken, we need to recreate them

0 commit comments

Comments
 (0)