From 22797dde022a398b34a91ba24e2bdd89be3f36f8 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Wed, 1 May 2019 22:32:25 +0200 Subject: Cleaned up sharing of files Co-authored-by: LarsVomMars --- src/main/kotlin/FileController.kt | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/main/kotlin/FileController.kt') diff --git a/src/main/kotlin/FileController.kt b/src/main/kotlin/FileController.kt index 9ba520c..9c2ee78 100644 --- a/src/main/kotlin/FileController.kt +++ b/src/main/kotlin/FileController.kt @@ -152,11 +152,10 @@ class FileController { } /** - * Renders the shared file + * Renders a shared file */ fun renderShared(ctx: Context) { - val accessId = ctx.queryParam("id").toString() - val sharedFileData = databaseController.getSharedFile(accessId) + val sharedFileData = databaseController.getSharedFile(ctx.queryParam("id").toString()) val fileLocation = sharedFileData.fileLocation if (sharedFileData.userId > 0 && fileLocation.isNotEmpty()) { val sharedFileLocation = "$fileHome/${sharedFileData.userId}/$fileLocation" @@ -171,7 +170,7 @@ class FileController { val files = ArrayList>() Files.list(Paths.get(sharedFileLocation)).forEach { val filename = it.toString() - .drop(sharedFileLocation.length - 1) + .drop(sharedFileLocation.length) val filePath = "$sharedFileLocation$filename" files.add(addToFileListing(filePath, filename)) } @@ -207,6 +206,9 @@ class FileController { ) } + /** + * Handles the rendering of human readable files + */ private fun handleHumanReadableFile(filePath: String, ctx: Context) { ctx.render( "fileview.rocker.html", model( @@ -226,7 +228,6 @@ class FileController { fun handleSharedFile(ctx: Context) { val filename = ctx.formParam("filename").toString() val accessId = ctx.formParam("accessId").toString() - val returnAccessId = databaseController.getAccessIdOfDirectory(filename, accessId) - ctx.result(returnAccessId) + ctx.result(databaseController.getAccessIdOfDirectory(filename, accessId)) } } -- cgit v1.2.3