mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2024-12-21 07:30:02 +08:00
add safety check in case of short extensions
so eg if a two-letter or empty extension is used, `.txt` would break, this `max` call protects that.
This commit is contained in:
parent
a71b7b5ec0
commit
48df6d66ea
@ -575,7 +575,7 @@ def save_image(image, path, basename, seed=None, prompt=None, extension='png', i
|
||||
fullfn_without_extension, extension = os.path.splitext(params.filename)
|
||||
if hasattr(os, 'statvfs'):
|
||||
max_name_len = os.statvfs(path).f_namemax
|
||||
fullfn_without_extension = fullfn_without_extension[:max_name_len - len(extension)]
|
||||
fullfn_without_extension = fullfn_without_extension[:max_name_len - max(4, len(extension))]
|
||||
params.filename = fullfn_without_extension + extension
|
||||
_atomically_save_image(image, fullfn_without_extension, extension)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user