GetByHash wraps a StorageBackend.GetByHash.
(hash string)
| 70 | |
| 71 | // GetByHash wraps a StorageBackend.GetByHash. |
| 72 | func (s *Storage) GetByHash(hash string) (*Link, error) { |
| 73 | link, err := s.back.GetByHash(hash) |
| 74 | if err != nil { |
| 75 | return nil, err |
| 76 | } |
| 77 | |
| 78 | if link.Expire != 0 && link.Expire <= time.Now().Unix() { |
| 79 | if err := s.Delete(link.Hash); err != nil { |
| 80 | return nil, err |
| 81 | } |
| 82 | return nil, fberrors.ErrNotExist |
| 83 | } |
| 84 | |
| 85 | return link, nil |
| 86 | } |
| 87 | |
| 88 | // GetPermanent wraps a StorageBackend.GetPermanent |
| 89 | func (s *Storage) GetPermanent(path string, id uint) (*Link, error) { |