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

Method GetByPath

agent/app/service/file_share.go:242–259  ·  view source on GitHub ↗
(path string)

Source from the content-addressed store, hash-verified

240}
241
242func (s *FileShareService) GetByPath(path string) (*response.FileShareInfo, error) {
243 item, err := fileShareRepo.GetFirst(fileShareRepo.WithByPath(strings.TrimSpace(path)))
244 if err != nil {
245 if errors.Is(err, gorm.ErrRecordNotFound) {
246 return nil, nil
247 }
248 return nil, err
249 }
250 if err := s.pruneInvalidShare(item); err != nil {
251 return nil, err
252 }
253 if item.ExpiresUnix > 0 && time.Now().Unix() > item.ExpiresUnix {
254 return nil, nil
255 }
256 info := shareModelToInfo(item)
257 fillSharePassword(&info, item)
258 return &info, nil
259}
260
261func (s *FileShareService) GetByCode(code string) (*response.FileShareInfo, error) {
262 item, err := fileShareRepo.GetFirst(fileShareRepo.WithByCode(strings.TrimSpace(code)))

Callers

nothing calls this directly

Calls 6

pruneInvalidShareMethod · 0.95
shareModelToInfoFunction · 0.85
fillSharePasswordFunction · 0.85
IsMethod · 0.80
GetFirstMethod · 0.65
WithByPathMethod · 0.65

Tested by

no test coverage detected