aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPinapelz <yukais@pinapelz.com>2026-02-06 16:32:10 -0800
committerPinapelz <yukais@pinapelz.com>2026-02-06 16:32:10 -0800
commit593f5ab225a17719207b873a98c1ed633e5d57e7 (patch)
treed7db07a24e3f792aab2549f7b2b9b54f59b5bd37
parentc2a809718173d03b09f19d7da3489e0ed4d75851 (diff)
finish split by parts configHEADmain
# Conflicts: # src/main/java/com/pinapelz/frontend/App.kt
-rw-r--r--src/main/java/com/pinapelz/frontend/App.kt3
-rw-r--r--src/main/java/com/pinapelz/frontend/MultipartFileManager.kt29
2 files changed, 29 insertions, 3 deletions
diff --git a/src/main/java/com/pinapelz/frontend/App.kt b/src/main/java/com/pinapelz/frontend/App.kt
index 2016bbf..a33d7ed 100644
--- a/src/main/java/com/pinapelz/frontend/App.kt
+++ b/src/main/java/com/pinapelz/frontend/App.kt
@@ -21,7 +21,7 @@ fun startFrontend(retriever: Retriever, fileSystem: FileSystem, webhooksFile: St
println("Warning: Webhooks file not found: $webhooksFile")
null
}
- val app = Javalin.create{}
+ val app = Javalin.create{};
app.get("/") { ctx ->
val directoryId = ctx.queryParam("dir")?.toIntOrNull() ?: 1
@@ -81,6 +81,7 @@ fun startFrontend(retriever: Retriever, fileSystem: FileSystem, webhooksFile: St
val sortBy = ctx.queryParam("sortBy") ?: "created_at"
val files = mutableListOf<Map<String, Any>>()
+
val fileEntries = fileSystem.getFilesByDirectoryId(
directoryId,
search,
diff --git a/src/main/java/com/pinapelz/frontend/MultipartFileManager.kt b/src/main/java/com/pinapelz/frontend/MultipartFileManager.kt
index 257521d..70546dd 100644
--- a/src/main/java/com/pinapelz/frontend/MultipartFileManager.kt
+++ b/src/main/java/com/pinapelz/frontend/MultipartFileManager.kt
@@ -224,7 +224,7 @@ class MultipartFileManager(
when (config) {
is SplitConfig.BySize -> {
- val partSize = config.sizeInBytes - (16 * 1024);
+ val partSize = config.sizeInBytes - (16 * 1024)
val numParts = ceil(fileSize.toDouble() / partSize.toDouble()).toInt()
println("Splitting file: ${fileSize} bytes into ${numParts} parts of max ${partSize} bytes each")
@@ -247,7 +247,32 @@ class MultipartFileManager(
}
}
- is SplitConfig.ByParts -> { // TODO: stubbed not yet implemented
+ is SplitConfig.ByParts -> {
+ val partSize = fileSize / config.numParts
+ var remainingBytes = fileSize
+ var offset = 0L
+
+ uploadedFile.content().use { inputStream ->
+ for (partId in 1..config.numParts) {
+ val partName = "part_$partId"
+ val partPath = workingDir.resolve(partName)
+
+ val currentPartSize = if (partId == config.numParts) remainingBytes else partSize
+ val partBytes = ByteArray(currentPartSize.toInt())
+ inputStream.read(partBytes, 0, currentPartSize.toInt())
+
+ Files.write(partPath, partBytes)
+ partsMeta += FilePartMeta(
+ id = partId.toString(),
+ name = partName,
+ size = currentPartSize,
+ path = partPath
+ )
+
+ offset += currentPartSize
+ remainingBytes -= currentPartSize
+ }
+ }
}
}
val metadata = SplitMetadata(
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage