Skip to content

Commit a01f1d4

Browse files
committed
workaround no os.pathconf() on Windows platforms
- Previous PR to truncate long filenames won't work on windows due to lack of support for os.pathconf(). This works around the limitation by hardcoding the value for PC_NAME_MAX when pathconf is unavailable.
1 parent 2af511c commit a01f1d4

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

ldm/invoke/dynamic_prompts.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,10 @@ def _get_fn_format(directory:str, sequence:int)->str:
116116
Get a filename that doesn't exceed filename length restrictions
117117
on the current platform.
118118
"""
119-
max_length = os.pathconf(directory,'PC_NAME_MAX')
119+
try:
120+
max_length = os.pathconf(directory,'PC_NAME_MAX')
121+
except:
122+
max_length = 255
120123
prefix = f'dp.{sequence:04}.'
121124
suffix = '.png'
122125
max_length -= len(prefix)+len(suffix)

0 commit comments

Comments
 (0)