Use MEDIUMTEXT column type to increase size limit

This commit is contained in:
kageru 2019-09-29 13:26:05 +02:00
parent 5a5084c711
commit df6d3e34e8
5 changed files with 12 additions and 7 deletions

@ -85,9 +85,9 @@ object Routes {
respond(HttpStatusCode.BadRequest, "Empty pastes are not allowed")
return null
}
if (content.length > 65535) {
Log.info("Rejecting paste over 64k")
respond(HttpStatusCode.BadRequest, "Pastes are limited to 64 KiB")
if (content.length > 1024 * 1024) {
Log.info("Rejecting paste over 1M")
respond(HttpStatusCode.BadRequest, "Pastes are limited to 1 MiB")
return null
}
val uri = PasteDao.insert(Paste(content, DateTime.now(), Paste.randomUri())).data.uri

@ -58,7 +58,7 @@ object AboutPage {
}
h3 { +"Expiration & limits" }
p {
+"All pastes are limited to 64 KiB, and empty pastes are rejected."
+"All pastes are limited to 1 MiB, and empty pastes are rejected."
br
+"Right now, pastes are not pruned or deleted at all. "
+"If more people start using this, I might add something that deletes unaccessed pastes after a few months. We’ll see."

@ -52,7 +52,7 @@ object Css {
borderStyle = BorderStyle.solid
color = Color.black
fontWeight = FontWeight.w600
padding = "5px 15px"
padding = "5px 10em"
cursor = Cursor.pointer
transition(duration = 500.ms)
}
@ -89,6 +89,7 @@ object Css {
}
rule("textarea:focus") {
borderColor = accent2
outline = Outline.none
}
rule("::selection") {
color = accent1

@ -9,7 +9,7 @@ object Homepage {
head {
link(rel = "stylesheet", href = "/style.css", type = "text/css")
unsafe {
+"<style>*{transition-duration: 400ms;}</style>"
+"<style>:not(textarea){transition-duration: 400ms;}</style>"
}
}
body {

@ -50,11 +50,15 @@ private fun ResultRow.toPaste() = Transient(
private object PasteTable : Table() {
val id = long("id").primaryKey().autoIncrement().uniqueIndex()
val content = text("content")
val content = registerColumn<String>("content", MediumTextColumnType())
val created = datetime("created").index()
val uri = varchar("uri", 10).uniqueIndex()
}
class MediumTextColumnType: IColumnType by TextColumnType() {
override fun sqlType(): String = "MEDIUMTEXT"
}
/*
* Better have that one generic class
* after deciding to make everything else