Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor updates #1343

Merged
merged 2 commits into from
Mar 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
height="120px"
style="padding-right: 20px">

[![Build Status](https://travis-ci.org/eikek/sharry.svg?branch=master)](https://travis-ci.org/eikek/sharry)
[![Scala Steward badge](https://img.shields.io/badge/Scala_Steward-helping-blue.svg?style=flat&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAQCAMAAAARSr4IAAAAVFBMVEUAAACHjojlOy5NWlrKzcYRKjGFjIbp293YycuLa3pYY2LSqql4f3pCUFTgSjNodYRmcXUsPD/NTTbjRS+2jomhgnzNc223cGvZS0HaSD0XLjbaSjElhIr+AAAAAXRSTlMAQObYZgAAAHlJREFUCNdNyosOwyAIhWHAQS1Vt7a77/3fcxxdmv0xwmckutAR1nkm4ggbyEcg/wWmlGLDAA3oL50xi6fk5ffZ3E2E3QfZDCcCN2YtbEWZt+Drc6u6rlqv7Uk0LdKqqr5rk2UCRXOk0vmQKGfc94nOJyQjouF9H/wCc9gECEYfONoAAAAASUVORK5CYII=)](https://scala-steward.org)

# Sharry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@ package sharry.backend.config
import cats.data.{Validated, ValidatedNec}
import cats.syntax.all._

import sharry.common.ByteSize
import sharry.common.Ident
import sharry.store.FileStoreConfig

case class FilesConfig(
defaultStore: Ident,
stores: Map[Ident, FileStoreConfig],
copyFiles: CopyFilesConfig,
downloadChunkSize: ByteSize
copyFiles: CopyFilesConfig
) {

val enabledStores: Map[Ident, FileStoreConfig] =
Expand Down
10 changes: 6 additions & 4 deletions modules/restserver/src/main/resources/reference.conf
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ sharry.restserver {
port = ${?SHARRY_BIND_PORT}
}

file-download {
# For open range requests, use this amount of data when
# responding.
download-chunk-size = "4M"
}

# Configures logging
logging {
# The format for the log messages. Can be one of:
Expand Down Expand Up @@ -358,10 +364,6 @@ sharry.restserver {
# How many files to copy in parallel.
parallel = 2
}

# For open range requests, use this amount of data when
# responding.
download-chunk-size = "4M"
}

# Checksums of uploaded files are computed in the background.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ case class Config(
baseUrl: LenientUri,
aliasMemberEnabled: Boolean,
bind: Config.Bind,
fileDownload: Config.FileDownload,
logging: LogConfig,
webapp: Config.Webapp,
backend: BackendConfig
Expand Down Expand Up @@ -61,6 +62,10 @@ object Config {

case class Bind(address: Host, port: Port)

case class FileDownload(
downloadChunkSize: ByteSize
)

case class Webapp(
appName: String,
appIcon: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,14 @@ object ByteResponse {
val isHead = req.method == Method.HEAD
val data = if (!isHead) file.data else Stream.empty
etagResponse(dsl, req, file).getOrElseF(
Ok(data)
Ok.apply(data)
.map(setETag(file.fileMeta))
.map(
_.putHeaders(
`Content-Type`(mediaType(file)),
`Accept-Ranges`.bytes,
`Last-Modified`(timestamp(file)),
`Content-Disposition`("inline", fileNameMap(file)),
`Content-Length`(file.fileMeta.length.bytes),
fileSizeHeader(file.fileMeta.length)
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ object OpenShareRoutes {

case req @ GET -> Root / Ident(id) / "file" / Ident(fid) =>
val pw = SharryPassword(req)
val chunkSize = cfg.backend.files.downloadChunkSize
val chunkSize = cfg.fileDownload.downloadChunkSize
ByteResponse(dsl, req, backend, ShareId.publish(id), pw, chunkSize, fid)

case req @ HEAD -> Root / Ident(id) / "file" / Ident(fid) =>
val pw = SharryPassword(req)
val chunkSize = cfg.backend.files.downloadChunkSize
val chunkSize = cfg.fileDownload.downloadChunkSize
ByteResponse(dsl, req, backend, ShareId.publish(id), pw, chunkSize, fid)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ object ShareRoutes {

case req @ GET -> Root / Ident(id) / "file" / Ident(fid) =>
val pw = SharryPassword(req)
val chunkSize = cfg.backend.files.downloadChunkSize
val chunkSize = cfg.fileDownload.downloadChunkSize
ByteResponse(
dsl,
req,
Expand All @@ -84,7 +84,7 @@ object ShareRoutes {

case req @ HEAD -> Root / Ident(id) / "file" / Ident(fid) =>
val pw = SharryPassword(req)
val chunkSize = cfg.backend.files.downloadChunkSize
val chunkSize = cfg.fileDownload.downloadChunkSize
ByteResponse(
dsl,
req,
Expand Down
Loading