diff --git a/server/internal/api/serve/serve.go b/server/internal/api/serve/serve.go
index 411804e8..51959dff 100644
--- a/server/internal/api/serve/serve.go
+++ b/server/internal/api/serve/serve.go
@@ -27,7 +27,6 @@ var ErrRangeNotSupported = errors.New("byte range not suppoered")
type ResourceInfo interface {
Name() string
- Path() string
Dir() bool
Created() time.Time
Modified() time.Time
@@ -81,12 +80,12 @@ func serveCollection(w http.ResponseWriter, r *http.Request, file Resource) {
w.Header().Set("Content-Type", "text/html; charset=utf-8")
fmt.Fprintln(w, "")
fmt.Fprintln(w, "
")
- fmt.Fprintf(w, "%s | Phylum\n", file.Path())
+ fmt.Fprintf(w, "%s | Phylum\n", file.Name())
fmt.Fprintln(w, "")
fmt.Fprintln(w, "")
fmt.Fprintln(w, "")
fmt.Fprintln(w, "")
- fmt.Fprintf(w, "Index of %s
", file.Path())
+ fmt.Fprintf(w, "Index of %s
", file.Name())
fmt.Fprintln(w, "
")
fmt.Fprintln(w, "| Name | Size | Content-Type | SHA-256 |
")
fmt.Fprintln(w, "")
diff --git a/server/internal/api/v1/fs/download.go b/server/internal/api/v1/fs/download.go
index 70b136c9..b950d731 100644
--- a/server/internal/api/v1/fs/download.go
+++ b/server/internal/api/v1/fs/download.go
@@ -3,8 +3,6 @@ package fs
import (
"archive/zip"
"io"
- "path"
- "strings"
"github.com/gin-gonic/gin"
"github.com/google/uuid"
@@ -21,14 +19,13 @@ func handleDownloadRequest(c *gin.Context) {
f := auth.GetFileSystem(c)
r, err := f.ResourceByID(resourceID)
- prefix := path.Dir(r.Path())
c.Writer.Header().Set("Content-Type", "application/zip")
c.Writer.Header().Set("Content-Disposition", "attachment; filename=\""+r.Name()+".zip\"")
var zip = zip.NewWriter(c.Writer)
close := c.Writer.CloseNotify()
- err = r.Walk(2, func(r serve.ResourceInfo) error {
+ err = r.Walk(2, func(r serve.ResourceInfo, p string) error {
if r.Dir() {
return nil
}
@@ -39,11 +36,7 @@ func handleDownloadRequest(c *gin.Context) {
default:
}
- path, found := strings.CutPrefix(r.Path(), prefix)
- if !found {
- return fs.ErrResourcePathInvalid
- }
- out, err := zip.Create(path)
+ out, err := zip.Create(p)
if err != nil {
return err
}
diff --git a/server/internal/api/webdav/impl/webdav.go b/server/internal/api/webdav/impl/webdav.go
index 2c05dd73..4ba8280d 100644
--- a/server/internal/api/webdav/impl/webdav.go
+++ b/server/internal/api/webdav/impl/webdav.go
@@ -449,7 +449,7 @@ func (h *Handler) handlePropfind(w http.ResponseWriter, r *http.Request) (status
mw := multistatusWriter{w: w}
- writePropStat := func(r serve.ResourceInfo) error {
+ writePropStat := func(r serve.ResourceInfo, p string) error {
var pstats []Propstat
if pf.Propname != nil {
pnames, err := propnames(h.FileSystem, h.LockSystem, r)
@@ -469,7 +469,7 @@ func (h *Handler) handlePropfind(w http.ResponseWriter, r *http.Request) (status
if err != nil {
return err
}
- href := path.Join(h.Prefix, r.Path())
+ href := path.Join(reqPath, p)
if href != "/" && r.Dir() {
href += "/"
}
diff --git a/server/internal/command/fs/ls.go b/server/internal/command/fs/ls.go
index e8045203..34ad1a3e 100644
--- a/server/internal/command/fs/ls.go
+++ b/server/internal/command/fs/ls.go
@@ -26,7 +26,7 @@ func setupLsCommand() *cobra.Command {
os.Exit(1)
}
- fmt.Println(r.Path() + " " + fullPermissionsString(r))
+ fmt.Println(r.Name() + " " + fullPermissionsString(r))
fmt.Println(formatRow(r.ID().String(), formatSize(r.ContentLength()), r.ContentSHA256(), ".", permissionJsonString(r.Info.Permissions()), r.Info.Publinks()))
if r.Dir() {
diff --git a/server/internal/core/fs/copy_move.go b/server/internal/core/fs/copy_move.go
index 4f8a5303..c96c698b 100644
--- a/server/internal/core/fs/copy_move.go
+++ b/server/internal/core/fs/copy_move.go
@@ -183,11 +183,6 @@ func (r Resource) Copy(target string, id uuid.UUID, recursive bool, conflictReso
}
info := ResourceInfoFromDBResource(root)
- if destParent.Path() == "/" {
- info.path = "/" + info.name
- } else {
- info.path = destParent.Path() + "/" + info.name
- }
ancestry := make([]ResourceInfo, len(destParent.Ancestors)+1)
copy(ancestry, destParent.Ancestors)
diff --git a/server/internal/core/fs/create.go b/server/internal/core/fs/create.go
index 3baedab1..d6b449e1 100644
--- a/server/internal/core/fs/create.go
+++ b/server/internal/core/fs/create.go
@@ -85,11 +85,6 @@ func (r Resource) CreateMemberResource(name string, id uuid.UUID, dir bool, conf
}
info := ResourceInfoFromDBResource(result)
- if r.Path() == "/" {
- info.path = "/" + info.name
- } else {
- info.path = r.Path() + "/" + info.name
- }
ancestry := make([]ResourceInfo, len(r.Ancestors)+1)
copy(ancestry, r.Ancestors)
ancestry = append(ancestry, r.Info)
diff --git a/server/internal/core/fs/find.go b/server/internal/core/fs/find.go
index e8dff79e..a02be7bc 100644
--- a/server/internal/core/fs/find.go
+++ b/server/internal/core/fs/find.go
@@ -44,11 +44,6 @@ func (f filesystem) resourceFromResult(e []db.FullResource, err error) (Resource
b.WriteString(e[i].Name)
}
info = resourceInfoFromDBPublinkedResource(e[i])
- if b.Len() == 0 {
- info.path = "/"
- } else {
- info.path = b.String()
- }
if i != 0 {
ancestry = append(ancestry, info)
}
diff --git a/server/internal/core/fs/open.go b/server/internal/core/fs/open.go
index 19d4346c..124cafac 100644
--- a/server/internal/core/fs/open.go
+++ b/server/internal/core/fs/open.go
@@ -4,7 +4,6 @@ import (
"crypto/sha256"
"io"
- "github.com/google/uuid"
"github.com/shroff/phylum/server/internal/api/serve"
"github.com/shroff/phylum/server/internal/core/db"
)
@@ -51,22 +50,19 @@ func (r Resource) ReadDir(recursive bool) ([]serve.ResourceInfo, error) {
}
result := make([]serve.ResourceInfo, len(children))
- path := make(map[uuid.UUID]string)
- path[r.ID()] = r.Path()
- if r.Path() == "/" {
- path[r.ID()] = ""
- }
for i, c := range children {
info := resourceInfoFromDBPublinkedResource(c)
- info.path = path[*info.parentID] + "/" + info.name
- path[info.id] = info.path
result[i] = info
}
return result, nil
}
-func (r Resource) Walk(depth int, fn func(serve.ResourceInfo) error) error {
- err := fn(r)
+func (r Resource) Walk(depth int, fn func(serve.ResourceInfo, string) error) error {
+ suffix := ""
+ if r.Dir() {
+ suffix = "/"
+ }
+ err := fn(r, suffix)
if err != nil {
return err
}
@@ -80,7 +76,7 @@ func (r Resource) Walk(depth int, fn func(serve.ResourceInfo) error) error {
}
for _, c := range children {
- if err := fn(c); err != nil {
+ if err := fn(c, suffix+r.Name()); err != nil {
return err
}
}
diff --git a/server/internal/core/fs/resource.go b/server/internal/core/fs/resource.go
index e4a695d7..52fde922 100644
--- a/server/internal/core/fs/resource.go
+++ b/server/internal/core/fs/resource.go
@@ -26,7 +26,6 @@ type ResourceInfo struct {
contentSHA256 string
permissions []byte
publinks []byte
- path string
}
func (r Resource) ID() uuid.UUID { return r.Info.id }
@@ -39,7 +38,6 @@ func (r Resource) Deleted() *time.Time { return r.Info.deleted }
func (r Resource) ContentLength() int64 { return r.Info.contentLength }
func (r Resource) ContentSHA256() string { return r.Info.contentSHA256 }
func (r Resource) ContentType() string { return r.Info.contentType }
-func (r Resource) Path() string { return r.Info.path }
func (r Resource) hasPermission(p Permission) bool {
return r.userPermission&p != 0
@@ -57,4 +55,3 @@ func (r ResourceInfo) ContentSHA256() string { return r.contentSHA256 }
func (r ResourceInfo) ContentType() string { return r.contentType }
func (r ResourceInfo) Permissions() []byte { return r.permissions }
func (r ResourceInfo) Publinks() []byte { return r.publinks }
-func (r ResourceInfo) Path() string { return r.path }