Commit b0e0ac6f authored by echel0n's avatar echel0n
Browse files

Added ability to optionally restore application id when restoring backup.

Fixed issue with provider cache API calls.
parent f16c8f14
# Changelog
- * b48a658 - 2018-09-09: Release v9.3.74
- * 8131650 - 2018-09-09: Added ability to optionally restore application id when restoring backup. Fixed issue with provider cache API calls.
- * 0a5590f - 2018-09-09: Release v9.3.74
- * fd54d1e - 2018-09-08: Pre-Release v9.3.74.dev1
- * d4b634c - 2018-09-08: Release v9.3.73
- * 0f56bf7 - 2018-09-08: Release v9.3.72
......
......@@ -3,7 +3,7 @@ from sickrage.core import API
class ProviderCacheAPI(API):
def get(self, provider, indexerid, season, episode):
query = 'cache/providers/{}/indexerids/{}/seasons/()/episodes/()'.format(provider, indexerid, season, episode)
query = 'cache/providers/{}/indexerids/{}/seasons/{}/episodes/{}'.format(provider, indexerid, season, episode)
return self._request('GET', query)
def add(self, data):
......
......@@ -45,6 +45,7 @@ import rarfile
import requests
import six
from bs4 import BeautifulSoup
from configobj import ConfigObj
import sickrage
from sickrage.core.common import Quality, SKIPPED, WANTED, FAILED, UNAIRED
......@@ -927,7 +928,8 @@ def create_zipfile(fileList, archive, arcname=None):
return False
def restoreConfigZip(archive, targetDir, restore_database=True, restore_config=True, restore_cache=True):
def restoreConfigZip(archive, targetDir, restore_appid=True, restore_database=True, restore_config=True,
restore_cache=True):
"""
Restores a backup ZIP file back in place
......@@ -960,6 +962,12 @@ def restoreConfigZip(archive, targetDir, restore_database=True, restore_config=T
zip_file.extract(member, targetDir)
if restore_config and not restore_appid:
cfg = ConfigObj(os.path.join(targetDir, 'config.ini'), indent_type=' ', encoding='utf8')
if 'app_id' in cfg['General']:
del cfg['General']['app_id']
cfg.write()
return True
except Exception as e:
sickrage.app.log.error("Zip extraction error: {}".format(e))
......
......@@ -3882,18 +3882,19 @@ class ConfigBackupRestore(Config):
return finalResult
@staticmethod
def restore(backupFile=None, restore_database=None, restore_config=None, restore_cache=None):
def restore(backupFile=None, restore_appid=None, restore_database=None, restore_config=None, restore_cache=None):
finalResult = ''
if backupFile:
source = backupFile
target_dir = os.path.join(sickrage.app.data_dir, 'restore')
restore_appid = checkbox_to_value(restore_appid)
restore_database = checkbox_to_value(restore_database)
restore_config = checkbox_to_value(restore_config)
restore_cache = checkbox_to_value(restore_cache)
if restoreConfigZip(source, target_dir, restore_database, restore_config, restore_cache):
if restoreConfigZip(source, target_dir, restore_appid, restore_database, restore_config, restore_cache):
finalResult += _("Successfully extracted restore files to " + target_dir)
finalResult += _("<br>Restart sickrage to complete the restore.")
else:
......
......@@ -66,6 +66,15 @@
<br/>
<div class="form-row">
<div class="col-md-12">
<label for="restore_appid">
<input type="checkbox" class="toggle color-primary is-material" name="restore_appid" id="restore_appid" checked/>
${_('Restore application id (requires restoring config)')}
</label>
</div>
</div>
<div class="form-row">
<div class="col-md-12">
<label for="restore_database">
......
Supports Markdown
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