feat: directory permissions

This commit is contained in:
2025-06-03 11:20:29 +03:00
parent 3bd2f28150
commit dc52153fb4
2 changed files with 35 additions and 8 deletions
+8 -3
View File
@@ -14,36 +14,41 @@ type HttpFS struct {
remoteStorage remote.Storage
}
type Option func(*HttpFS)
type HttpFSOption func(*HttpFS)
// WithRemoteStorage
func WithRemoteStorage(storage remote.Storage) Option {
func WithRemoteStorage(storage remote.Storage) HttpFSOption {
return func(httpFS *HttpFS) {
httpFS.remoteStorage = storage
}
}
// NewHttpFS
func NewHttpFS(dir string, opts ...Option) (*HttpFS, error) {
func NewHttpFS(dir string, opts ...HttpFSOption) (*HttpFS, error) {
store, err := NewStore(dir)
if err != nil {
return nil, err
}
f := &HttpFS{store: store}
for _, opt := range opts {
if opt != nil {
opt(f)
}
}
return f, nil
}
// Open
func (f *HttpFS) Open(name string) (http.File, error) {
n := strings.TrimPrefix(name, "/")
if f.remoteStorage != nil {
return f.remoteStorage.Open(name)
}
return f.store.Open(n)
}