Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
S
Stable Diffusion Webui
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
novelai-storage
Stable Diffusion Webui
Commits
b2f97095
Commit
b2f97095
authored
Sep 30, 2023
by
AUTOMATIC1111
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
get #13121 to work without restart
parent
5cc7bf38
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
8 deletions
+15
-8
modules/ui_extra_networks.py
modules/ui_extra_networks.py
+15
-8
No files found.
modules/ui_extra_networks.py
View file @
b2f97095
import
functools
import
os.path
import
os.path
import
urllib.parse
import
urllib.parse
from
pathlib
import
Path
from
pathlib
import
Path
...
@@ -15,10 +16,16 @@ from modules.ui_components import ToolButton
...
@@ -15,10 +16,16 @@ from modules.ui_components import ToolButton
extra_pages
=
[]
extra_pages
=
[]
allowed_dirs
=
set
()
allowed_dirs
=
set
()
allowed_preview_extensions
=
[
"png"
,
"jpg"
,
"jpeg"
,
"webp"
,
"gif"
]
default_allowed_preview_extensions
=
[
"png"
,
"jpg"
,
"jpeg"
,
"webp"
,
"gif"
]
if
shared
.
opts
.
samples_format
not
in
allowed_preview_extensions
:
allowed_preview_extensions
.
append
(
shared
.
opts
.
samples_format
)
allowed_preview_extensions_dot
=
[
'.'
+
extension
for
extension
in
allowed_preview_extensions
]
@
functools
.
cache
def
allowed_preview_extensions_with_extra
(
extra_extensions
=
None
):
return
set
(
default_allowed_preview_extensions
)
|
set
(
extra_extensions
or
[])
def
allowed_preview_extensions
():
return
allowed_preview_extensions_with_extra
((
shared
.
opts
.
samples_format
,
))
def
register_page
(
page
):
def
register_page
(
page
):
...
@@ -38,9 +45,9 @@ def fetch_file(filename: str = ""):
...
@@ -38,9 +45,9 @@ def fetch_file(filename: str = ""):
if
not
any
(
Path
(
x
)
.
absolute
()
in
Path
(
filename
)
.
absolute
()
.
parents
for
x
in
allowed_dirs
):
if
not
any
(
Path
(
x
)
.
absolute
()
in
Path
(
filename
)
.
absolute
()
.
parents
for
x
in
allowed_dirs
):
raise
ValueError
(
f
"File cannot be fetched: {filename}. Must be in one of directories registered by extra pages."
)
raise
ValueError
(
f
"File cannot be fetched: {filename}. Must be in one of directories registered by extra pages."
)
ext
=
os
.
path
.
splitext
(
filename
)[
1
]
.
lower
()
ext
=
os
.
path
.
splitext
(
filename
)[
1
]
.
lower
()
[
1
:]
if
ext
not
in
allowed_preview_extensions
_dot
:
if
ext
not
in
allowed_preview_extensions
()
:
raise
ValueError
(
f
"File cannot be fetched: {filename}.
Only png, jpg, webp, and gif
."
)
raise
ValueError
(
f
"File cannot be fetched: {filename}.
Extensions allowed: {allowed_preview_extensions()}
."
)
# would profit from returning 304
# would profit from returning 304
return
FileResponse
(
filename
,
headers
=
{
"Accept-Ranges"
:
"bytes"
})
return
FileResponse
(
filename
,
headers
=
{
"Accept-Ranges"
:
"bytes"
})
...
@@ -278,7 +285,7 @@ class ExtraNetworksPage:
...
@@ -278,7 +285,7 @@ class ExtraNetworksPage:
Find a preview PNG for a given path (without extension) and call link_preview on it.
Find a preview PNG for a given path (without extension) and call link_preview on it.
"""
"""
potential_files
=
sum
([[
path
+
"."
+
ext
,
path
+
".preview."
+
ext
]
for
ext
in
allowed_preview_extensions
],
[])
potential_files
=
sum
([[
path
+
"."
+
ext
,
path
+
".preview."
+
ext
]
for
ext
in
allowed_preview_extensions
()
],
[])
for
file
in
potential_files
:
for
file
in
potential_files
:
if
os
.
path
.
isfile
(
file
):
if
os
.
path
.
isfile
(
file
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment