mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-08-06 22:10:14 -03:00
fix(download): route UNet/diffusion model downloads to unet roots in location step
When downloading a diffusion model (UNet) from the checkpoints page, the download modal's location step always showed checkpoint roots and paths. Now the modal detects the file subtype and switches to unet_roots endpoint, default_unet_root key, and 'unet' path template.
This commit is contained in:
@@ -158,6 +158,7 @@ export class DownloadManager {
|
|||||||
this.modelVersionId = null;
|
this.modelVersionId = null;
|
||||||
this.source = null;
|
this.source = null;
|
||||||
this.selectedFile = null;
|
this.selectedFile = null;
|
||||||
|
this._isDiffusionModel = false;
|
||||||
|
|
||||||
this.selectedFolder = '';
|
this.selectedFolder = '';
|
||||||
this.batchModels = [];
|
this.batchModels = [];
|
||||||
@@ -787,24 +788,40 @@ export class DownloadManager {
|
|||||||
async proceedToLocationContent() {
|
async proceedToLocationContent() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Fetch model roots
|
const _isDiffusionModel = this.selectedFile
|
||||||
const rootsData = await this.apiClient.fetchModelRoots();
|
? (this.selectedFile.type === 'UNet' || this.selectedFile.type === 'Diffusion Model')
|
||||||
|
: (this.currentVersion?.files || []).some(
|
||||||
|
f => f.type === 'UNet' || f.type === 'Diffusion Model'
|
||||||
|
);
|
||||||
|
this._isDiffusionModel = _isDiffusionModel;
|
||||||
|
|
||||||
|
let rootsData;
|
||||||
|
if (this._isDiffusionModel && this.apiClient.modelType === 'checkpoints') {
|
||||||
|
rootsData = await this.apiClient.fetchModelRoots('diffusion_model');
|
||||||
|
} else {
|
||||||
|
rootsData = await this.apiClient.fetchModelRoots();
|
||||||
|
}
|
||||||
const modelRoot = document.getElementById('modelRoot');
|
const modelRoot = document.getElementById('modelRoot');
|
||||||
modelRoot.innerHTML = rootsData.roots.map(root =>
|
modelRoot.innerHTML = rootsData.roots.map(root =>
|
||||||
`<option value="${root}">${root}</option>`
|
`<option value="${root}">${root}</option>`
|
||||||
).join('');
|
).join('');
|
||||||
|
|
||||||
// Set default root if available
|
const singularType = this._isDiffusionModel
|
||||||
const singularType = this.apiClient.modelType.replace(/s$/, '');
|
? 'unet'
|
||||||
|
: this.apiClient.modelType.replace(/s$/, '');
|
||||||
const defaultRootKey = `default_${singularType}_root`;
|
const defaultRootKey = `default_${singularType}_root`;
|
||||||
const defaultRoot = state.global.settings[defaultRootKey];
|
const defaultRoot = state.global.settings[defaultRootKey];
|
||||||
console.log(`Default root for ${this.apiClient.modelType}:`, defaultRoot);
|
console.log(`Default root for ${singularType}:`, defaultRoot);
|
||||||
console.log('Available roots:', rootsData.roots);
|
console.log('Available roots:', rootsData.roots);
|
||||||
if (defaultRoot && rootsData.roots.includes(defaultRoot)) {
|
if (defaultRoot && rootsData.roots.includes(defaultRoot)) {
|
||||||
console.log(`Setting default root: ${defaultRoot}`);
|
console.log(`Setting default root: ${defaultRoot}`);
|
||||||
modelRoot.value = defaultRoot;
|
modelRoot.value = defaultRoot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const subtypeDisplay = this._isDiffusionModel ? 'Diffusion Model' : this.apiClient.apiConfig.config.displayName;
|
||||||
|
document.getElementById('modelRootLabel').textContent =
|
||||||
|
translate('modals.download.selectTypeRoot', { type: subtypeDisplay });
|
||||||
|
|
||||||
// Set autocomplete="off" on folderPath input
|
// Set autocomplete="off" on folderPath input
|
||||||
const folderPathInput = document.getElementById('folderPath');
|
const folderPathInput = document.getElementById('folderPath');
|
||||||
if (folderPathInput) {
|
if (folderPathInput) {
|
||||||
@@ -1776,13 +1793,15 @@ export class DownloadManager {
|
|||||||
const modelRoot = document.getElementById('modelRoot').value;
|
const modelRoot = document.getElementById('modelRoot').value;
|
||||||
const config = this.apiClient.apiConfig.config;
|
const config = this.apiClient.apiConfig.config;
|
||||||
|
|
||||||
let fullPath = modelRoot || translate('modals.download.selectTypeRoot', { type: config.displayName });
|
const subtypeDisplay = this._isDiffusionModel ? 'Diffusion Model' : config.displayName;
|
||||||
|
let fullPath = modelRoot || translate('modals.download.selectTypeRoot', { type: subtypeDisplay });
|
||||||
|
|
||||||
if (modelRoot) {
|
if (modelRoot) {
|
||||||
if (this.useDefaultPath) {
|
if (this.useDefaultPath) {
|
||||||
// Show actual template path
|
|
||||||
try {
|
try {
|
||||||
const singularType = this.apiClient.modelType.replace(/s$/, '');
|
const singularType = this._isDiffusionModel
|
||||||
|
? 'unet'
|
||||||
|
: this.apiClient.modelType.replace(/s$/, '');
|
||||||
const templates = state.global.settings.download_path_templates;
|
const templates = state.global.settings.download_path_templates;
|
||||||
const template = templates[singularType];
|
const template = templates[singularType];
|
||||||
fullPath += `/${template}`;
|
fullPath += `/${template}`;
|
||||||
|
|||||||
@@ -333,6 +333,7 @@ export const PATH_TEMPLATE_PLACEHOLDERS = [
|
|||||||
export const DEFAULT_PATH_TEMPLATES = {
|
export const DEFAULT_PATH_TEMPLATES = {
|
||||||
lora: '{base_model}/{first_tag}',
|
lora: '{base_model}/{first_tag}',
|
||||||
checkpoint: '{base_model}',
|
checkpoint: '{base_model}',
|
||||||
|
unet: '{base_model}',
|
||||||
embedding: '{first_tag}'
|
embedding: '{first_tag}'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user