Skip to content

Commit

Permalink
feat(mux): add KnownFSTypes to list filesystem prefixes
Browse files Browse the repository at this point in the history
this makes it possible to iterate a common set of supported prefix types. Exporting this string
slice as the return value of a function gives us the opportunity to declare an interface for
modifying prefixes registered with the muxfs packaage in the future
  • Loading branch information
b5 committed Nov 17, 2020
1 parent 20e9e18 commit f5c12e4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion adder.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

// ErrNotAddingFS is the canonical error to return when the AddingFS extension
// interface is required but not available
var ErrNotAddingFS = errors.New("This filesystem doesn't support batched adding")
var ErrNotAddingFS = errors.New("this filesystem doesn't support batched adding")

// AddedFile reports on the results of adding a file to the store
type AddedFile struct {
Expand Down
4 changes: 0 additions & 4 deletions fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ var (
ErrReadOnly = errors.New("readonly filesystem")
)

// func init() {
// logger.SetLogLevel("qfs", "debug")
// }

// PathResolver is the "get" portion of a Filesystem
type PathResolver interface {
Get(ctx context.Context, path string) (File, error)
Expand Down
12 changes: 11 additions & 1 deletion muxfs/mux.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,21 @@ func (m *Mux) Filesystem(fsType string) qfs.Filesystem {
return m.handlers[fsType]
}

// KnownFSTypes gives the set of filesystems known to muxfs.New
func KnownFSTypes() []string {
return []string{
httpfs.FilestoreType,
qipfs.FilestoreType,
localfs.FilestoreType,
qfs.MemFilestoreType,
}
}

// constructors maps filesystem type strings to constructor functions
var constructors = map[string]qfs.Constructor{
httpfs.FilestoreType: httpfs.NewFilesystem,
qipfs.FilestoreType: qipfs.NewFilesystem,
localfs.FilestoreType: localfs.NewFilesystem,
httpfs.FilestoreType: httpfs.NewFilesystem,
qfs.MemFilestoreType: qfs.NewMemFilesystem,
}

Expand Down

0 comments on commit f5c12e4

Please sign in to comment.