fix bug where added_on is always 0 for downloads

This commit is contained in:
Victor Shyba 2022-03-21 04:38:51 -03:00
parent 34bd9e5cb4
commit c5e2f19dde
2 changed files with 8 additions and 1 deletions

View file

@ -1,3 +1,4 @@
import time
import typing
@ -18,7 +19,7 @@ class BlobInfo:
self.blob_num = blob_num
self.length = length
self.iv = iv
self.added_on = added_on
self.added_on = added_on or time.time()
self.is_mine = is_mine
def as_dict(self) -> typing.Dict:

View file

@ -573,6 +573,12 @@ class DiskSpaceManagement(CommandTestCase):
self.assertTrue(blobs2.issubset(blobs))
self.assertFalse(blobs3.issubset(blobs))
self.assertTrue(blobs4.issubset(blobs))
# check that added_on gets set on downloads (was a bug)
self.assertLess(0, await self.daemon.storage.run_and_return_one_or_none("select min(added_on) from blob"))
await self.daemon.jsonrpc_file_delete(delete_all=True)
await self.daemon.jsonrpc_get("foo4", save_file=False)
self.assertLess(0, await self.daemon.storage.run_and_return_one_or_none("select min(added_on) from blob"))
class TestBackgroundDownloaderComponent(CommandTestCase):