Skip to content

[Bug]: FileNotFoundError on broken symlinks #11098

Description

@allo-

Is there an existing issue for this?

  • I have searched the existing issues and checked the recent builds/commits

What happened?

I am getting an uncaught FileNotFound Exception for symlinks that are broken.

Steps to reproduce the problem

  1. Have a symlink in models/Lora
  2. Delete the file the link is pointing to

ondisk_mtime = os.path.getmtime(filename)

raises a FileNotFound exception. Either the webui relies on the directory listing implying that the files are accessible or there is an exists check somewhere which probably would succeed for broken symlinks, even when checking the mtime does not.

What should have happened?

Probably the best way would be to just handle the exception and remove the file from the list. Possibly the console could print a warning.

Commit where the problem happens

39ec4f0

What Python version are you running on ?

Python 3.10.x

Console logs

...
  File "/usr/lib/python3.10/genericpath.py", line 55, in getmtime
    return os.stat(filename).st_mtime
FileNotFoundError: [Errno 2] No such file or directory: '/xxx/models/Lora/other/brokensymlink.safetensors'

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug-reportReport of a bug, yet to be confirmed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions