(path string)
| 240 | } |
| 241 | |
| 242 | func (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 | |
| 261 | func (s *FileShareService) GetByCode(code string) (*response.FileShareInfo, error) { |
| 262 | item, err := fileShareRepo.GetFirst(fileShareRepo.WithByCode(strings.TrimSpace(code))) |
nothing calls this directly
no test coverage detected