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
This commit is contained in:
patriceac 2023-01-14 23:54:09 -08:00 committed by GitHub
parent 8ee4364065
commit a8fba8f3fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)) {