Merge pull request #989 from ian-h-chamberlain/fix-delete-blob-twice

Delete blob hash from list when blob is deleted
This commit is contained in:
Alex Grin 2017-11-07 09:30:03 -05:00 committed by GitHub
commit 1ae3cd1f61
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 0 deletions

View file

@ -17,6 +17,7 @@ at anytime.
* Fixed external IP detection via jsonip.com (avoid detecting IPv6)
* Fixed failing ConnectionManager unit test for parallel connections
* Fixed race condition between `publish` and `channel_new`
* Fixed incorrect response on attempting to delete blob twice
### Deprecated
*

View file

@ -153,6 +153,7 @@ class DiskBlobManager(DHTHashSupplier):
blob = yield self.get_blob(blob_hash)
yield blob.delete()
bh_to_delete_from_db.append(blob_hash)
del self.blobs[blob_hash]
except Exception as e:
log.warning("Failed to delete blob file. Reason: %s", e)
yield self._delete_blobs_from_db(bh_to_delete_from_db)

View file

@ -83,6 +83,10 @@ class BlobManagerTest(unittest.TestCase):
self.assertEqual(len(blobs), 0)
blobs = yield self.bm._get_all_blob_hashes()
self.assertEqual(len(blobs), 0)
self.assertFalse(blob_hash in self.bm.blobs)
# delete blob that was already deleted once
out = yield self.bm.delete_blobs([blob_hash])
# delete blob that does not exist, nothing will
# happen