MCPcopy Create free account
hub / github.com/OpenListTeam/OpenList / GetSharingUnwrapPath

Function GetSharingUnwrapPath

internal/op/sharing.go:90–113  ·  view source on GitHub ↗
(sharing *model.Sharing, path string)

Source from the content-addressed store, hash-verified

88}
89
90func GetSharingUnwrapPath(sharing *model.Sharing, path string) (unwrapPath string, err error) {
91 if len(sharing.Files) == 0 {
92 return "", errors.New("cannot get actual path of an invalid sharing")
93 }
94 if len(sharing.Files) == 1 {
95 return stdpath.Join(sharing.Files[0], path), nil
96 }
97 path = utils.FixAndCleanPath(path)[1:]
98 if len(path) == 0 {
99 return "", errors.New("cannot get actual path of a sharing root path")
100 }
101 mapPath := ""
102 child, rest, _ := strings.Cut(path, "/")
103 for _, c := range sharing.Files {
104 if child == stdpath.Base(c) {
105 mapPath = c
106 break
107 }
108 }
109 if mapPath == "" {
110 return "", fmt.Errorf("failed find child [%s] of sharing [%s]", child, sharing.ID)
111 }
112 return stdpath.Join(mapPath, rest), nil
113}
114
115func CreateSharing(sharing *model.Sharing) (id string, err error) {
116 sharing.CreatorId = sharing.Creator.ID

Callers 7

archiveMetaFunction · 0.92
archiveListFunction · 0.92
linkFunction · 0.92
getFunction · 0.92
listFunction · 0.92
SharingDownFunction · 0.92
SharingArchiveExtractFunction · 0.92

Calls 1

FixAndCleanPathFunction · 0.92

Tested by

no test coverage detected