From 5523bd7a5e30b09baa6bb3ccd23252d0ebef6000 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Fri, 19 Apr 2019 22:07:22 +0200 Subject: Fixed recursive upload function Co-authored-by: LarsVomMars --- src/main/kotlin/FileController.kt | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/main/kotlin/FileController.kt') diff --git a/src/main/kotlin/FileController.kt b/src/main/kotlin/FileController.kt index d8f7dfb..06c1402 100644 --- a/src/main/kotlin/FileController.kt +++ b/src/main/kotlin/FileController.kt @@ -8,8 +8,11 @@ import java.io.* import java.nio.charset.* import java.nio.file.* import java.text.* +import java.util.logging.* class FileController { + private val log = Logger.getLogger(this.javaClass.name) + /** * Crawls the requested file and either renders the directory view or the file view */ @@ -113,16 +116,16 @@ class FileController { fun upload(ctx: Context) { ctx.uploadedFiles("file").forEach { (_, content, name, _) -> val path = "${ctx.splats()[0]}/$name" - val uid = userHandler.getVerifiedUserId(ctx) + val userId = userHandler.getVerifiedUserId(ctx) var addPath = "" path.split("/").forEach { addPath += "$it/" - if (!path.endsWith(it)) databaseController.addFile(addPath, uid, true) + if (!path.endsWith(it)) databaseController.addFile(addPath, userId, true) } - if (databaseController.addFile(path, uid)) { + if (databaseController.addFile(path, userId)) { FileUtil.streamToFile( content, - "$fileHome/$uid/$path" + "$fileHome/$userId/$path" ) } } @@ -144,7 +147,7 @@ class FileController { if (userId > 0) { val path = ctx.splats()[0] File("$fileHome/$userId/$path").delete() // File.deleteRecursively() kind of "crashes" server but deletes folder :'( - databaseController.deleteFile(path, userId) + databaseController.deleteFile(path, userId) // kind of works for deleting directories } } -- cgit v1.2.3