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)