Repository: stable-diffusion-webui
Issue: [Bug]: Access denied reading models sub folders
Labels: bug-report

### Checklist

- [X] The issue exists after disabling all extensions
- [X] The issue exists on a clean installation of webui
- [ ] The issue is caused by an extension, but I believe it is caused by a bug in the webui
- [X] The issue exists in the current version of the webui
- [X] The issue has not been reported before recently
- [ ] The issue has been reported before but has not been fixed yet

### What happened?

In Windows 11 mapping drives as paths to sub folders of the models folder causes access denied and fails to load.

### Steps to reproduce the problem

Taken from - https://learn.microsoft.com/en-us/windows-server/storage/disk-management/assign-a-mount-point-folder-path-to-a-drive

    In the search box on the taskbar, enter Computer Management, and select Disk Management.

    Choose the partition or volume that has the folder you want to mount the drive.

    Go to Action > All Tasks > Change Drive Letter and Paths, then choose Add.

    Select Mount in the following empty NTFS folder option.

    Select the Browse button to locate the folder- at this point select a sub folder in the models foler 
       for example models/Stable-diffusion/hdd1

    After you select the folder, choose select OK.

    Select OK in the Change Drive Letter and Paths dialog box to finish.


run webui-user.bat

### What should have happened?

UI fails to start:

Traceback (most recent call last):
  File "D:\stable-diffusion-webui\launch.py", line 48, in <module>
    main()
  File "D:\stable-diffusion-webui\launch.py", line 44, in main
    start()
  File "D:\stable-diffusion-webui\modules\launch_utils.py", line 469, in start
    webui.webui()
  File "D:\stable-diffusion-webui\webui.py", line 64, in webui
    shared.demo = ui.create_ui()
  File "D:\stable-diffusion-webui\modules\ui.py", line 494, in create_ui
    extra_networks_ui = ui_extra_networks.create_ui(txt2img_interface, [txt2img_generation_tab], 'txt2img')
  File "D:\stable-diffusion-webui\modules\ui_extra_networks.py", line 751, in create_ui
    page_elem = gr.HTML(page.create_html(tabname, empty=True), elem_id=elem_id)
  File "D:\stable-diffusion-webui\modules\ui_extra_networks.py", line 621, in create_html
    pane_content = self.pane_content_dirs_tpl.format(**page_params, dirs_html=self.create_dirs_view_html(tabname))
  File "D:\stable-diffusion-webui\modules\ui_extra_networks.py", line 532, in create_dirs_view_html
    is_empty = len(os.listdir(x)) == 0
PermissionError: [WinError 5] Access is denied: 'D:\\stable-diffusion-webui\\models\\Stable-diffusion\\HDD1\\System Volume Information'
Loading VAE weights specified in settings: D:\stable-diffusion-webui\models\VAE\sdxl_vae_fix.safetensors
Applying attention optimization: xformers... done.
Model loaded in 9.1s (load weights from disk: 2.8s, create model: 2.8s, apply weights to model: 2.9s, load VAE: 0.1s, move model to device: 0.1s, calculate empty prompt: 0.2s).
Press any key to continue . . .

### What browsers do you use to access the UI ?

Google Chrome

### Sysinfo

[sysinfo.txt](https://github.com/user-attachments/files/17653352/sysinfo.txt)


### Console logs

```Shell
Already up to date.
venv "D:\stable-diffusion-webui\venv\Scripts\Python.exe"
Python 3.10.6 (tags/v3.10.6:9c7b4bd, Aug  1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)]
Version: v1.10.1
Commit hash: 82a973c04367123ae98bd9abdf80d9eda9b910e2
Launching Web UI with arguments: --xformers
D:\stable-diffusion-webui\venv\lib\site-packages\timm\models\layers\__init__.py:48: FutureWarning: Importing from timm.models.layers is deprecated, please import via timm.layers
  warnings.warn(f"Importing from {__name__} is deprecated, please import via timm.layers", FutureWarning)
CHv1.8.11: Get Custom Model Folder
Loading weights [ee9e02e512] from D:\stable-diffusion-webui\models\Stable-diffusion\HDD1\Pony\realisticPonyPhoto_v10.safetensors
Creating model from config: D:\stable-diffusion-webui\repositories\generative-models\configs\inference\sd_xl_base.yaml
D:\stable-diffusion-webui\venv\lib\site-packages\huggingface_hub\file_download.py:797: FutureWarning: `resume_download` is deprecated and will be removed in version 1.0.0. Downloads always resume when possible. If you want to force a new download, use `force_download=True`.
  warnings.warn(
CHv1.8.11: Set Proxy:
Traceback (most recent call last):
  File "D:\stable-diffusion-webui\launch.py", line 48, in <module>
    main()
  File "D:\stable-diffusion-webui\launch.py", line 44, in main
    start()
  File "D:\stable-diffusion-webui\modules\launch_utils.py", line 469, in start
    webui.webui()
  File "D:\stable-diffusion-webui\webui.py", line 64, in webui
    shared.demo = ui.create_ui()
  File "D:\stable-diffusion-webui\modules\ui.py", line 494, in create_ui
    extra_networks_ui = ui_extra_networks.create_ui(txt2img_interface, [txt2img_generation_tab], 'txt2img')
  File "D:\stable-diffusion-webui\modules\ui_extra_networks.py", line 751, in create_ui
    page_elem = gr.HTML(page.create_html(tabname, empty=True), elem_id=elem_id)
  File "D:\stable-diffusion-webui\modules\ui_extra_networks.py", line 621, in create_html
    pane_content = self.pane_content_dirs_tpl.format(**page_params, dirs_html=self.create_dirs_view_html(tabname))
  File "D:\stable-diffusion-webui\modules\ui_extra_networks.py", line 532, in create_dirs_view_html
    is_empty = len(os.listdir(x)) == 0
PermissionError: [WinError 5] Access is denied: 'D:\\stable-diffusion-webui\\models\\Stable-diffusion\\HDD1\\System Volume Information'
Loading VAE weights specified in settings: D:\stable-diffusion-webui\models\VAE\sdxl_vae_fix.safetensors
Applying attention optimization: xformers... done.
Model loaded in 9.1s (load weights from disk: 2.8s, create model: 2.8s, apply weights to model: 2.9s, load VAE: 0.1s, move model to device: 0.1s, calculate empty prompt: 0.2s).
Press any key to continue . . .
```


### Additional information

Adding the following to "ui_extra_networks.py" at line 520 seems to work for now.

                    xtest = os.path.join(x, "WPSettings.dat")
                    if not os.access(xtest, os.W_OK):
                        continue