diff options
author | Ghostkeeper <rubend@tutanota.com> | 2021-02-04 19:10:03 +0300 |
---|---|---|
committer | Ghostkeeper <rubend@tutanota.com> | 2021-02-04 19:10:03 +0300 |
commit | ba5b033499369749fd493e1c007ead09cdb43dd2 (patch) | |
tree | c3f501d55cfb178cb1a9b35285bdd44aa8643ee3 /cura/Settings/MachineNameValidator.py | |
parent | 577e45595ec5e421bd59c8ab9e7d9a8fd58252b9 (diff) |
Don't crash when not able to read maximum file name length
Just use a safe-ish maximum then.
Fixes Sentry issue CURA-1QY.
Diffstat (limited to 'cura/Settings/MachineNameValidator.py')
-rw-r--r-- | cura/Settings/MachineNameValidator.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/cura/Settings/MachineNameValidator.py b/cura/Settings/MachineNameValidator.py index c3ca4ed369..99a5c7da0a 100644 --- a/cura/Settings/MachineNameValidator.py +++ b/cura/Settings/MachineNameValidator.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Ultimaker B.V. +# Copyright (c) 2021 Ultimaker B.V. # Cura is released under the terms of the LGPLv3 or higher. from PyQt5.QtCore import pyqtSlot, pyqtProperty, QObject, pyqtSignal, QRegExp @@ -23,7 +23,7 @@ class MachineNameValidator(QObject): #Compute the validation regex for printer names. This is limited by the maximum file name length. try: filename_max_length = os.statvfs(Resources.getDataStoragePath()).f_namemax - except AttributeError: #Doesn't support statvfs. Probably because it's not a Unix system. + except (AttributeError, EnvironmentError): # Doesn't support statvfs. Probably because it's not a Unix system. Or perhaps there is no permission or it doesn't exist. filename_max_length = 255 #Assume it's Windows on NTFS. machine_name_max_length = filename_max_length - len("_current_settings.") - len(ContainerRegistry.getMimeTypeForContainer(InstanceContainer).preferredSuffix) # Characters that urllib.parse.quote_plus escapes count for 12! So now |