(code string)
| 277 | } |
| 278 | |
| 279 | func (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 | |
| 297 | func (s *FileShareService) DeleteByPath(path string) error { |
| 298 | item, err := fileShareRepo.GetFirst(fileShareRepo.WithByPath(strings.TrimSpace(path))) |
nothing calls this directly
no test coverage detected