Skip to content

Commit

Permalink
Merge pull request #6054 from tomachalek/supp2877
Browse files Browse the repository at this point in the history
Handle legacy/removed corpora names when transfering deprec. settings
  • Loading branch information
tomachalek authored Nov 20, 2023
2 parents 6e17de4 + 0322f89 commit aea63fe
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/plugins/mysql_settings_storage/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@

import logging
from collections import defaultdict
from typing import Any, Dict, List, Optional
from typing import Dict, List, Optional

import plugins
import ujson as json
from pymysql.err import IntegrityError
from plugin_types.common import Serializable
from plugin_types.settings_storage import AbstractSettingsStorage
from plugins import inject
Expand Down Expand Up @@ -71,7 +72,11 @@ async def _upgrade_general_settings(self, data: Dict[str, Serializable], user_id
else:
gen[k] = v
for corp, data in corp_set.items():
await self.save(user_id, corp, data)
try:
await self.save(user_id, corp, data)
except IntegrityError:
logging.getLogger(__name__).warning(
f'Failed to transfer legacy format settings for corpus {corp}. Throwing the setting away.')

if len(gen) < len(data):
logging.getLogger(__name__).warning(
Expand Down

0 comments on commit aea63fe

Please sign in to comment.