A user found model folders cluttered after scans: four files per model. model_sidecars.py now says where the plugin's own side files are (.info, .anomalous.json, .civitai_bak.*): beside the model, or in the folder's hidden .amb (Settings -> Models -> Files that come with models). Every reader and writer goes through it and reads both places; covers stay beside the model for ComfyUI and other plugins. Scans no longer keep a copy of Civitai's picture identical to the cover: the cover is noted as Civitai's (SHA-256 in the .info) and a copy is kept aside only while the user's own cover shows. api/sidecar_layout.py moves existing files and drops the duplicates to the Recycle Bin. The folder tree leaves .amb out; the duplicated tree builder and cover owner check are shared now (model_catalog.py, backup.py back under 600 lines). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
21 lines
1020 B
JavaScript
21 lines
1020 B
JavaScript
/**
|
|
* Settings → Models → "Side files" requests (api/sidecar_layout.py): where the files only this
|
|
* plugin uses sit beside each model ('beside', or 'hidden' in each folder's .amb), what putting
|
|
* them there would move, and doing it (Civitai pictures kept twice go too). No DOM.
|
|
*/
|
|
|
|
async function json(url, options) {
|
|
const response = await fetch(url, options);
|
|
const data = await response.json().catch(() => ({}));
|
|
if (!response.ok) throw new Error(data.error || `HTTP ${response.status}`);
|
|
return data;
|
|
}
|
|
|
|
/** { layout, moves, duplicates, models }: what putting the side files in `layout` would do. */
|
|
export const planSidecars = (layout) => json(`/anomalous/sidecars/plan?layout=${encodeURIComponent(layout)}`);
|
|
|
|
/** Saves `layout` and puts the side files there: { layout, moved, deduped, failed, more }. */
|
|
export const applySidecars = (layout) => json('/anomalous/sidecars/apply', {
|
|
method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ layout }),
|
|
});
|