Commit f05bd79b authored by echel0n's avatar echel0n
Browse files

Fixed issue with migration of config.ini to config.db

Added code to skip config.ini migrations if config.ini.migrated exists
parent 96b17530
......@@ -326,8 +326,15 @@ class Core(object):
self.config.load()
# migrate config
if os.path.exists(self.config_file) and not os.path.exists(self.config.db.db_path):
self.config.migrate_config_file(self.config_file)
self.config.migrate_config_file(self.config_file)
# config overrides
if self.web_port:
self.config.general.web_port = self.web_port
if self.web_root:
self.config.general.web_root = self.web_root
if self.web_host:
self.config.general.web_host = self.web_host
# set language
change_gui_lang(self.config.gui.gui_lang)
......@@ -373,23 +380,23 @@ class Core(object):
if self.config.general.torrent_method not in TorrentMethod:
self.config.general.torrent_method = TorrentMethod.BLACKHOLE
# if self.config.general.auto_postprocessor_freq < self.sickrage.app.min_auto_postprocessor_freq:
# self.config.general.auto_postprocessor_freq = self.sickrage.app.min_auto_postprocessor_freq
#
# if self.config.general.daily_searcher_freq < self.config.min_daily_searcher_freq:
# self.config.general.daily_searcher_freq = self.config.min_daily_searcher_freq
#
# if self.config.general.backlog_searcher_freq < self.config.min_backlog_searcher_freq:
# self.config.general.backlog_searcher_freq = self.config.min_backlog_searcher_freq
#
# if self.config.general.version_updater_freq < self.config.min_version_updater_freq:
# self.config.general.version_updater_freq = self.config.min_version_updater_freq
#
# if self.config.general.subtitle_searcher_freq < self.config.min_subtitle_searcher_freq:
# self.config.general.subtitle_searcher_freq = self.config.min_subtitle_searcher_freq
#
# if self.config.failed_snatches.age < self.config.min_failed_snatch_age:
# self.config.failed_snatches.age = self.config.min_failed_snatch_age
if self.config.general.auto_postprocessor_freq < self.min_auto_postprocessor_freq:
self.config.general.auto_postprocessor_freq = self.min_auto_postprocessor_freq
if self.config.general.daily_searcher_freq < self.min_daily_searcher_freq:
self.config.general.daily_searcher_freq = self.min_daily_searcher_freq
if self.config.general.backlog_searcher_freq < self.min_backlog_searcher_freq:
self.config.general.backlog_searcher_freq = self.min_backlog_searcher_freq
if self.config.general.version_updater_freq < self.min_version_updater_freq:
self.config.general.version_updater_freq = self.min_version_updater_freq
if self.config.general.subtitle_searcher_freq < self.min_subtitle_searcher_freq:
self.config.general.subtitle_searcher_freq = self.min_subtitle_searcher_freq
if self.config.failed_snatches.age < self.min_failed_snatch_age:
self.config.failed_snatches.age = self.min_failed_snatch_age
if self.config.general.proper_searcher_interval not in CheckPropersInterval:
self.config.general.proper_searcher_interval = CheckPropersInterval.DAILY
......
......@@ -616,6 +616,14 @@ class Config(object):
CustomStringEncryptedType.reset = False
def migrate_config_file(self, filename):
# no config.ini is present to migrate
if not os.path.exists(filename):
return
# config.ini has already been migrated
if os.path.exists(f'{filename}.migrated'):
return
try:
private_key_filename = os.path.join(sickrage.app.data_dir, 'privatekey.pem')
config_object = decrypt_config(filename, load_private_key(private_key_filename))
......@@ -719,8 +727,8 @@ class Config(object):
self.general.naming_anime = self._get_config_file_value(config_object, 'General', 'naming_anime', field_type=int)
self.general.naming_custom_sports = self._get_config_file_value(config_object, 'General', 'naming_custom_sports', field_type=bool)
self.general.naming_custom_anime = self._get_config_file_value(config_object, 'General', 'naming_custom_anime', field_type=bool)
self.general.naming_multi_ep = MultiEpNaming(self._get_config_file_value(config_object, 'General', 'naming_multi_ep', field_type=int))
self.general.naming_anime_multi_ep = MultiEpNaming(self._get_config_file_value(config_object, 'General', 'naming_anime_multi_ep', field_type=int))
self.general.naming_multi_ep = MultiEpNaming(self._get_config_file_value(config_object, 'General', 'naming_multi_ep', default=MultiEpNaming.REPEAT.value, field_type=int))
self.general.naming_anime_multi_ep = MultiEpNaming(self._get_config_file_value(config_object, 'General', 'naming_anime_multi_ep', default=MultiEpNaming.REPEAT.value, field_type=int))
self.general.naming_strip_year = self._get_config_file_value(config_object, 'General', 'naming_strip_year', field_type=bool)
self.general.use_nzbs = self._get_config_file_value(config_object, 'General', 'use_nzbs', field_type=bool)
self.general.use_torrents = self._get_config_file_value(config_object, 'General', 'use_torrents', field_type=bool)
......@@ -1214,12 +1222,12 @@ class Config(object):
self.save()
# delete old config
os.remove(filename)
# rename old config
os.rename(filename, f'{filename}.migrated')
# delete old config private key
if os.path.exists(private_key_filename):
os.remove(private_key_filename)
# rename old config private key
if not os.path.exists(private_key_filename):
os.rename(private_key_filename, f'{private_key_filename}.migrated')
sickrage.app.log.info("Migrating config file to database was successful!")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment