Skip to content

Commit

Permalink
The hide_ui_dir_config flag also restrict write attempt to path settings
Browse files Browse the repository at this point in the history
  • Loading branch information
sgkoishi authored and AUTOMATIC1111 committed Oct 16, 2022
1 parent 26a1177 commit c8045c5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
10 changes: 10 additions & 0 deletions modules/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,16 @@


cmd_opts = parser.parse_args()
restricted_opts = [
"samples_filename_pattern",
"outdir_samples",
"outdir_txt2img_samples",
"outdir_img2img_samples",
"outdir_extras_samples",
"outdir_grids",
"outdir_txt2img_grids",
"outdir_save",
]

devices.device, devices.device_interrogate, devices.device_gfpgan, devices.device_bsrgan, devices.device_esrgan, devices.device_scunet, devices.device_codeformer = \
(devices.cpu if any(y in cmd_opts.use_cpu for y in [x, 'all']) else devices.get_optimal_device() for x in ['sd', 'interrogate', 'gfpgan', 'bsrgan', 'esrgan', 'scunet', 'codeformer'])
Expand Down
8 changes: 7 additions & 1 deletion modules/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

from modules import sd_hijack, sd_models
from modules.paths import script_path
from modules.shared import opts, cmd_opts
from modules.shared import opts, cmd_opts, restricted_opts
if cmd_opts.deepdanbooru:
from modules.deepbooru import get_deepbooru_tags
import modules.shared as shared
Expand Down Expand Up @@ -1430,6 +1430,9 @@ def run_settings(*args):
if comp_args and isinstance(comp_args, dict) and comp_args.get('visible') is False:
continue

if cmd_opts.hide_ui_dir_config and key in restricted_opts:
continue

oldval = opts.data.get(key, None)
opts.data[key] = value

Expand All @@ -1447,6 +1450,9 @@ def run_settings_single(value, key):
if not opts.same_type(value, opts.data_labels[key].default):
return gr.update(visible=True), opts.dumpjson()

if cmd_opts.hide_ui_dir_config and key in restricted_opts:
return gr.update(value=oldval), opts.dumpjson()

oldval = opts.data.get(key, None)
opts.data[key] = value

Expand Down

0 comments on commit c8045c5

Please sign in to comment.