Skip to content
This repository has been archived by the owner on Feb 3, 2024. It is now read-only.

Commit

Permalink
return error if hash not found
Browse files Browse the repository at this point in the history
  • Loading branch information
anonyindian committed Jun 30, 2023
1 parent 709a43a commit 7685213
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ var (
ErrNotSupported = errors.New("file you're trying to download is not supported yet")

ErrDownloadNotFound = errors.New("Item you are trying to download is not found")

ErrFlushHashNotFound = errors.New("Item you are trying to flush is not found")
)
6 changes: 6 additions & 0 deletions manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,12 @@ func (m *Manager) Flush() error {
func (m *Manager) FlushOne(hash string) error {
m.fmu.RLock()
defer m.fmu.RUnlock()
m.mu.RLock()
_, found := m.items[hash]
m.mu.RUnlock()
if !found {
return ErrFlushHashNotFound
}
m.deleteItem(hash)
m.encode(m.items)
return os.RemoveAll(GetPath(DlDataDir, hash))
Expand Down

0 comments on commit 7685213

Please sign in to comment.