fix missing added_on for torrent files

This commit is contained in:
Victor Shyba 2022-10-27 20:10:00 -03:00
parent b39971bf05
commit 77d2c81a30
2 changed files with 6 additions and 2 deletions

View file

@ -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

View file

@ -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)