diff --git a/clearml/utilities/files.py b/clearml/utilities/files.py index 59698f7c..5770406d 100644 --- a/clearml/utilities/files.py +++ b/clearml/utilities/files.py @@ -7,19 +7,22 @@ import psutil def get_filename_max_length(dir_path): # type: (str) -> int + default = 255 # Common filesystems like NTFS, EXT4 and HFS+ limited with 255 try: dir_path = pathlib2.Path(os.path.abspath(dir_path)) if platform == "win32": + # noinspection PyBroadException dir_drive = dir_path.drive for drv in psutil.disk_partitions(): if drv.device.startswith(dir_drive): - return drv.maxfile + # The maxfile attribute is only available in psutil >=5.7.4,<6.0.0 + return getattr(drv, "maxfile", default) elif platform in ("linux", "darwin"): return os.statvfs(dir_path).f_namemax except Exception as err: print(err) - return 255 # Common filesystems like NTFS, EXT4 and HFS+ limited with 255 + return default def is_path_traversal(target_folder, relative_path):