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

Method GetPublicByCode

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

Source from the content-addressed store, hash-verified

277}
278
279func (s *FileShareService) GetPublicByCode(code string) (*response.FileSharePublicInfo, error) {
280 item, err := fileShareRepo.GetFirst(fileShareRepo.WithByCode(strings.TrimSpace(code)))
281 if err != nil {
282 if errors.Is(err, gorm.ErrRecordNotFound) {
283 return nil, buserr.New("ErrFileShareInvalid")
284 }
285 return nil, err
286 }
287 if err := s.pruneInvalidShare(item); err != nil {
288 return nil, err
289 }
290 if item.ExpiresUnix > 0 && time.Now().Unix() > item.ExpiresUnix {
291 return nil, buserr.New("ErrFileShareExpired")
292 }
293 info := shareModelToPublicInfo(item)
294 return &info, nil
295}
296
297func (s *FileShareService) DeleteByPath(path string) error {
298 item, err := fileShareRepo.GetFirst(fileShareRepo.WithByPath(strings.TrimSpace(path)))

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected