forked from openlp/openlp
Close and delete zip in case of exception
This commit is contained in:
parent
39fbbf779d
commit
9702870afa
@ -404,12 +404,17 @@ class ThemeManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ThemeManager, R
|
|||||||
:param theme: The name of the theme to be exported
|
:param theme: The name of the theme to be exported
|
||||||
"""
|
"""
|
||||||
theme_path = os.path.join(path, theme + '.otz')
|
theme_path = os.path.join(path, theme + '.otz')
|
||||||
theme_zip = zipfile.ZipFile(theme_path, 'w')
|
try:
|
||||||
source = os.path.join(self.path, theme)
|
theme_zip = zipfile.ZipFile(theme_path, 'w')
|
||||||
for files in os.walk(source):
|
source = os.path.join(self.path, theme)
|
||||||
for name in files[2]:
|
for files in os.walk(source):
|
||||||
theme_zip.write(os.path.join(source, name), os.path.join(theme, name))
|
for name in files[2]:
|
||||||
theme_zip.close()
|
theme_zip.write(os.path.join(source, name), os.path.join(theme, name))
|
||||||
|
except (IOError, OSError):
|
||||||
|
if theme_zip:
|
||||||
|
theme_zip.close()
|
||||||
|
shutil.rmtree(theme_path, True)
|
||||||
|
raise
|
||||||
|
|
||||||
def on_import_theme(self, field=None):
|
def on_import_theme(self, field=None):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user