aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/DatabaseController.kt
diff options
context:
space:
mode:
authorMarvin Borner2019-04-19 22:07:22 +0200
committerMarvin Borner2019-04-19 22:07:22 +0200
commit5523bd7a5e30b09baa6bb3ccd23252d0ebef6000 (patch)
tree9e0ec38ac5f0ac3dc208eb2be0bc0eef24d5a5e0 /src/main/kotlin/DatabaseController.kt
parentfe97c12731193211caf8652a6fd40e02d0d429b4 (diff)
Fixed recursive upload function
Co-authored-by: LarsVomMars <lars@kroenner.eu>
Diffstat (limited to 'src/main/kotlin/DatabaseController.kt')
-rw-r--r--src/main/kotlin/DatabaseController.kt8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/main/kotlin/DatabaseController.kt b/src/main/kotlin/DatabaseController.kt
index 77f2e70..d65e800 100644
--- a/src/main/kotlin/DatabaseController.kt
+++ b/src/main/kotlin/DatabaseController.kt
@@ -222,7 +222,7 @@ class DatabaseController(dbFileLocation: String = "main.db") {
}
true
} catch (err: org.jetbrains.exposed.exceptions.ExposedSQLException) {
- log.warning("File already exists!")
+ if (!isDirectoryBool) log.warning("File already exists!")
false
}
}
@@ -235,7 +235,8 @@ class DatabaseController(dbFileLocation: String = "main.db") {
fun deleteFile(fileLocation: String, userId: Int) {
transaction {
try {
- FileLocation.deleteWhere { (FileLocation.path eq fileLocation) and (FileLocation.userId eq userId) }
+ // TODO: Think of new solution for directory deleting (instead of wildcards)
+ FileLocation.deleteWhere { (FileLocation.path like "$fileLocation%") and (FileLocation.userId eq userId) }
} catch (_: org.jetbrains.exposed.exceptions.ExposedSQLException) {
log.warning("File does not exist!")
}
@@ -272,8 +273,7 @@ class DatabaseController(dbFileLocation: String = "main.db") {
val isDir =
FileLocation.select { FileLocation.accessId eq accessId }.map { it[FileLocation.isDirectory] }[0]
ReturnFileData(userId, fileLocation, isDir)
- }
- else
+ } else
ReturnFileData(-1, "", false)
} catch (_: org.jetbrains.exposed.exceptions.ExposedSQLException) {
log.warning("File does not exist!")