Fix up loading 2.9.x services

This commit is contained in:
Raoul Snyman 2023-01-25 05:29:00 +00:00 committed by Tomas Groth
parent bc6c1e629a
commit f060664c9f
2 changed files with 869 additions and 584 deletions

View File

@ -791,6 +791,7 @@ class ServiceManager(QtWidgets.QWidget, RegistryBase, Ui_ServiceManager, LogMixi
# if the filename, directory name, or volume label syntax is incorrect it can cause an exception
return False
service_data = None
is_broken_file = False
self.application.set_busy_cursor()
try:
# TODO: figure out a way to use the presentation thumbnails from the service file
@ -828,6 +829,13 @@ class ServiceManager(QtWidgets.QWidget, RegistryBase, Ui_ServiceManager, LogMixi
# into the root of the service folder.
if self.servicefile_version and self.servicefile_version < 3:
zip_info.filename = os.path.basename(zip_info.filename.replace('/', os.path.sep))
else:
# Fix an issue with service files created in 2.9.x
fname, ext = os.path.splitext(zip_info.filename)
if not ext and os.path.basename(fname).startswith('.'):
zip_info.filename = fname.replace('/', '')
is_broken_file = True
self.log_debug(f'Fixing file {fname} => {zip_info.filename}')
zip_file.extract(zip_info, str(self.service_path))
self.main_window.increment_progress_bar(zip_info.compress_size)
# Handle the content
@ -836,6 +844,9 @@ class ServiceManager(QtWidgets.QWidget, RegistryBase, Ui_ServiceManager, LogMixi
self.set_file_name(file_path)
self.main_window.add_recent_file(file_path)
self.set_modified(False)
# If this file was broken due to a bug in 2.9.x, save the file to fix it.
if is_broken_file:
self.save_file()
self.settings.setValue('servicemanager/last file', file_path)
except (NameError, OSError, ValidationError, zipfile.BadZipFile):
self.application.set_normal_cursor()

File diff suppressed because it is too large Load Diff