Authentication data is now stripped from project file before saving

CURA-1263
This commit is contained in:
Jaime van Kessel 2016-12-05 12:46:53 +01:00
parent 8f023524d2
commit 16447f7173

View file

@ -2,9 +2,11 @@ from UM.Workspace.WorkspaceWriter import WorkspaceWriter
from UM.Application import Application from UM.Application import Application
from UM.Preferences import Preferences from UM.Preferences import Preferences
from UM.Settings.ContainerRegistry import ContainerRegistry from UM.Settings.ContainerRegistry import ContainerRegistry
from UM.Settings.ContainerStack import ContainerStack
from cura.Settings.ExtruderManager import ExtruderManager from cura.Settings.ExtruderManager import ExtruderManager
import zipfile import zipfile
from io import StringIO from io import StringIO
import copy
class ThreeMFWorkspaceWriter(WorkspaceWriter): class ThreeMFWorkspaceWriter(WorkspaceWriter):
@ -74,5 +76,14 @@ class ThreeMFWorkspaceWriter(WorkspaceWriter):
file_in_archive = zipfile.ZipInfo(file_name) file_in_archive = zipfile.ZipInfo(file_name)
# For some reason we have to set the compress type of each file as well (it doesn't keep the type of the entire archive) # For some reason we have to set the compress type of each file as well (it doesn't keep the type of the entire archive)
file_in_archive.compress_type = zipfile.ZIP_DEFLATED file_in_archive.compress_type = zipfile.ZIP_DEFLATED
if type(container) == ContainerStack and (container.getMetaDataEntry("network_authentication_id") or container.getMetaDataEntry("network_authentication_key")):
# TODO: Hack
# Create a shallow copy of the container, so we can filter out the network auth (if any)
container_copy = copy.deepcopy(container)
container_copy.removeMetaDataEntry("network_authentication_id")
container_copy.removeMetaDataEntry("network_authentication_key")
serialized_data = container_copy.serialize()
else:
serialized_data = container.serialize()
archive.writestr(file_in_archive, container.serialize()) archive.writestr(file_in_archive, serialized_data)