MCPcopy Create free account
hub / github.com/1Panel-dev/1Panel / GetByCode

Method GetByCode

agent/app/service/file_share.go:261–277  ·  view source on GitHub ↗
(code string)

Source from the content-addressed store, hash-verified

259}
260
261func (s *FileShareService) GetByCode(code string) (*response.FileShareInfo, error) {
262 item, err := fileShareRepo.GetFirst(fileShareRepo.WithByCode(strings.TrimSpace(code)))
263 if err != nil {
264 if errors.Is(err, gorm.ErrRecordNotFound) {
265 return nil, buserr.New("ErrFileShareInvalid")
266 }
267 return nil, err
268 }
269 if err := s.pruneInvalidShare(item); err != nil {
270 return nil, err
271 }
272 if item.ExpiresUnix > 0 && time.Now().Unix() > item.ExpiresUnix {
273 return nil, buserr.New("ErrFileShareExpired")
274 }
275 info := shareModelToInfo(item)
276 return &info, nil
277}
278
279func (s *FileShareService) GetPublicByCode(code string) (*response.FileSharePublicInfo, error) {
280 item, err := fileShareRepo.GetFirst(fileShareRepo.WithByCode(strings.TrimSpace(code)))

Callers

nothing calls this directly

Calls 5

pruneInvalidShareMethod · 0.95
shareModelToInfoFunction · 0.85
IsMethod · 0.80
GetFirstMethod · 0.65
WithByCodeMethod · 0.65

Tested by

no test coverage detected