From a8fba8f3fb4864189d87b1f9dd991201fa1984fd Mon Sep 17 00:00:00 2001 From: patriceac <48073125+patriceac@users.noreply.github.com> Date: Sat, 14 Jan 2023 23:54:09 -0800 Subject: [PATCH] Fix restoration of models with subfolders In dnd.js, when models are restored in the UI, there is code that strips the path from the model file name. Now that we allow models to be hosted in subfolders, this code break the task restoration (e.g. use settings, D&D, copy/paste) because "/my models/model.ckpt" becomes "model.ckpt", which won't be found. https://discord.com/channels/1014774730907209781/1014780368890630164/1063726724573052948 --- ui/media/js/dnd.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/ui/media/js/dnd.js b/ui/media/js/dnd.js index 573e068c..c2c7a93a 100644 --- a/ui/media/js/dnd.js +++ b/ui/media/js/dnd.js @@ -363,12 +363,14 @@ function readUI() { } function getModelPath(filename, extensions) { - let pathIdx = filename.lastIndexOf('/') // Linux, Mac paths - if (pathIdx < 0) { - pathIdx = filename.lastIndexOf('\\') // Windows paths. - } - if (pathIdx >= 0) { - filename = filename.slice(pathIdx + 1) + if (filename.includes('/models/stable-diffusion/')) { + let pathIdx = filename.lastIndexOf('/') // Linux, Mac paths + if (pathIdx < 0) { + pathIdx = filename.lastIndexOf('\\') // Windows paths. + } + if (pathIdx >= 0) { + filename = filename.slice(pathIdx + 1) + } } extensions.forEach(ext => { if (filename.endsWith(ext)) {