From c5e2f19dde86e130b4fbdb9d1267a807ddeb3823 Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Mon, 21 Mar 2022 04:38:51 -0300 Subject: [PATCH] fix bug where added_on is always 0 for downloads --- lbry/blob/blob_info.py | 3 ++- tests/integration/datanetwork/test_file_commands.py | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lbry/blob/blob_info.py b/lbry/blob/blob_info.py index 7d4bc71dd..1058d1285 100644 --- a/lbry/blob/blob_info.py +++ b/lbry/blob/blob_info.py @@ -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: diff --git a/tests/integration/datanetwork/test_file_commands.py b/tests/integration/datanetwork/test_file_commands.py index a57718f6b..7472527e5 100644 --- a/tests/integration/datanetwork/test_file_commands.py +++ b/tests/integration/datanetwork/test_file_commands.py @@ -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):