Skip to content

Commit 96c2f86

Browse files
committed
Add database fallback option
1 parent e6484da commit 96c2f86

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

resources/lib/common.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,10 @@ def extract_addon_db(self,use_backup=False):
210210
success = False
211211
if use_backup:
212212
current_file = self.config.files.get('db_zipped_backup')
213+
alternate_file = self.config.files.get('addon_data_db_zipped')
213214
else:
214215
current_file = self.config.files.get('addon_data_db_zipped')
216+
alternate_file = self.config.files.get('db_zipped_backup')
215217
if current_file.exists():
216218
my_archive = archive_tool.archive_tool(archive_file=str(current_file),directory_out=str(self.config.files.get('db').parent),flatten_archive=True)
217219
xbmc.log(msg='IAGL: Extracting zipped db {} to path {}'.format(current_file,self.config.files.get('db')),level=xbmc.LOGDEBUG)
@@ -221,8 +223,17 @@ def extract_addon_db(self,use_backup=False):
221223
else:
222224
success = False
223225
else:
224-
xbmc.log(msg='IAGL: File not found: {}'.format(current_file),level=xbmc.LOGDEBUG)
225-
success = False
226+
if alternate_file.exists():
227+
my_archive = archive_tool.archive_tool(archive_file=str(alternate_file),directory_out=str(self.config.files.get('db').parent),flatten_archive=True)
228+
xbmc.log(msg='IAGL: Extracting zipped db {} to path {}'.format(alternate_file,self.config.files.get('db')),level=xbmc.LOGDEBUG)
229+
extracted_files, result = my_archive.extract()
230+
if result and self.config.files.get('db').exists():
231+
success = True
232+
else:
233+
success = False
234+
else:
235+
xbmc.log(msg='IAGL: File not found: {}'.format(current_file),level=xbmc.LOGDEBUG)
236+
success = False
226237
return success
227238

228239
def check_db(self):

0 commit comments

Comments
 (0)