Skip to content

Commit

Permalink
Merge branch 'release-7.6' into devel
Browse files Browse the repository at this point in the history
  • Loading branch information
ichorid committed Dec 6, 2020
2 parents 42c3385 + 0c841fd commit b621704
Show file tree
Hide file tree
Showing 14 changed files with 331 additions and 105 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ async def get_channel_contents(self, request):
for torrent in contents_list:
if torrent['type'] == REGULAR_TORRENT:
dl = self.session.dlmgr.get_download(unhexlify(torrent['infohash']))
if dl is not None:
if dl is not None and dl.tdef.infohash not in self.session.dlmgr.metainfo_requests:
torrent['progress'] = dl.get_state().get_progress()
response_dict = {
"results": contents_list,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@

class RemoteQueryEndpoint(MetadataEndpointBase):
"""
This endpoint is responsible for searching in channels and torrents present in the local Tribler database.
It also fires a remote search in the IPv8 channel community.
This endpoint fires a remote search in the IPv8 GigaChannel Community.
"""

def setup_routes(self):
Expand All @@ -38,10 +37,7 @@ def sanitize_parameters(self, parameters):
)
@querystring_schema(RemoteQueryParameters)
async def create_remote_search_request(self, request):
# Query remote results from the GigaChannel Community v1.0.
# v1.0 does not support searching for text limited by public key.
# GigaChannel v1.0 search community sends requests for channel contents by putting channel's public key
# into the text filter field. To communicate with older clients we have to shape the request accordingly.
# Query remote results from the GigaChannel Community.
# Results are returned over the Events endpoint.
try:
sanitized = self.sanitize_parameters(request.query)
Expand Down
12 changes: 10 additions & 2 deletions src/tribler-core/tribler_core/modules/metadata_store/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,17 @@ def drop_indexes(self):
for [index_name] in cursor.fetchall():
cursor.execute("drop index %s" % index_name)

def recreate_indexes(self):
def get_objects_to_create(self):
connection = self._db.get_connection()
self._db.schema.create_tables(self._db.provider, connection)
schema = self._db.schema
provider = schema.provider
created_tables = set()
result = []
for table in schema.order_tables_to_create():
for db_object in table.get_objects_to_create(created_tables):
if not db_object.exists(provider, connection):
result.append(db_object)
return result

def drop_fts_triggers(self):
cursor = self._db.get_connection().cursor()
Expand Down
65 changes: 39 additions & 26 deletions src/tribler-core/tribler_core/upgrade/config_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from configparser import MissingSectionHeaderError
from lib2to3.pgen2.parse import ParseError

from configobj import ConfigObj
from configobj import ConfigObj, ParseError as ConfigObjParseError

import libtorrent as lt

Expand All @@ -19,6 +19,10 @@
logger = logging.getLogger(__name__)


def load_config(filename: str):
return ConfigObj(infile=filename, encoding='utf8')


def convert_config_to_tribler74(state_dir):
"""
Convert the download config files to Tribler 7.4 format. The extensions will also be renamed from .state to .conf
Expand Down Expand Up @@ -69,39 +73,48 @@ def _fix_state_config(config):
if old_config.has_option('state', 'dlstate'):
old_config.remove_option('state', 'dlstate')

new_config = ConfigObj(infile=str(filename)[:-6] + '.conf', encoding='utf8')
for section in old_config.sections():
for key, _ in old_config.items(section):
val = old_config.get(section, key)
if section not in new_config:
new_config[section] = {}
new_config[section][key] = val
new_config.write()
os.remove(filename)
try:
conf_filename = str(filename)[:-6] + '.conf'
new_config = load_config(conf_filename)
for section in old_config.sections():
for key, _ in old_config.items(section):
val = old_config.get(section, key)
if section not in new_config:
new_config[section] = {}
new_config[section][key] = val
new_config.write()
os.remove(filename)
except ConfigObjParseError:
logger.error("Could not parse %s file on upgrade so removing it", filename)
os.remove(filename)


def convert_config_to_tribler75(state_dir):
"""
Convert the download config files from Tribler 7.4 to 7.5 format.
"""
for filename in (state_dir / STATEDIR_CHECKPOINT_DIR).glob('*.conf'):
config = DownloadConfig.load(filename)

# Convert resume data
resumedata = config.get_engineresumedata()
if b'mapped_files' in resumedata:
resumedata.pop(b'mapped_files')
config.set_engineresumedata(resumedata)
try:
config = DownloadConfig.load(filename)

# Convert resume data
resumedata = config.get_engineresumedata()
if b'mapped_files' in resumedata:
resumedata.pop(b'mapped_files')
config.set_engineresumedata(resumedata)
config.write(str(filename))

# Convert metainfo
metainfo = config.get_metainfo()
if not config.config['download_defaults'].get('selected_files') or not metainfo:
continue # no conversion needed/possible, selected files will be reset to their default (i.e., all files)
tdef = TorrentDef.load_from_dict(metainfo)
config.set_selected_files([tdef.get_index_of_file_in_files(fn)
for fn in config.config['download_defaults'].pop('selected_files')])
config.write(str(filename))

# Convert metainfo
metainfo = config.get_metainfo()
if not config.config['download_defaults'].get('selected_files') or not metainfo:
continue # no conversion needed/possible, selected files will be reset to their default (i.e., all files)
tdef = TorrentDef.load_from_dict(metainfo)
config.set_selected_files([tdef.get_index_of_file_in_files(fn)
for fn in config.config['download_defaults'].pop('selected_files')])
config.write(str(filename))
except ConfigObjParseError:
logger.error("Could not parse %s file so removing it", filename)
os.remove(filename)


def convert_config_to_tribler76(state_dir):
Expand Down

0 comments on commit b621704

Please sign in to comment.