From 77d2c81a301225456721082fac1824f079f5440a Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Thu, 27 Oct 2022 20:10:00 -0300 Subject: [PATCH] fix missing added_on for torrent files --- lbry/file/source.py | 3 ++- tests/integration/datanetwork/test_file_commands.py | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lbry/file/source.py b/lbry/file/source.py index 519327629..f8bcbdd82 100644 --- a/lbry/file/source.py +++ b/lbry/file/source.py @@ -1,5 +1,6 @@ import os import asyncio +import time import typing import logging import binascii @@ -43,7 +44,7 @@ class ManagedDownloadSource: self.rowid = rowid self.content_fee = content_fee self.purchase_receipt = None - self._added_on = added_on + self._added_on = added_on or int(time.time()) self.analytics_manager = analytics_manager self.downloader = None diff --git a/tests/integration/datanetwork/test_file_commands.py b/tests/integration/datanetwork/test_file_commands.py index d4edb4936..32647f5d5 100644 --- a/tests/integration/datanetwork/test_file_commands.py +++ b/tests/integration/datanetwork/test_file_commands.py @@ -1,3 +1,4 @@ +import time import unittest from unittest import skipIf import asyncio @@ -81,7 +82,9 @@ class FileCommands(CommandTestCase): # second call, see its there and move on self.assertNotIn('error', await self.out(self.daemon.jsonrpc_get('torrent'))) self.assertItemCount(await self.daemon.jsonrpc_file_list(), 1) - self.assertEqual((await self.daemon.jsonrpc_file_list())['items'][0].identifier, btih) + file = (await self.daemon.jsonrpc_file_list())['items'][0] + self.assertEqual(btih, file.identifier) + self.assertAlmostEqual(time.time(), file.added_on, delta=2) self.assertIn(btih, self.client_session._handles) # stream over streaming API (full range of the largest file)