aboutsummaryrefslogtreecommitdiff
path: root/hotline/file_wrapper.go
diff options
context:
space:
mode:
authorJeff Halter <868228+jhalter@users.noreply.github.com>2026-07-08 09:11:10 -0700
committerJeff Halter <868228+jhalter@users.noreply.github.com>2026-07-08 09:11:10 -0700
commita42a5961861f638fef3b49685fc6df2eea38fa0d (patch)
treee16775a6c135c78cdbb77f99296a34494c44c122 /hotline/file_wrapper.go
parentbba70d0a2903ab1fff5a2e89cff97cb1f6c7f82a (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/file_wrapper.go')
-rw-r--r--hotline/file_wrapper.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/hotline/file_wrapper.go b/hotline/file_wrapper.go
index de3cbe4..4aeaf25 100644
--- a/hotline/file_wrapper.go
+++ b/hotline/file_wrapper.go
@@ -103,7 +103,7 @@ func (f *File) infoForkName() string {
}
func (f *File) rsrcForkWriter() (io.WriteCloser, error) {
- file, err := os.OpenFile(f.rsrcPath, os.O_CREATE|os.O_WRONLY, 0644)
+ file, err := f.fs.OpenFile(f.rsrcPath, os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
return nil, err
}
@@ -112,7 +112,7 @@ func (f *File) rsrcForkWriter() (io.WriteCloser, error) {
}
func (f *File) InfoForkWriter() (io.WriteCloser, error) {
- file, err := os.OpenFile(f.infoPath, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0644)
+ file, err := f.fs.OpenFile(f.infoPath, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0644)
if err != nil {
return nil, err
}
@@ -121,7 +121,7 @@ func (f *File) InfoForkWriter() (io.WriteCloser, error) {
}
func (f *File) incFileWriter() (io.WriteCloser, error) {
- file, err := os.OpenFile(f.incompletePath, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0644)
+ file, err := f.fs.OpenFile(f.incompletePath, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0644)
if err != nil {
return nil, err
}
@@ -137,7 +137,7 @@ func (f *File) dataForkReader() (io.Reader, error) {
return f.fs.Open(f.incompletePath)
}
-func (f *File) rsrcForkFile() (*os.File, error) {
+func (f *File) rsrcForkFile() (io.ReadCloser, error) {
return f.fs.Open(f.rsrcPath)
}