diff --git a/server/internal/api/authenticator/authenticator.go b/server/internal/api/authenticator/authenticator.go
index 54a0cd74..cb62f00d 100644
--- a/server/internal/api/authenticator/authenticator.go
+++ b/server/internal/api/authenticator/authenticator.go
@@ -6,8 +6,8 @@ import (
"strings"
"github.com/gin-gonic/gin"
+ "github.com/shroff/phylum/server/internal/core"
"github.com/shroff/phylum/server/internal/core/errors"
- "github.com/shroff/phylum/server/internal/core/fs"
"github.com/shroff/phylum/server/internal/core/user"
)
@@ -24,12 +24,12 @@ func GetUser(c *gin.Context) user.User {
return val.(user.User)
}
-func GetFileSystem(c *gin.Context) fs.FileSystem {
+func GetFileSystem(c *gin.Context) core.FileSystem {
val, ok := c.Get(keyFileSystem)
if !ok {
return nil
}
- return val.(fs.FileSystem)
+ return val.(core.FileSystem)
}
func Require(c *gin.Context) {
diff --git a/server/internal/api/publink/publink.go b/server/internal/api/publink/publink.go
index 1e4e6cb5..2dd7f3b2 100644
--- a/server/internal/api/publink/publink.go
+++ b/server/internal/api/publink/publink.go
@@ -6,7 +6,7 @@ import (
"github.com/gin-gonic/gin"
"github.com/shroff/phylum/server/internal/api/serve"
- "github.com/shroff/phylum/server/internal/core/fs"
+ "github.com/shroff/phylum/server/internal/core"
)
func Setup(r *gin.RouterGroup) {
@@ -15,18 +15,18 @@ func Setup(r *gin.RouterGroup) {
path := c.Param("path")
_, password, _ := c.Request.BasicAuth()
- f, err := fs.OpenFromPublink(c.Request.Context(), id, password)
+ f, err := core.OpenFromPublink(c.Request.Context(), id, password)
if err != nil {
- if errors.Is(err, fs.ErrInsufficientPermissions) {
+ if errors.Is(err, core.ErrInsufficientPermissions) {
c.Header("WWW-Authenticate", "Basic realm=\""+id+"\"")
c.AbortWithStatus(http.StatusUnauthorized)
- } else if errors.Is(err, fs.ErrResourceNotFound) {
+ } else if errors.Is(err, core.ErrResourceNotFound) {
c.AbortWithStatus(http.StatusNotFound)
} else {
c.AbortWithStatus(http.StatusInternalServerError)
}
} else if r, err := f.ResourceByPath(path); err != nil {
- if errors.Is(err, fs.ErrResourceNotFound) {
+ if errors.Is(err, core.ErrResourceNotFound) {
c.AbortWithStatus(http.StatusNotFound)
} else {
c.AbortWithStatus(http.StatusInternalServerError)
diff --git a/server/internal/api/serve/serve.go b/server/internal/api/serve/serve.go
index e6d9a80c..3a344630 100644
--- a/server/internal/api/serve/serve.go
+++ b/server/internal/api/serve/serve.go
@@ -13,7 +13,7 @@ import (
"time"
"github.com/google/uuid"
- "github.com/shroff/phylum/server/internal/core/fs"
+ "github.com/shroff/phylum/server/internal/core"
"github.com/shroff/phylum/server/internal/core/storage"
)
@@ -28,11 +28,11 @@ var htmlReplacer = strings.NewReplacer(
)
type FileSystem interface {
- ReadDir(fs.Resource, bool) ([]fs.Resource, error)
- FindVersion(fs.Resource, uuid.UUID) (fs.Version, error)
+ ReadDir(core.Resource, bool) ([]core.Resource, error)
+ FindVersion(core.Resource, uuid.UUID) (core.Version, error)
}
-func Serve(w http.ResponseWriter, r *http.Request, f FileSystem, res fs.Resource) {
+func Serve(w http.ResponseWriter, r *http.Request, f FileSystem, res core.Resource) {
if res.Dir() {
serveCollection(w, r, f, res)
} else {
@@ -40,7 +40,7 @@ func Serve(w http.ResponseWriter, r *http.Request, f FileSystem, res fs.Resource
}
}
-func serveCollection(w http.ResponseWriter, r *http.Request, f FileSystem, file fs.Resource) {
+func serveCollection(w http.ResponseWriter, r *http.Request, f FileSystem, file core.Resource) {
if !strings.HasSuffix(r.URL.Path, "/") {
http.Redirect(w, r, r.URL.String()+"/", http.StatusMovedPermanently)
return
@@ -110,7 +110,7 @@ func formatSize(size int) string {
return fmt.Sprintf("%d%s", size, suffix[si])
}
-func ServeResourceVersion(w http.ResponseWriter, r *http.Request, f FileSystem, res fs.Resource, versionID uuid.UUID) {
+func ServeResourceVersion(w http.ResponseWriter, r *http.Request, f FileSystem, res core.Resource, versionID uuid.UUID) {
if versionID == uuid.Nil {
versionID = res.LatestVersion().ID
}
@@ -269,7 +269,7 @@ func parseRange(s string, size int) ([]httpRange, error) {
// checkPreconditions evaluates request preconditions and reports whether a precondition
// resulted in sending StatusNotModified or StatusPreconditionFailed.
-func checkPreconditions(w http.ResponseWriter, r *http.Request, v fs.VersionInfo) (done bool, rangeHeader string) {
+func checkPreconditions(w http.ResponseWriter, r *http.Request, v core.VersionInfo) (done bool, rangeHeader string) {
// This function carefully follows RFC 7232 section 6.
ch := checkIfMatch(r, v)
if ch == condNone {
@@ -352,7 +352,7 @@ const (
condFalse
)
-func checkIfMatch(r *http.Request, v fs.VersionInfo) condResult {
+func checkIfMatch(r *http.Request, v core.VersionInfo) condResult {
im := r.Header.Get("If-Match")
if im == "" {
return condNone
@@ -382,7 +382,7 @@ func checkIfMatch(r *http.Request, v fs.VersionInfo) condResult {
return condFalse
}
-func checkIfUnmodifiedSince(r *http.Request, v fs.VersionInfo) condResult {
+func checkIfUnmodifiedSince(r *http.Request, v core.VersionInfo) condResult {
ius := r.Header.Get("If-Unmodified-Since")
if ius == "" {
return condNone
@@ -400,7 +400,7 @@ func checkIfUnmodifiedSince(r *http.Request, v fs.VersionInfo) condResult {
return condFalse
}
-func checkIfNoneMatch(r *http.Request, v fs.VersionInfo) condResult {
+func checkIfNoneMatch(r *http.Request, v core.VersionInfo) condResult {
inm := r.Header.Get("If-None-Match")
if inm == "" {
return condNone
@@ -430,7 +430,7 @@ func checkIfNoneMatch(r *http.Request, v fs.VersionInfo) condResult {
return condTrue
}
-func checkIfModifiedSince(r *http.Request, v fs.VersionInfo) condResult {
+func checkIfModifiedSince(r *http.Request, v core.VersionInfo) condResult {
if r.Method != "GET" && r.Method != "HEAD" {
return condNone
}
@@ -450,7 +450,7 @@ func checkIfModifiedSince(r *http.Request, v fs.VersionInfo) condResult {
return condTrue
}
-func checkIfRange(r *http.Request, v fs.VersionInfo) condResult {
+func checkIfRange(r *http.Request, v core.VersionInfo) condResult {
if r.Method != "GET" && r.Method != "HEAD" {
return condNone
}
diff --git a/server/internal/api/v1/fs/contents.go b/server/internal/api/v1/fs/contents.go
index 00fcabe6..d669352a 100644
--- a/server/internal/api/v1/fs/contents.go
+++ b/server/internal/api/v1/fs/contents.go
@@ -9,8 +9,8 @@ import (
"github.com/google/uuid"
"github.com/shroff/phylum/server/internal/api/authenticator"
"github.com/shroff/phylum/server/internal/api/serve"
+ "github.com/shroff/phylum/server/internal/core"
"github.com/shroff/phylum/server/internal/core/errors"
- "github.com/shroff/phylum/server/internal/core/fs"
)
var errGetCollectionContents = errors.NewError(http.StatusBadRequest, "resource_is_collection", "Cannot get contents of collection")
@@ -61,7 +61,7 @@ func handleContentsRequest(c *gin.Context) {
var zip = zip.NewWriter(c.Writer)
close := c.Writer.CloseNotify()
- err = f.Walk(r, 2, func(r fs.Resource, p string) error {
+ err = f.Walk(r, 2, func(r core.Resource, p string) error {
if r.Dir() {
return nil
}
diff --git a/server/internal/api/v1/fs/copy.go b/server/internal/api/v1/fs/copy.go
index 9c3f20ca..a77bd4ac 100644
--- a/server/internal/api/v1/fs/copy.go
+++ b/server/internal/api/v1/fs/copy.go
@@ -5,15 +5,15 @@ import (
"github.com/google/uuid"
"github.com/shroff/phylum/server/internal/api/authenticator"
"github.com/shroff/phylum/server/internal/api/v1/responses"
- "github.com/shroff/phylum/server/internal/core/fs"
+ "github.com/shroff/phylum/server/internal/core"
)
type copyParams struct {
- Src string `json:"src" form:"src" binding:"required"`
- Dest string `json:"dest" form:"dest" binding:"required"`
- ID uuid.UUID `json:"id" form:"id"`
- VersionID uuid.UUID `json:"version_id" form:"id"`
- Conflict fs.ResourceBindConflictResolution `json:"conflict" form:"conflict"`
+ Src string `json:"src" form:"src" binding:"required"`
+ Dest string `json:"dest" form:"dest" binding:"required"`
+ ID uuid.UUID `json:"id" form:"id"`
+ VersionID uuid.UUID `json:"version_id" form:"id"`
+ Conflict core.ResourceBindConflictResolution `json:"conflict" form:"conflict"`
}
func handleCopyRequest(c *gin.Context) {
diff --git a/server/internal/api/v1/fs/mkdir.go b/server/internal/api/v1/fs/mkdir.go
index f80a98e7..6afd4fce 100644
--- a/server/internal/api/v1/fs/mkdir.go
+++ b/server/internal/api/v1/fs/mkdir.go
@@ -5,14 +5,14 @@ import (
"github.com/google/uuid"
"github.com/shroff/phylum/server/internal/api/authenticator"
"github.com/shroff/phylum/server/internal/api/v1/responses"
- "github.com/shroff/phylum/server/internal/core/fs"
+ "github.com/shroff/phylum/server/internal/core"
)
type mkdirParams struct {
- Path string `json:"path" form:"path" binding:"required"`
- CreateParents bool `json:"create_parents" form:"create_parents"`
- ID uuid.UUID `json:"id" form:"id"`
- Conflict fs.ResourceBindConflictResolution `json:"conflict" form:"conflict"`
+ Path string `json:"path" form:"path" binding:"required"`
+ CreateParents bool `json:"create_parents" form:"create_parents"`
+ ID uuid.UUID `json:"id" form:"id"`
+ Conflict core.ResourceBindConflictResolution `json:"conflict" form:"conflict"`
}
func handleMkdirRequest(c *gin.Context) {
diff --git a/server/internal/api/v1/fs/move.go b/server/internal/api/v1/fs/move.go
index 4753c58f..903fdcbb 100644
--- a/server/internal/api/v1/fs/move.go
+++ b/server/internal/api/v1/fs/move.go
@@ -4,13 +4,13 @@ import (
"github.com/gin-gonic/gin"
"github.com/shroff/phylum/server/internal/api/authenticator"
"github.com/shroff/phylum/server/internal/api/v1/responses"
- "github.com/shroff/phylum/server/internal/core/fs"
+ "github.com/shroff/phylum/server/internal/core"
)
type moveParams struct {
- Src string `json:"src" form:"src" binding:"required"`
- Dest string `json:"dest" form:"dest" binding:"required"`
- Conflict fs.ResourceBindConflictResolution `json:"conflict" form:"conflict"`
+ Src string `json:"src" form:"src" binding:"required"`
+ Dest string `json:"dest" form:"dest" binding:"required"`
+ Conflict core.ResourceBindConflictResolution `json:"conflict" form:"conflict"`
}
func handleMoveRequest(c *gin.Context) {
diff --git a/server/internal/api/v1/fs/share.go b/server/internal/api/v1/fs/share.go
index c8c75ee4..07f689be 100644
--- a/server/internal/api/v1/fs/share.go
+++ b/server/internal/api/v1/fs/share.go
@@ -4,14 +4,14 @@ import (
"github.com/gin-gonic/gin"
"github.com/shroff/phylum/server/internal/api/authenticator"
"github.com/shroff/phylum/server/internal/api/v1/responses"
- "github.com/shroff/phylum/server/internal/core/fs"
+ "github.com/shroff/phylum/server/internal/core"
"github.com/shroff/phylum/server/internal/core/user"
)
type shareParams struct {
- Path string `json:"path" form:"path" binding:"required"`
- Email string `json:"email" form:"email" binding:"required"`
- Permission fs.Permission `json:"permission" form:"permission"`
+ Path string `json:"path" form:"path" binding:"required"`
+ Email string `json:"email" form:"email" binding:"required"`
+ Permission core.Permission `json:"permission" form:"permission"`
}
func handleShareRequest(c *gin.Context) {
diff --git a/server/internal/api/v1/fs/upload.go b/server/internal/api/v1/fs/upload.go
index 124adcfa..add6ded0 100644
--- a/server/internal/api/v1/fs/upload.go
+++ b/server/internal/api/v1/fs/upload.go
@@ -8,16 +8,16 @@ import (
"github.com/google/uuid"
"github.com/shroff/phylum/server/internal/api/authenticator"
"github.com/shroff/phylum/server/internal/api/v1/responses"
- "github.com/shroff/phylum/server/internal/core/fs"
+ "github.com/shroff/phylum/server/internal/core"
)
type uploadParams struct {
- Path string `json:"path" form:"path" binding:"required"`
- ID string `json:"id" form:"id" binding:"omitempty,uuid"`
- VersionID string `json:"version_id" form:"version_id" binding:"omitempty,uuid"`
- CreateParents bool `json:"create_parents" form:"create_parents"`
- Conflict fs.ResourceBindConflictResolution `json:"conflict" form:"conflict"`
- SHA256 string `json:"sha256" form:"sha256"`
+ Path string `json:"path" form:"path" binding:"required"`
+ ID string `json:"id" form:"id" binding:"omitempty,uuid"`
+ VersionID string `json:"version_id" form:"version_id" binding:"omitempty,uuid"`
+ CreateParents bool `json:"create_parents" form:"create_parents"`
+ Conflict core.ResourceBindConflictResolution `json:"conflict" form:"conflict"`
+ SHA256 string `json:"sha256" form:"sha256"`
}
func handleUploadRequest(c *gin.Context) {
@@ -44,7 +44,7 @@ func handleUploadRequest(c *gin.Context) {
// TODO: Calculate and verify sha sum
f := authenticator.GetFileSystem(c)
- err = f.RunInTx(func(f fs.FileSystem) error {
+ err = f.RunInTx(func(f core.FileSystem) error {
res, err := f.CreateResourceByPath(params.Path, id, false, params.CreateParents, params.Conflict)
if err != nil {
return err
diff --git a/server/internal/api/v1/responses/helpers.go b/server/internal/api/v1/responses/helpers.go
index a371b48f..75568184 100644
--- a/server/internal/api/v1/responses/helpers.go
+++ b/server/internal/api/v1/responses/helpers.go
@@ -1,8 +1,8 @@
package responses
-import "github.com/shroff/phylum/server/internal/core/fs"
+import "github.com/shroff/phylum/server/internal/core"
-func FullResourceFromFS(f fs.FileSystem, r fs.Resource) ResourceFull {
+func FullResourceFromFS(f core.FileSystem, r core.Resource) ResourceFull {
response := ResourceFull{
Resource: ResourceFromFS(r),
}
@@ -32,7 +32,7 @@ func FullResourceFromFS(f fs.FileSystem, r fs.Resource) ResourceFull {
return response
}
-func ResourceFromFS(r fs.Resource) Resource {
+func ResourceFromFS(r core.Resource) Resource {
var deleted int64 = 0
if r.Deleted().Valid {
deleted = r.Deleted().Time.UnixMilli()
@@ -52,7 +52,7 @@ func ResourceFromFS(r fs.Resource) Resource {
}
}
-func PublinkFromFS(p fs.Publink) Publink {
+func PublinkFromFS(p core.Publink) Publink {
return Publink{
ID: p.ID,
Created: p.Created,
diff --git a/server/internal/api/webdav/handler.go b/server/internal/api/webdav/handler.go
index 619bcbe3..e456e01a 100644
--- a/server/internal/api/webdav/handler.go
+++ b/server/internal/api/webdav/handler.go
@@ -8,7 +8,7 @@ import (
"github.com/google/uuid"
"github.com/jackc/pgx/v5/pgtype"
webdav "github.com/shroff/phylum/server/internal/api/webdav/impl"
- "github.com/shroff/phylum/server/internal/core/fs"
+ "github.com/shroff/phylum/server/internal/core"
"github.com/shroff/phylum/server/internal/core/user"
"github.com/sirupsen/logrus"
)
@@ -41,7 +41,7 @@ func SetupHandler(r *gin.RouterGroup) {
func (h *handler) HandleRequest(c *gin.Context) {
authSuccess := false
- var f fs.FileSystem
+ var f core.FileSystem
if email, pass, ok := c.Request.BasicAuth(); ok {
ctx := c.Request.Context()
userManager := user.ManagerFromContext(ctx)
diff --git a/server/internal/api/webdav/impl/copy_move.go b/server/internal/api/webdav/impl/copy_move.go
index 8acf472e..833dc7e3 100644
--- a/server/internal/api/webdav/impl/copy_move.go
+++ b/server/internal/api/webdav/impl/copy_move.go
@@ -5,8 +5,8 @@ import (
"net/url"
"github.com/google/uuid"
+ "github.com/shroff/phylum/server/internal/core"
"github.com/shroff/phylum/server/internal/core/errors"
- "github.com/shroff/phylum/server/internal/core/fs"
)
func (h *Handler) handleCopyMove(_ http.ResponseWriter, r *http.Request) (status int, err error) {
@@ -91,9 +91,9 @@ func moveFiles(f FileSystem, srcPath, dstPath string, overwrite bool) (status in
}
return http.StatusInternalServerError, err
} else {
- var conflictResolution fs.ResourceBindConflictResolution = fs.ResourceBindConflictResolutionError
+ var conflictResolution core.ResourceBindConflictResolution = core.ResourceBindConflictResolutionError
if overwrite {
- conflictResolution = fs.ResourceBindConflictResolutionDelete
+ conflictResolution = core.ResourceBindConflictResolutionDelete
}
if _, deleted, err := f.Move(src, dstPath, conflictResolution); err != nil {
if e, ok := err.(*errors.Error); ok {
@@ -121,9 +121,9 @@ func copyFiles(f FileSystem, srcPath, dstPath string, overwrite bool, depth int)
return http.StatusInternalServerError, err
} else {
id, _ := uuid.NewV7()
- var conflictResolution fs.ResourceBindConflictResolution = fs.ResourceBindConflictResolutionError
+ var conflictResolution core.ResourceBindConflictResolution = core.ResourceBindConflictResolutionError
if overwrite {
- conflictResolution = fs.ResourceBindConflictResolutionOverwrite
+ conflictResolution = core.ResourceBindConflictResolutionOverwrite
}
if _, deleted, err := f.Copy(src, dstPath, id, depth != 0, conflictResolution); err != nil {
if e, ok := err.(*errors.Error); ok {
diff --git a/server/internal/api/webdav/impl/prop.go b/server/internal/api/webdav/impl/prop.go
index 8c334dd7..9d27ad8c 100644
--- a/server/internal/api/webdav/impl/prop.go
+++ b/server/internal/api/webdav/impl/prop.go
@@ -10,7 +10,7 @@ import (
"net/http"
"strconv"
- "github.com/shroff/phylum/server/internal/core/fs"
+ "github.com/shroff/phylum/server/internal/core"
)
// Proppatch describes a property update instruction as defined in RFC 4918.
@@ -69,7 +69,7 @@ func makePropstats(x, y Propstat) []Propstat {
var liveProps = map[xml.Name]struct {
// findFn implements the propfind function of this property. If nil,
// it indicates a hidden property.
- findFn func(fs.Resource) string
+ findFn func(core.Resource) string
// dir is true if the property applies to directories.
dir bool
}{
@@ -132,7 +132,7 @@ var liveProps = map[xml.Name]struct {
//
// Each Propstat has a unique status and each property name will only be part
// of one Propstat element.
-func props(fs FileSystem, ls LockSystem, fi fs.Resource, pnames []xml.Name) ([]Propstat, error) {
+func props(fs FileSystem, ls LockSystem, fi core.Resource, pnames []xml.Name) ([]Propstat, error) {
pstatOK := Propstat{Status: http.StatusOK}
pstatNotFound := Propstat{Status: http.StatusNotFound}
for _, pn := range pnames {
@@ -153,7 +153,7 @@ func props(fs FileSystem, ls LockSystem, fi fs.Resource, pnames []xml.Name) ([]P
}
// propnames returns the property names defined for resource name.
-func propnames(fs FileSystem, ls LockSystem, fi fs.Resource) ([]xml.Name, error) {
+func propnames(fs FileSystem, ls LockSystem, fi core.Resource) ([]xml.Name, error) {
pnames := make([]xml.Name, 0, len(liveProps))
for pn, prop := range liveProps {
if prop.findFn != nil && (prop.dir || !fi.Dir()) {
@@ -171,7 +171,7 @@ func propnames(fs FileSystem, ls LockSystem, fi fs.Resource) ([]xml.Name, error)
// returned if they are named in 'include'.
//
// See http://www.webdav.org/specs/rfc4918.html#METHOD_PROPFIND
-func allprop(fs FileSystem, ls LockSystem, fi fs.Resource, include []xml.Name) ([]Propstat, error) {
+func allprop(fs FileSystem, ls LockSystem, fi core.Resource, include []xml.Name) ([]Propstat, error) {
pnames, err := propnames(fs, ls, fi)
if err != nil {
return nil, err
@@ -252,38 +252,38 @@ func escapeXML(s string) string {
return s
}
-func findResourceType(fi fs.Resource) string {
+func findResourceType(fi core.Resource) string {
if fi.Dir() {
return ``
}
return ""
}
-func findDisplayName(fi fs.Resource) string {
+func findDisplayName(fi core.Resource) string {
return escapeXML(fi.Name())
}
-func findContentLength(fi fs.Resource) string {
+func findContentLength(fi core.Resource) string {
return strconv.Itoa(int(fi.LatestVersion().Size))
}
-func findCreationDate(fi fs.Resource) string {
+func findCreationDate(fi core.Resource) string {
return fi.Created().UTC().Format(http.TimeFormat)
}
-func findLastModified(fi fs.Resource) string {
+func findLastModified(fi core.Resource) string {
return fi.Modified().UTC().Format(http.TimeFormat)
}
-func findContentType(fi fs.Resource) string {
+func findContentType(fi core.Resource) string {
return fi.LatestVersion().MimeType
}
-func findETag(fi fs.Resource) string {
+func findETag(fi core.Resource) string {
return fi.LatestVersion().SHA256
}
-func findSupportedLock(fi fs.Resource) string {
+func findSupportedLock(fi core.Resource) string {
return `` +
`` +
`` +
diff --git a/server/internal/api/webdav/impl/webdav.go b/server/internal/api/webdav/impl/webdav.go
index a38530a5..f2e503c8 100644
--- a/server/internal/api/webdav/impl/webdav.go
+++ b/server/internal/api/webdav/impl/webdav.go
@@ -17,7 +17,7 @@ import (
"github.com/google/uuid"
"github.com/shroff/phylum/server/internal/api/serve"
- "github.com/shroff/phylum/server/internal/core/fs"
+ "github.com/shroff/phylum/server/internal/core"
)
type Handler struct {
@@ -36,13 +36,13 @@ type Handler struct {
// in a file path are separated by slash ('/', U+002F) characters, regardless
// of host operating system convention.
type FileSystem interface {
- fs.ROFileSystem
+ core.ROFileSystem
- CreateResourceByPath(name string, id uuid.UUID, dir, recursive bool, conflictResolution fs.ResourceBindConflictResolution) (fs.Resource, error)
- OpenWrite(fs.Resource, uuid.UUID) (io.WriteCloser, error)
- Copy(fs.Resource, string, uuid.UUID, bool, fs.ResourceBindConflictResolution) (fs.Resource, bool, error)
- Move(fs.Resource, string, fs.ResourceBindConflictResolution) (fs.Resource, bool, error)
- DeleteRecursive(fs.Resource, bool) (fs.Resource, error)
+ CreateResourceByPath(name string, id uuid.UUID, dir, recursive bool, conflictResolution core.ResourceBindConflictResolution) (core.Resource, error)
+ OpenWrite(core.Resource, uuid.UUID) (io.WriteCloser, error)
+ Copy(core.Resource, string, uuid.UUID, bool, core.ResourceBindConflictResolution) (core.Resource, bool, error)
+ Move(core.Resource, string, core.ResourceBindConflictResolution) (core.Resource, bool, error)
+ DeleteRecursive(core.Resource, bool) (core.Resource, error)
}
func (h *Handler) stripPrefix(p string) (string, int, error) {
@@ -242,7 +242,7 @@ func (h *Handler) handleDelete(_ http.ResponseWriter, r *http.Request) (status i
defer release()
if r, err := h.FileSystem.ResourceByPath(reqPath); err != nil {
- if errors.Is(err, fs.ErrResourceNotFound) {
+ if errors.Is(err, core.ErrResourceNotFound) {
return http.StatusNotFound, err
}
return http.StatusMethodNotAllowed, err
@@ -265,12 +265,12 @@ func (h *Handler) handlePut(w http.ResponseWriter, r *http.Request) (status int,
// TODO(rost): Support the If-Match, If-None-Match headers? See bradfitz'
// comments in http.checkEtag.
- res, err := h.FileSystem.CreateResourceByPath(reqPath, uuid.Nil, false, false, fs.ResourceBindConflictResolutionEnsure)
+ res, err := h.FileSystem.CreateResourceByPath(reqPath, uuid.Nil, false, false, core.ResourceBindConflictResolutionEnsure)
if err != nil {
- if errors.Is(err, fs.ErrParentNotFound) {
+ if errors.Is(err, core.ErrParentNotFound) {
return http.StatusConflict, err
- } else if errors.Is(err, fs.ErrResourceCollection) {
- return http.StatusConflict, fs.ErrResourceCollection
+ } else if errors.Is(err, core.ErrResourceCollection) {
+ return http.StatusConflict, core.ErrResourceCollection
}
return http.StatusNotFound, err
}
@@ -306,8 +306,8 @@ func (h *Handler) handleMkcol(_ http.ResponseWriter, r *http.Request) (status in
if r.ContentLength > 0 {
return http.StatusUnsupportedMediaType, nil
}
- if _, err := h.FileSystem.CreateResourceByPath(reqPath, uuid.Nil, true, false, fs.ResourceBindConflictResolutionError); err != nil {
- if errors.Is(err, fs.ErrParentNotFound) {
+ if _, err := h.FileSystem.CreateResourceByPath(reqPath, uuid.Nil, true, false, core.ResourceBindConflictResolutionError); err != nil {
+ if errors.Is(err, core.ErrParentNotFound) {
return http.StatusConflict, err
}
return http.StatusMethodNotAllowed, err
@@ -383,9 +383,9 @@ func (h *Handler) handleLock(w http.ResponseWriter, r *http.Request) (retStatus
// Create the resource if it didn't previously exist.
if _, err := h.FileSystem.ResourceByPath(reqPath); err != nil {
- _, err = h.FileSystem.CreateResourceByPath(reqPath, uuid.Nil, false, false, fs.ResourceBindConflictResolutionEnsure)
+ _, err = h.FileSystem.CreateResourceByPath(reqPath, uuid.Nil, false, false, core.ResourceBindConflictResolutionEnsure)
if err != nil {
- if errors.Is(err, fs.ErrParentNotFound) {
+ if errors.Is(err, core.ErrParentNotFound) {
return http.StatusConflict, err
}
return http.StatusNotFound, err
@@ -439,7 +439,7 @@ func (h *Handler) handlePropfind(w http.ResponseWriter, request *http.Request) (
}
fi, err := h.FileSystem.ResourceByPath(reqPath)
if err != nil {
- if errors.Is(err, fs.ErrResourceNotFound) {
+ if errors.Is(err, core.ErrResourceNotFound) {
return http.StatusNotFound, err
}
return http.StatusMethodNotAllowed, err
@@ -458,7 +458,7 @@ func (h *Handler) handlePropfind(w http.ResponseWriter, request *http.Request) (
mw := multistatusWriter{w: w}
- writePropStat := func(r fs.Resource, p string) error {
+ writePropStat := func(r core.Resource, p string) error {
var pstats []Propstat
if pf.Propname != nil {
pnames, err := propnames(h.FileSystem, h.LockSystem, r)
@@ -508,7 +508,7 @@ func (h *Handler) handleProppatch(w http.ResponseWriter, r *http.Request) (statu
defer release()
if _, err := h.FileSystem.ResourceByPath(reqPath); err != nil {
- if errors.Is(err, fs.ErrResourceNotFound) {
+ if errors.Is(err, core.ErrResourceNotFound) {
return http.StatusNotFound, err
}
return http.StatusMethodNotAllowed, err
diff --git a/server/internal/command/admin/user/mod.go b/server/internal/command/admin/user/mod.go
index 6962ad3f..ede0cac4 100644
--- a/server/internal/command/admin/user/mod.go
+++ b/server/internal/command/admin/user/mod.go
@@ -6,8 +6,8 @@ import (
"os"
"github.com/jackc/pgx/v5/pgtype"
+ "github.com/shroff/phylum/server/internal/core"
"github.com/shroff/phylum/server/internal/core/db"
- "github.com/shroff/phylum/server/internal/core/fs"
"github.com/shroff/phylum/server/internal/core/user"
"github.com/spf13/cobra"
)
@@ -27,7 +27,7 @@ func setupModCommand() *cobra.Command {
name, _ := cmd.Flags().GetString("name")
- f := fs.OpenOmniscient(db.Get(context.Background()))
+ f := core.OpenOmniscient(db.Get(context.Background()))
var homeID pgtype.UUID
path, _ := cmd.Flags().GetString("home")
if path != "" {
diff --git a/server/internal/command/common/common.go b/server/internal/command/common/common.go
index 98fcf60e..91da98f6 100644
--- a/server/internal/command/common/common.go
+++ b/server/internal/command/common/common.go
@@ -5,14 +5,14 @@ import (
"fmt"
"os"
+ "github.com/shroff/phylum/server/internal/core"
"github.com/shroff/phylum/server/internal/core/db"
- "github.com/shroff/phylum/server/internal/core/fs"
"github.com/shroff/phylum/server/internal/core/user"
"github.com/spf13/cobra"
)
var u *user.User
-var f fs.FileSystem
+var f core.FileSystem
func User(cmd *cobra.Command) *user.User {
if u == nil {
@@ -33,11 +33,11 @@ func User(cmd *cobra.Command) *user.User {
return u
}
-func UserFileSystem(cmd *cobra.Command) fs.FileSystem {
+func UserFileSystem(cmd *cobra.Command) core.FileSystem {
if f == nil {
user := User(cmd)
if user == nil {
- f = fs.OpenOmniscient(db.Get(context.Background()))
+ f = core.OpenOmniscient(db.Get(context.Background()))
} else {
f = user.OpenFileSystem(context.Background())
}
diff --git a/server/internal/command/common/format.go b/server/internal/command/common/format.go
index 72e7c599..5021a356 100644
--- a/server/internal/command/common/format.go
+++ b/server/internal/command/common/format.go
@@ -6,10 +6,10 @@ import (
"strings"
"github.com/jackc/pgx/v5/pgtype"
- "github.com/shroff/phylum/server/internal/core/fs"
+ "github.com/shroff/phylum/server/internal/core"
)
-func FormatResourceSummary(r fs.Resource, name string, deleted pgtype.Timestamp) string {
+func FormatResourceSummary(r core.Resource, name string, deleted pgtype.Timestamp) string {
if name == "" {
name = r.Name()
}
@@ -55,21 +55,21 @@ func formatGrantsJson(j []byte) string {
return "[" + strings.Join(perm, ", ") + "]"
}
-func FormatPermission(p fs.Permission) string {
- if p == fs.PermissionSU {
+func FormatPermission(p core.Permission) string {
+ if p == core.PermissionSU {
return "su"
}
str := ""
- if p&fs.PermissionRead != 0 {
- p -= fs.PermissionRead
+ if p&core.PermissionRead != 0 {
+ p -= core.PermissionRead
str += "r"
}
- if p&fs.PermissionWrite != 0 {
- p -= fs.PermissionWrite
+ if p&core.PermissionWrite != 0 {
+ p -= core.PermissionWrite
str += "w"
}
- if p&fs.PermissionShare != 0 {
- p -= fs.PermissionShare
+ if p&core.PermissionShare != 0 {
+ p -= core.PermissionShare
str += "s"
}
if p != 0 {
diff --git a/server/internal/command/fs/cp.go b/server/internal/command/fs/cp.go
index 8ca4611b..4248ed06 100644
--- a/server/internal/command/fs/cp.go
+++ b/server/internal/command/fs/cp.go
@@ -6,7 +6,7 @@ import (
"github.com/google/uuid"
"github.com/shroff/phylum/server/internal/command/common"
- "github.com/shroff/phylum/server/internal/core/fs"
+ "github.com/shroff/phylum/server/internal/core"
"github.com/spf13/cobra"
)
@@ -33,9 +33,9 @@ func setupCpCommand() *cobra.Command {
}
id, _ := uuid.NewV7()
- var conflictResolution fs.ResourceBindConflictResolution = fs.ResourceBindConflictResolutionError
+ var conflictResolution core.ResourceBindConflictResolution = core.ResourceBindConflictResolutionError
if force {
- conflictResolution = fs.ResourceBindConflictResolutionOverwrite
+ conflictResolution = core.ResourceBindConflictResolutionOverwrite
}
if _, _, err := f.Copy(src, args[1], id, true, conflictResolution); err != nil {
fmt.Println("cannot copy'" + srcPath + "' to '" + args[1] + "': " + err.Error())
diff --git a/server/internal/command/fs/import.go b/server/internal/command/fs/import.go
index a3a41006..6dce6547 100644
--- a/server/internal/command/fs/import.go
+++ b/server/internal/command/fs/import.go
@@ -10,7 +10,7 @@ import (
"github.com/google/uuid"
"github.com/shroff/phylum/server/internal/command/common"
- "github.com/shroff/phylum/server/internal/core/fs"
+ "github.com/shroff/phylum/server/internal/core"
"github.com/spf13/cobra"
)
@@ -32,7 +32,7 @@ func setupImportCommand() *cobra.Command {
destName := stat.Name()
if len(args) > 2 {
destName = args[2]
- if fs.CheckNameInvalid(destName) {
+ if core.CheckNameInvalid(destName) {
fmt.Println("invalid name: '" + destName + "'")
}
}
@@ -47,7 +47,7 @@ func setupImportCommand() *cobra.Command {
force, _ := cmd.Flags().GetBool("force")
var size int = 0
- create := make([]fs.CreateResourcesParams, 0)
+ create := make([]core.CreateResourcesParams, 0)
copy := make(map[string]uuid.UUID)
ids := make(map[string]uuid.UUID)
targetRootID, _ := uuid.NewV7()
@@ -67,12 +67,12 @@ func setupImportCommand() *cobra.Command {
len = 0
}
size += len
- if fs.CheckNameInvalid(d.Name()) {
- return fs.ErrResourceNameInvalid
+ if core.CheckNameInvalid(d.Name()) {
+ return core.ErrResourceNameInvalid
}
ids[p], _ = uuid.NewV7()
parent := ids[path.Dir(p)]
- create = append(create, fs.CreateResourcesParams{
+ create = append(create, core.CreateResourcesParams{
Parent: parent,
ID: ids[p],
Name: d.Name(),
@@ -92,13 +92,13 @@ func setupImportCommand() *cobra.Command {
}
fmt.Printf("Importing %d files (%d bytes) across %d dirs\n", len(copy), size, 1+len(create)-len(copy))
- var conflictResolution fs.ResourceBindConflictResolution = fs.ResourceBindConflictResolutionError
+ var conflictResolution core.ResourceBindConflictResolution = core.ResourceBindConflictResolutionError
if force {
- conflictResolution = fs.ResourceBindConflictResolutionDelete
+ conflictResolution = core.ResourceBindConflictResolutionDelete
}
- err = f.RunInTx(func(f fs.FileSystem) error {
+ err = f.RunInTx(func(f core.FileSystem) error {
if _, err = f.CreateResourceByPath(args[1]+"/"+destName, targetRootID, stat.IsDir(), false, conflictResolution); err != nil {
- if err == fs.ErrResourceNameConflict {
+ if err == core.ErrResourceNameConflict {
err = errors.New("resource with name '" + destName + "' already exist. use -f to overwrite")
}
return err
@@ -128,7 +128,7 @@ func setupImportCommand() *cobra.Command {
return &cmd
}
-func copyContents(f fs.FileSystem, src string, id uuid.UUID) error {
+func copyContents(f core.FileSystem, src string, id uuid.UUID) error {
fmt.Println("importing " + src + " to " + id.String())
in, err := os.Open(src)
if err != nil {
diff --git a/server/internal/command/fs/ls.go b/server/internal/command/fs/ls.go
index e1620e96..e5379356 100644
--- a/server/internal/command/fs/ls.go
+++ b/server/internal/command/fs/ls.go
@@ -10,7 +10,7 @@ import (
"github.com/jackc/pgx/v5/pgtype"
"github.com/shroff/phylum/server/internal/command/common"
- "github.com/shroff/phylum/server/internal/core/fs"
+ "github.com/shroff/phylum/server/internal/core"
"github.com/spf13/cobra"
)
@@ -72,7 +72,7 @@ func setupLsCommand() *cobra.Command {
}
func formatPermissionsJson(j []byte) string {
- p := make(map[string]fs.Permission)
+ p := make(map[string]core.Permission)
json.Unmarshal(j, &p)
if len(p) == 0 {
return ""
@@ -85,8 +85,8 @@ func formatPermissionsJson(j []byte) string {
}
type Grant struct {
- Permission fs.Permission `json:"p"`
- Timestamp int `json:"t"`
+ Permission core.Permission `json:"p"`
+ Timestamp int `json:"t"`
}
func formatGrantsJson(j []byte) string {
diff --git a/server/internal/command/fs/mkdir.go b/server/internal/command/fs/mkdir.go
index dcc1e4c7..ff6324c5 100644
--- a/server/internal/command/fs/mkdir.go
+++ b/server/internal/command/fs/mkdir.go
@@ -6,7 +6,7 @@ import (
"github.com/google/uuid"
"github.com/shroff/phylum/server/internal/command/common"
- "github.com/shroff/phylum/server/internal/core/fs"
+ "github.com/shroff/phylum/server/internal/core"
"github.com/spf13/cobra"
)
@@ -19,14 +19,14 @@ func setupMkdirCommand() *cobra.Command {
f := common.UserFileSystem(cmd)
path := args[0]
var recursive bool
- var conflict fs.ResourceBindConflictResolution = fs.ResourceBindConflictResolutionError
+ var conflict core.ResourceBindConflictResolution = core.ResourceBindConflictResolutionError
if b, err := cmd.Flags().GetBool("parents"); err != nil {
fmt.Println("could not read flag 'parents': " + err.Error())
os.Exit(1)
} else {
recursive = b
if recursive {
- conflict = fs.ResourceBindConflictResolutionEnsure
+ conflict = core.ResourceBindConflictResolutionEnsure
}
}
if _, err := f.CreateResourceByPath(path, uuid.Nil, true, recursive, conflict); err != nil {
diff --git a/server/internal/command/fs/mv.go b/server/internal/command/fs/mv.go
index 2e128dee..2b37b84e 100644
--- a/server/internal/command/fs/mv.go
+++ b/server/internal/command/fs/mv.go
@@ -5,7 +5,7 @@ import (
"os"
"github.com/shroff/phylum/server/internal/command/common"
- "github.com/shroff/phylum/server/internal/core/fs"
+ "github.com/shroff/phylum/server/internal/core"
"github.com/spf13/cobra"
)
@@ -25,9 +25,9 @@ func setupMvCommand() *cobra.Command {
force, _ := cmd.Flags().GetBool("force")
- var conflictResolution fs.ResourceBindConflictResolution = fs.ResourceBindConflictResolutionError
+ var conflictResolution core.ResourceBindConflictResolution = core.ResourceBindConflictResolutionError
if force {
- conflictResolution = fs.ResourceBindConflictResolutionDelete
+ conflictResolution = core.ResourceBindConflictResolutionDelete
}
if _, _, err := f.Move(src, args[1], conflictResolution); err != nil {
fmt.Println("cannot move'" + srcPath + "' to '" + args[1] + "': " + err.Error())
diff --git a/server/internal/command/fs/publink/create.go b/server/internal/command/fs/publink/create.go
index 42a77fd3..544c7a29 100644
--- a/server/internal/command/fs/publink/create.go
+++ b/server/internal/command/fs/publink/create.go
@@ -7,7 +7,7 @@ import (
"github.com/jackc/pgx/v5/pgtype"
"github.com/shroff/phylum/server/internal/command/common"
- "github.com/shroff/phylum/server/internal/core/fs"
+ "github.com/shroff/phylum/server/internal/core"
"github.com/spf13/cobra"
)
@@ -32,7 +32,7 @@ func setupCreateCommand() *cobra.Command {
return &cmd
}
-func createPublink(f fs.FileSystem, name, path string, password string, durationStr string, accesses int) error {
+func createPublink(f core.FileSystem, name, path string, password string, durationStr string, accesses int) error {
r, err := f.ResourceByPathWithRoot(path)
if err != nil {
return err
diff --git a/server/internal/command/fs/setfacl.go b/server/internal/command/fs/setfacl.go
index a4c2edca..a96b942f 100644
--- a/server/internal/command/fs/setfacl.go
+++ b/server/internal/command/fs/setfacl.go
@@ -7,7 +7,7 @@ import (
"os"
"github.com/shroff/phylum/server/internal/command/common"
- "github.com/shroff/phylum/server/internal/core/fs"
+ "github.com/shroff/phylum/server/internal/core"
"github.com/shroff/phylum/server/internal/core/user"
"github.com/spf13/cobra"
)
@@ -47,16 +47,16 @@ func setupSetfaclCommand() *cobra.Command {
return &cmd
}
-func parsePermissionString(s string) (fs.Permission, error) {
+func parsePermissionString(s string) (core.Permission, error) {
switch s {
case "none":
- return fs.PermissionNone, nil
+ return core.PermissionNone, nil
case "read":
- return fs.PermissionRead, nil
+ return core.PermissionRead, nil
case "write":
- return fs.PermissionRead | fs.PermissionWrite, nil
+ return core.PermissionRead | core.PermissionWrite, nil
case "share":
- return fs.PermissionRead | fs.PermissionWrite | fs.PermissionShare, nil
+ return core.PermissionRead | core.PermissionWrite | core.PermissionShare, nil
}
- return fs.PermissionNone, errors.New("unrecognized permission: " + s)
+ return core.PermissionNone, errors.New("unrecognized permission: " + s)
}
diff --git a/server/internal/command/fs/trash/summary.go b/server/internal/command/fs/trash/summary.go
index 2a4e2e26..a2b4c0cb 100644
--- a/server/internal/command/fs/trash/summary.go
+++ b/server/internal/command/fs/trash/summary.go
@@ -5,7 +5,7 @@ import (
"os"
"github.com/shroff/phylum/server/internal/command/common"
- "github.com/shroff/phylum/server/internal/core/fs"
+ "github.com/shroff/phylum/server/internal/core"
"github.com/spf13/cobra"
)
@@ -22,7 +22,7 @@ func setupSummaryCommand() *cobra.Command {
return &cmd
}
-func printTrashSummary(f fs.FileSystem) {
+func printTrashSummary(f core.FileSystem) {
items, size, err := f.TrashSummary()
if err != nil {
fmt.Println("cannot get trash summary: " + err.Error())
diff --git a/server/internal/command/serve/cmd.go b/server/internal/command/serve/cmd.go
index 237fe69f..498c85fa 100644
--- a/server/internal/command/serve/cmd.go
+++ b/server/internal/command/serve/cmd.go
@@ -14,7 +14,7 @@ import (
"github.com/shroff/phylum/server/internal/api/publink"
apiv1 "github.com/shroff/phylum/server/internal/api/v1"
"github.com/shroff/phylum/server/internal/api/webdav"
- "github.com/shroff/phylum/server/internal/core/fs"
+ "github.com/shroff/phylum/server/internal/core"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)
@@ -106,8 +106,8 @@ func setupTrashCompactor() {
go func() {
for {
<-ticker.C
- fs.TrashCompact(context.Background(), trashRetainDuration)
+ core.TrashCompact(context.Background(), trashRetainDuration)
}
}()
- fs.TrashCompact(context.Background(), trashRetainDuration)
+ core.TrashCompact(context.Background(), trashRetainDuration)
}
diff --git a/server/internal/core/fs/ancestors.go b/server/internal/core/ancestors.go
similarity index 99%
rename from server/internal/core/fs/ancestors.go
rename to server/internal/core/ancestors.go
index 9be519a1..13b85e06 100644
--- a/server/internal/core/fs/ancestors.go
+++ b/server/internal/core/ancestors.go
@@ -1,4 +1,4 @@
-package fs
+package core
import (
"strings"
diff --git a/server/internal/core/fs/copy_move.go b/server/internal/core/copy_move.go
similarity index 99%
rename from server/internal/core/fs/copy_move.go
rename to server/internal/core/copy_move.go
index 05c2190a..24cfddd5 100644
--- a/server/internal/core/fs/copy_move.go
+++ b/server/internal/core/copy_move.go
@@ -1,4 +1,4 @@
-package fs
+package core
import (
"errors"
diff --git a/server/internal/core/fs/create.go b/server/internal/core/create.go
similarity index 99%
rename from server/internal/core/fs/create.go
rename to server/internal/core/create.go
index 9fd10de5..14ed1658 100644
--- a/server/internal/core/fs/create.go
+++ b/server/internal/core/create.go
@@ -1,4 +1,4 @@
-package fs
+package core
import (
"errors"
diff --git a/server/internal/core/fs/create_resources.go b/server/internal/core/create_resources.go
similarity index 98%
rename from server/internal/core/fs/create_resources.go
rename to server/internal/core/create_resources.go
index 3813b892..9d3f16a7 100644
--- a/server/internal/core/fs/create_resources.go
+++ b/server/internal/core/create_resources.go
@@ -1,4 +1,4 @@
-package fs
+package core
import (
"github.com/google/uuid"
diff --git a/server/internal/core/fs/delete.go b/server/internal/core/delete.go
similarity index 99%
rename from server/internal/core/fs/delete.go
rename to server/internal/core/delete.go
index 87e09688..d1fc5f73 100644
--- a/server/internal/core/fs/delete.go
+++ b/server/internal/core/delete.go
@@ -1,4 +1,4 @@
-package fs
+package core
import (
"errors"
diff --git a/server/internal/core/fs/disk_usage.go b/server/internal/core/disk_usage.go
similarity index 98%
rename from server/internal/core/fs/disk_usage.go
rename to server/internal/core/disk_usage.go
index f88e622a..297bb3f0 100644
--- a/server/internal/core/fs/disk_usage.go
+++ b/server/internal/core/disk_usage.go
@@ -1,4 +1,4 @@
-package fs
+package core
import (
"github.com/doug-martin/goqu/v9"
diff --git a/server/internal/core/fs/errors.go b/server/internal/core/errors.go
similarity index 99%
rename from server/internal/core/fs/errors.go
rename to server/internal/core/errors.go
index 420b7e7b..9ef38dfa 100644
--- a/server/internal/core/fs/errors.go
+++ b/server/internal/core/errors.go
@@ -1,4 +1,4 @@
-package fs
+package core
import (
"net/http"
diff --git a/server/internal/core/fs/filesystem.go b/server/internal/core/filesystem.go
similarity index 98%
rename from server/internal/core/fs/filesystem.go
rename to server/internal/core/filesystem.go
index f64671ac..36364c1f 100644
--- a/server/internal/core/fs/filesystem.go
+++ b/server/internal/core/filesystem.go
@@ -1,4 +1,4 @@
-package fs
+package core
import (
"github.com/jackc/pgx/v5/pgtype"
diff --git a/server/internal/core/fs/find.go b/server/internal/core/find.go
similarity index 99%
rename from server/internal/core/fs/find.go
rename to server/internal/core/find.go
index a20f563d..3ee4976f 100644
--- a/server/internal/core/fs/find.go
+++ b/server/internal/core/find.go
@@ -1,4 +1,4 @@
-package fs
+package core
import (
"strings"
diff --git a/server/internal/core/fs/fs.go b/server/internal/core/fs.go
similarity index 99%
rename from server/internal/core/fs/fs.go
rename to server/internal/core/fs.go
index f7d717b5..a3e3f364 100644
--- a/server/internal/core/fs/fs.go
+++ b/server/internal/core/fs.go
@@ -1,4 +1,4 @@
-package fs
+package core
import (
"context"
diff --git a/server/internal/core/fs/open.go b/server/internal/core/open.go
similarity index 99%
rename from server/internal/core/fs/open.go
rename to server/internal/core/open.go
index 9be310cd..d9520c2c 100644
--- a/server/internal/core/fs/open.go
+++ b/server/internal/core/open.go
@@ -1,4 +1,4 @@
-package fs
+package core
import (
"encoding/hex"
diff --git a/server/internal/core/fs/permissions.go b/server/internal/core/permissions.go
similarity index 99%
rename from server/internal/core/fs/permissions.go
rename to server/internal/core/permissions.go
index 02918255..f4c69d66 100644
--- a/server/internal/core/fs/permissions.go
+++ b/server/internal/core/permissions.go
@@ -1,4 +1,4 @@
-package fs
+package core
import (
"github.com/google/uuid"
diff --git a/server/internal/core/fs/publink.go b/server/internal/core/publink.go
similarity index 99%
rename from server/internal/core/fs/publink.go
rename to server/internal/core/publink.go
index 69ce6259..b0734da8 100644
--- a/server/internal/core/fs/publink.go
+++ b/server/internal/core/publink.go
@@ -1,4 +1,4 @@
-package fs
+package core
import (
"strings"
diff --git a/server/internal/core/fs/resource.go b/server/internal/core/resource.go
similarity index 99%
rename from server/internal/core/fs/resource.go
rename to server/internal/core/resource.go
index b1443b8b..b35e423c 100644
--- a/server/internal/core/fs/resource.go
+++ b/server/internal/core/resource.go
@@ -1,4 +1,4 @@
-package fs
+package core
import (
"encoding/json"
diff --git a/server/internal/core/fs/search.go b/server/internal/core/search.go
similarity index 98%
rename from server/internal/core/fs/search.go
rename to server/internal/core/search.go
index 6f9baa72..e97469fe 100644
--- a/server/internal/core/fs/search.go
+++ b/server/internal/core/search.go
@@ -1,4 +1,4 @@
-package fs
+package core
import (
"strings"
diff --git a/server/internal/core/fs/shared.go b/server/internal/core/shared.go
similarity index 97%
rename from server/internal/core/fs/shared.go
rename to server/internal/core/shared.go
index ea9b3de8..3f714697 100644
--- a/server/internal/core/fs/shared.go
+++ b/server/internal/core/shared.go
@@ -1,4 +1,4 @@
-package fs
+package core
import (
"github.com/jackc/pgx/v5"
diff --git a/server/internal/core/fs/sql_common.go b/server/internal/core/sql_common.go
similarity index 99%
rename from server/internal/core/fs/sql_common.go
rename to server/internal/core/sql_common.go
index 644e3b6a..4e3c688d 100644
--- a/server/internal/core/fs/sql_common.go
+++ b/server/internal/core/sql_common.go
@@ -1,4 +1,4 @@
-package fs
+package core
import (
"slices"
diff --git a/server/internal/core/fs/trash_compact.go b/server/internal/core/trash_compact.go
similarity index 98%
rename from server/internal/core/fs/trash_compact.go
rename to server/internal/core/trash_compact.go
index a14c6420..17caaf22 100644
--- a/server/internal/core/fs/trash_compact.go
+++ b/server/internal/core/trash_compact.go
@@ -1,4 +1,4 @@
-package fs
+package core
import (
"context"
diff --git a/server/internal/core/fs/trash_list.go b/server/internal/core/trash_list.go
similarity index 99%
rename from server/internal/core/fs/trash_list.go
rename to server/internal/core/trash_list.go
index 63ecd1bd..8e43afa4 100644
--- a/server/internal/core/fs/trash_list.go
+++ b/server/internal/core/trash_list.go
@@ -1,4 +1,4 @@
-package fs
+package core
import (
"encoding/base64"
diff --git a/server/internal/core/fs/trash_summary_empty.go b/server/internal/core/trash_summary_empty.go
similarity index 98%
rename from server/internal/core/fs/trash_summary_empty.go
rename to server/internal/core/trash_summary_empty.go
index 60886dfa..2cd392cd 100644
--- a/server/internal/core/fs/trash_summary_empty.go
+++ b/server/internal/core/trash_summary_empty.go
@@ -1,4 +1,4 @@
-package fs
+package core
import (
"github.com/doug-martin/goqu/v9"
diff --git a/server/internal/core/fs/update.go b/server/internal/core/update.go
similarity index 98%
rename from server/internal/core/fs/update.go
rename to server/internal/core/update.go
index c50d5d2d..da1ed072 100644
--- a/server/internal/core/fs/update.go
+++ b/server/internal/core/update.go
@@ -1,4 +1,4 @@
-package fs
+package core
import (
"github.com/google/uuid"
diff --git a/server/internal/core/user/bookmarks.go b/server/internal/core/user/bookmarks.go
index acf84129..30a6ba1c 100644
--- a/server/internal/core/user/bookmarks.go
+++ b/server/internal/core/user/bookmarks.go
@@ -6,7 +6,7 @@ import (
"github.com/google/uuid"
"github.com/jackc/pgx/v5"
- "github.com/shroff/phylum/server/internal/core/fs"
+ "github.com/shroff/phylum/server/internal/core"
)
type Bookmark struct {
@@ -29,12 +29,12 @@ func scanBookmark(row pgx.CollectableRow) (Bookmark, error) {
return p, nil
}
-func (m manager) AddBookmark(u User, resource fs.Resource, name string) (Bookmark, error) {
+func (m manager) AddBookmark(u User, resource core.Resource, name string) (Bookmark, error) {
if name == "" {
name = resource.Name()
}
- if fs.CheckNameInvalid(name) {
- return Bookmark{}, fs.ErrResourceNameInvalid
+ if core.CheckNameInvalid(name) {
+ return Bookmark{}, core.ErrResourceNameInvalid
}
const q = `INSERT INTO bookmarks(user_id, resource_id, name, dir)
diff --git a/server/internal/core/user/create.go b/server/internal/core/user/create.go
index 77d61c7f..bd8448b7 100644
--- a/server/internal/core/user/create.go
+++ b/server/internal/core/user/create.go
@@ -7,9 +7,9 @@ import (
"github.com/google/uuid"
"github.com/jackc/pgx/v5"
"github.com/jackc/pgx/v5/pgtype"
+ "github.com/shroff/phylum/server/internal/core"
"github.com/shroff/phylum/server/internal/core/db"
"github.com/shroff/phylum/server/internal/core/errors"
- "github.com/shroff/phylum/server/internal/core/fs"
)
var errInvalidEmailAddress = errors.NewError(http.StatusBadRequest, "invalid_email_address", "Invalid email address")
@@ -21,12 +21,12 @@ func (m manager) CreateUser(email, name string, noCreateHome bool) (User, error)
m := m.withDb(db)
var err error
var homeID pgtype.UUID
- var home fs.Resource
- f := fs.OpenOmniscient(db)
+ var home core.Resource
+ f := core.OpenOmniscient(db)
if !noCreateHome {
var err error
homePath := strings.TrimRight(Cfg.BaseDir, "/") + "/" + email
- home, err = f.CreateResourceByPath(homePath, uuid.Nil, true, true, fs.ResourceBindConflictResolutionEnsure)
+ home, err = f.CreateResourceByPath(homePath, uuid.Nil, true, true, core.ResourceBindConflictResolutionEnsure)
if err != nil {
return err
}
@@ -39,7 +39,7 @@ func (m manager) CreateUser(email, name string, noCreateHome bool) (User, error)
}
if homeID.Valid {
- if _, err := f.UpdatePermissions(home, user.ID, fs.PermissionRead|fs.PermissionWrite|fs.PermissionShare); err != nil {
+ if _, err := f.UpdatePermissions(home, user.ID, core.PermissionRead|core.PermissionWrite|core.PermissionShare); err != nil {
return err
}
}
diff --git a/server/internal/core/user/user.go b/server/internal/core/user/user.go
index 269c05c5..c46af776 100644
--- a/server/internal/core/user/user.go
+++ b/server/internal/core/user/user.go
@@ -6,7 +6,7 @@ import (
"github.com/google/uuid"
"github.com/jackc/pgx/v5"
"github.com/jackc/pgx/v5/pgtype"
- "github.com/shroff/phylum/server/internal/core/fs"
+ "github.com/shroff/phylum/server/internal/core"
)
var Cfg Config
@@ -31,8 +31,8 @@ func scanUser(row pgx.CollectableRow) (User, error) {
return u, err
}
-func (u User) OpenFileSystem(ctx context.Context) fs.FileSystem {
- return fs.Open(ctx, u.ID, u.Home, u.Permissions&PermissionFilesAll != 0)
+func (u User) OpenFileSystem(ctx context.Context) core.FileSystem {
+ return core.Open(ctx, u.ID, u.Home, u.Permissions&PermissionFilesAll != 0)
}
type Manager interface {
@@ -61,7 +61,7 @@ type Manager interface {
ResetUserPassword(user User, token, password string) error
// bookmarks.go
- AddBookmark(u User, resource fs.Resource, name string) (Bookmark, error)
+ AddBookmark(u User, resource core.Resource, name string) (Bookmark, error)
RemoveBookmark(u User, id uuid.UUID) error
ListBookmarks(u User, since int64) ([]Bookmark, error)
}
diff --git a/server/internal/core/fs/util.go b/server/internal/core/util.go
similarity index 98%
rename from server/internal/core/fs/util.go
rename to server/internal/core/util.go
index 85171f1c..bb1d4da8 100644
--- a/server/internal/core/fs/util.go
+++ b/server/internal/core/util.go
@@ -1,4 +1,4 @@
-package fs
+package core
import (
"crypto/sha256"
diff --git a/server/internal/core/fs/version.go b/server/internal/core/version.go
similarity index 98%
rename from server/internal/core/fs/version.go
rename to server/internal/core/version.go
index 124935ab..dfd2afd8 100644
--- a/server/internal/core/fs/version.go
+++ b/server/internal/core/version.go
@@ -1,4 +1,4 @@
-package fs
+package core
import (
"errors"