diff options
| author | Jeff Halter <868228+jhalter@users.noreply.github.com> | 2026-07-08 09:11:10 -0700 |
|---|---|---|
| committer | Jeff Halter <868228+jhalter@users.noreply.github.com> | 2026-07-08 09:11:10 -0700 |
| commit | a42a5961861f638fef3b49685fc6df2eea38fa0d (patch) | |
| tree | e16775a6c135c78cdbb77f99296a34494c44c122 /hotline/server.go | |
| parent | bba70d0a2903ab1fff5a2e89cff97cb1f6c7f82a (diff) | |
Decouple FileStore from *os.File for object-store backends
The FileStore interface returned concrete *os.File from Open/Create/
OpenFile, which no non-filesystem backend (e.g. S3/R2) can produce, and
many file-library hot paths bypassed the interface entirely with direct
os.* / filepath.Walk calls.
Widen the interface to return io.ReadCloser / io.WriteCloser and add
ReadDir, ReadLink, and Walk so directory traversal no longer escapes the
abstraction. Route every file-library call site (fork writers, upload/
download handlers, GetFileNameList, CalcTotalSize/CalcItemCount, the set-
file-info folder rename) through the injected FileStore, and add a
WithFileStore option. OSFileStore keeps byte-identical behavior.
DownloadHandler now nil-guards the optional resource-fork reader instead
of relying on *os.File's nil-receiver tolerance, so a backend returning an
untyped-nil reader does not panic.
Diffstat (limited to 'hotline/server.go')
| -rw-r--r-- | hotline/server.go | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/hotline/server.go b/hotline/server.go index 020f878..14cee04 100644 --- a/hotline/server.go +++ b/hotline/server.go @@ -141,6 +141,13 @@ func WithPresenceTracker(p PresenceTracker) func(s *Server) { } } +// WithFileStore sets the storage backend for the file library. Defaults to OSFileStore. +func WithFileStore(fs FileStore) func(s *Server) { + return func(s *Server) { + s.FS = fs + } +} + // WithTLS optionally enables TLS support on the specified port. func WithTLS(tlsConfig *tls.Config, port int) func(s *Server) { return func(s *Server) { |