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

Function GetSharingById

internal/op/sharing.go:45–72  ·  view source on GitHub ↗
(id string, refresh ...bool)

Source from the content-addressed store, hash-verified

43var sharingG singleflight.Group[*model.Sharing]
44
45func GetSharingById(id string, refresh ...bool) (*model.Sharing, error) {
46 if !utils.IsBool(refresh...) {
47 if sharing, ok := sharingCache.Get(id); ok {
48 log.Debugf("use cache when get sharing %s", id)
49 return sharing, nil
50 }
51 }
52 sharing, err, _ := sharingG.Do(id, func() (*model.Sharing, error) {
53 s, err := db.GetSharingById(id)
54 if err != nil {
55 return nil, errors.WithMessagef(err, "failed get sharing [%s]", id)
56 }
57 creator, err := GetUserById(s.CreatorId)
58 if err != nil {
59 return nil, errors.WithMessagef(err, "failed get sharing creator [%s]", id)
60 }
61 var files []string
62 if err = utils.Json.UnmarshalFromString(s.FilesRaw, &files); err != nil {
63 files = make([]string, 0)
64 }
65 return &model.Sharing{
66 SharingDB: s,
67 Files: files,
68 Creator: creator,
69 }, nil
70 })
71 return sharing, err
72}
73
74func GetSharings(pageIndex, pageSize int) ([]model.Sharing, int64, error) {
75 s, cnt, err := db.GetSharings(pageIndex, pageSize)

Callers 11

archiveMetaFunction · 0.92
archiveListFunction · 0.92
linkFunction · 0.92
getFunction · 0.92
listFunction · 0.92
SharingDownFunction · 0.92
SharingArchiveExtractFunction · 0.92
GetSharingFunction · 0.92
UpdateSharingFunction · 0.92
DeleteSharingFunction · 0.92
SetEnableSharingFunction · 0.92

Calls 5

IsBoolFunction · 0.92
GetSharingByIdFunction · 0.92
GetUserByIdFunction · 0.70
GetMethod · 0.65
DoMethod · 0.65

Tested by

no test coverage detected