On Windows both models (Privacy Filter 1.6 GB, AstrLink Guard 39 MB) went onto the C: drive with no way to choose. Settings > Privacy now has Advanced > Models folder: Move… picks a folder in the system's picker and moves what is downloaded there; Move back returns it to magpie's cache. The default is unchanged. - settings.RedactModelDir is this computer's own (kept by KeepOwn, never set by a settings save). - pii.Root() is the one place every path is made from (dir, guardRoot, so the model, its cache files, pf-serve, the CoreML program). - pii.MoveTo: a rename on one disk, else a copy checked by sha256 read back; the setting switches after it and the old subfolders are deleted last (never the picked folder); a failure puts back what it moved and keeps the old copy. Refuses a relative path, an unwritable folder and one inside what is moved. A picked folder that has gone (disk unplugged) is not recreated by a download. Download and Remove wait out a move. - GUI: pmfolder.js, loaded on first draw so the core script is no bigger; strings in zh, zh-TW, ja, de. Docs: gateway-routing.md, masking.html (en, zh, ja), site index regenerated with docs-index.mjs. Run (mica; mote had no room, load 35/18 and 29/12): - go test of internal/pii folder tests, internal/gui TestPrivacyModel*, internal/settings and settingsapi keep tests: ok. Each broken by hand and red: guardRoot ignoring the folder, no rollback, no missing-folder check, KeepOwn line removed, settingsapi line removed, folder action not calling MoveTo. - Windows box (win-run): the move tests ok, TestMoveAcrossDisks on a real C: to D: move ok. - GUI privacy-model.test.cjs, Chromium and WebKit, 5 languages, 1100 and 640px: 104 of 104. - go vet on pii, gui, settings, settingsapi for linux (nogui), windows and darwin: clean. node --test site/*.test.mjs: 135 of 135. Not run before this push: the whole GUI suite, go test ./... (both follow at the pushed head), the size-budget and i18n tests (run after the rebase), gofmt over the whole tree (touched files only), and a real Privacy Filter download into a picked folder on a real account.
35 lines
2.3 KiB
JavaScript
35 lines
2.3 KiB
JavaScript
// Settings › Privacy's Models folder (MetalHqa on X: on Windows both local
|
||
// models went onto the C: drive): where they are downloaded, under an
|
||
// Advanced fold since it is set once. Move… picks a folder in the system's
|
||
// picker and the models are moved there in the background, copied and
|
||
// checked before the old ones go; Move back is magpie's cache. app.js
|
||
// imports this the first time the model row draws, so it weighs nothing on
|
||
// the core.
|
||
let pmFolderOpen = false;
|
||
window.pmFolder = function (row, score, m, act) {
|
||
// under the threshold's row, or the model's own while that is out
|
||
let box = document.getElementById("pmFolderRow");
|
||
if (!row.isConnected || !m?.folder || (!m.supported && !m.installed && !m.folderSet)) return void box?.remove();
|
||
if (!box) (box = el("div")).id = "pmFolderRow";
|
||
if (box.previousElementSibling !== (score.isConnected ? score : row)) (score.isConnected ? score : row).after(box);
|
||
let d = box.querySelector("details.pm-adv");
|
||
if (!d) {
|
||
d = el("details", "prefs-more pm-adv");
|
||
d.ontoggle = () => { pmFolderOpen = d.open; };
|
||
d.append(el("summary", "", t("Advanced")));
|
||
}
|
||
d.open = pmFolderOpen || !!m.folderSet || !!m.moving || !!m.moveError;
|
||
const r = el("div", "row pref pm-folder");
|
||
const who = el("div", "who"), val = el("div", "val");
|
||
const say = m.moving ? t("Moving the models: {done} of {total}", { done: fmtBytes(m.moveDone || 0), total: fmtBytes(m.moveTotal || 0) }) : m.folder;
|
||
who.append(el("div", "name", t("Models folder")), el("div", "sub wraps pm-folder-dir" + (m.moving ? " say" : ""), say));
|
||
if (m.moveError && !m.moving) who.append(el("div", "sub wraps bad pm-folder-said", t("The move stopped: {error}", { error: m.moveError })));
|
||
else if (m.moveLeft && !m.moving) who.append(el("div", "sub wraps pm-folder-said", t("Moved, but the old copy couldn't be deleted: {paths}", { paths: m.moveLeft })));
|
||
const btn = (label, fn) => { const b = el("button", "text", label); b.type = "button"; b.disabled = !!m.moving; b.onclick = fn; return b; };
|
||
val.append(btn(t("Move…"), () => act("folder", "", 0, "")));
|
||
if (m.folderSet) val.append(btn(t("Move back"), () => act("folder", "", 0, "default")));
|
||
r.append(who, val);
|
||
d.replaceChildren(d.firstChild, r);
|
||
if (d.parentNode !== box) box.replaceChildren(d);
|
||
};
|