Make videos on the computer you already own. FreeVideo runs MiniMax H3 in as little as 8 GB of VRAM and 16 GB of RAM, and adapts its acceleration path to your hardware.
Launcher: a dialog offers to delete imported offline package ZIPs that are no longer needed
Bowen Xued936e95e4ab3
diff --git a/freevideo_engine/launcher/Main.qml b/freevideo_engine/launcher/Main.qmlindex a6ce92a..3a17c59 100644--- a/freevideo_engine/launcher/Main.qml+++ b/freevideo_engine/launcher/Main.qml@@ -13,6 +13,7 @@ ApplicationWindow {property bool settingsOpen: falseproperty bool terminalOpen: falseproperty bool confirmArchives: false // the in-place "delete the imported ZIPs?" step+ property bool archivesExpanded: falseproperty string settingsTab: "downloads"property string modelInfo: "video"property bool modelInfoOpen: false@@ -21,6 +22,7 @@ ApplicationWindow {property bool releaseConfirm: falseproperty bool accepted: falseproperty bool manualUpdate: false+ readonly property bool updateDialogWanted: !s.busy && (s.update.remind || manualUpdate)property bool releaseNotesOpen: falseproperty bool licensesOpen: falseproperty string previousStatus: ""@@ -867,20 +869,7 @@ ApplicationWindow {}FText { objectName: "oldVersions"; visible: !!s.old_versions; text: "✓ " + s.old_versions; color: theme.success; font.pixelSize: theme.micro; Layout.fillWidth: true }FText { objectName: "copiedModels"; visible: !!s.copied_models; text: s.copied_models || ""; color: theme.muted; font.pixelSize: theme.micro; wrapMode: Text.WordWrap; Layout.fillWidth: true }- RowLayout {- visible: !!s.archives && !confirmArchives; spacing: 12; Layout.fillWidth: true- FText { objectName: "archivesOffer"; text: s.archives || ""; color: theme.muted; font.pixelSize: theme.micro; wrapMode: Text.WordWrap; Layout.fillWidth: true }- FButton { objectName: "deleteArchives"; implicitWidth: contentItem.implicitWidth + leftPadding + rightPadding; Layout.rightMargin: -rightPadding; text: t("Delete ZIP files", "删除压缩包"); flat: true; implicitHeight: theme.heightSm - 2; font.pixelSize: theme.micro + 1; enabled: !s.busy; onClicked: confirmArchives = true }- }- // The user's own files, and not recoverable: confirm in place, no dialog.- RowLayout {- visible: !!s.archives && confirmArchives; spacing: 8; Layout.fillWidth: true- FText { objectName: "archivesConfirm"; text: s.archives_confirm || ""; color: theme.text; font.pixelSize: theme.micro; wrapMode: Text.WordWrap; Layout.fillWidth: true }- FButton { objectName: "confirmDeleteArchives"; text: t("Delete", "删除"); danger: true; implicitHeight: theme.heightSm - 2; font.pixelSize: theme.micro + 1; enabled: !s.busy; onClicked: { confirmArchives = false; backend.action("delete_archives", false) } }- FButton { objectName: "cancelDeleteArchives"; implicitWidth: contentItem.implicitWidth + leftPadding + rightPadding; Layout.rightMargin: -rightPadding; text: t("Cancel", "取消"); flat: true; implicitHeight: theme.heightSm - 2; font.pixelSize: theme.micro + 1; onClicked: confirmArchives = false }- }- FText { objectName: "archivesDone"; visible: !!s.archives_done; text: "✓ " + (s.archives_done || ""); color: theme.success; font.pixelSize: theme.micro; Layout.fillWidth: true }- FText { objectName: "archivesFailed"; visible: !!s.archives_failed; text: s.archives_failed || ""; color: theme.muted; font.pixelSize: theme.micro; Layout.fillWidth: true }+ FText { objectName: "archivesDone"; visible: !!s.archives_toast; text: s.archives_toast || ""; color: theme.success; font.pixelSize: theme.micro; Layout.fillWidth: true }FCheck { visible: s.needs_consent; text: s.consent; checked: accepted; onToggled: accepted = checked; Layout.fillWidth: true }FButton { objectName: "bundleLicensesButton"; visible: s.needs_consent; text: t("View licenses", "查看许可证"); flat: true; implicitHeight: theme.heightSm - 2; leftPadding: 32; font.pixelSize: theme.micro + 1; onClicked: licensesOpen = true }}@@ -1098,6 +1087,27 @@ ApplicationWindow {}}FText { visible: !!s.cleanup.error; text: s.cleanup.error || ""; color: theme.danger; font.pixelSize: theme.micro; Layout.fillWidth: true }+ FDivider { objectName: "archivesStorageDivider"; visible: !!s.archives }+ RowLayout {+ objectName: "archivesStorageRow"+ visible: !!s.archives+ spacing: 12; Layout.fillWidth: true+ ColumnLayout {+ Layout.fillWidth: true; spacing: 2+ FText { objectName: "archivesStorageTitle"; text: t("Offline package ZIPs", "离线包压缩包"); Layout.fillWidth: true }+ FText { objectName: "archivesStorageOffer"; text: s.archives || ""; color: theme.muted; font.pixelSize: theme.micro; Layout.fillWidth: true }+ }+ FButton { objectName: "deleteArchives"; visible: !confirmArchives; text: s.archives_busy ? t("Deleting…", "正在删除…") : t("Delete", "删除"); implicitHeight: theme.heightSm; font.pixelSize: theme.micro + 1; enabled: s.can_delete_archives; onClicked: confirmArchives = true }+ }+ // The user's own files, and not recoverable: confirm in place.+ RowLayout {+ visible: !!s.archives && confirmArchives; spacing: 8; Layout.fillWidth: true+ FText { objectName: "archivesConfirm"; text: s.archives_confirm || ""; font.pixelSize: theme.micro; Layout.fillWidth: true }+ FButton { objectName: "confirmDeleteArchives"; text: t("Delete", "删除"); danger: true; implicitHeight: theme.heightSm; font.pixelSize: theme.micro + 1; enabled: s.can_delete_archives; onClicked: { confirmArchives = false; backend.action("delete_archives", false) } }+ FButton { objectName: "cancelDeleteArchives"; text: t("Cancel", "取消"); flat: true; implicitHeight: theme.heightSm; enabled: !s.archives_busy; onClicked: confirmArchives = false }+ }+ FText { objectName: "archivesStorageDone"; visible: !!s.archives_done; text: s.archives_done || ""; color: theme.success; font.pixelSize: theme.micro; Layout.fillWidth: true }+ FText { objectName: "archivesStorageFailed"; visible: !!s.archives_failed; text: s.archives_failed || ""; color: theme.danger; font.pixelSize: theme.micro; Layout.fillWidth: true }RowLayout {objectName: "modelStorageRow"visible: ["available", "low-disk", "downloading", "downloaded", "switching", "releasing", "releasable", "complete", "failed"].indexOf(upgrade.status) >= 0@@ -1275,7 +1285,68 @@ ApplicationWindow {}FPopup {- id: updateDialog; visible: !s.busy && (s.update.remind || manualUpdate)+ id: archivesDialog; objectName: "archivesDialog"+ visible: s.archives_dialog.remind && !updateDialogWanted && !settingsOpen && !releaseNotesOpen && !modelInfoOpen && !closePending && !s.notice+ width: Math.min(480, win.width - 40); closePolicy: Popup.NoAutoClose+ onClosed: archivesExpanded = false+ height: Math.min(archivesContents.implicitHeight + padding * 2 + archivesActions.implicitHeight + archivesFootnote.implicitHeight + 28, win.height - 48)+ contentItem: ColumnLayout {+ spacing: 14+ ScrollView {+ id: archivesScroll; Layout.fillWidth: true; Layout.fillHeight: true; clip: true; contentWidth: availableWidth+ ColumnLayout {+ id: archivesContents; width: archivesScroll.availableWidth; spacing: 14+ FText { objectName: "archivesDialogTitle"; text: s.archives_dialog.title; font.pixelSize: theme.section + 2; font.weight: Font.DemiBold; Layout.fillWidth: true }+ FText {+ objectName: "archivesDialogText"; color: theme.muted; Layout.fillWidth: true+ visible: !!s.archives_dialog.body; text: s.archives_dialog.body+ }+ FButton { objectName: "archivesFilesToggle"; visible: !s.archives_dialog.retry; text: t("Show these files (" + s.archives_dialog.count + ")", "查看这些文件(" + s.archives_dialog.count + " 个)") + (archivesExpanded ? " −" : " +"); flat: true; leftPadding: 0; onClicked: archivesExpanded = !archivesExpanded }+ ColumnLayout {+ objectName: "archivesFileList"; visible: archivesExpanded && !s.archives_dialog.retry; Layout.fillWidth: true; spacing: 12+ Repeater {+ model: s.archives_dialog.groups+ delegate: ColumnLayout {+ id: archiveGroup+ required property var modelData+ required property int index+ Layout.fillWidth: true; spacing: 8+ FText {+ objectName: "archivesFolder-" + archiveGroup.index; text: archiveGroup.modelData.folder+ color: theme.muted; font.pixelSize: theme.micro; Layout.fillWidth: true+ wrapMode: Text.NoWrap; elide: Text.ElideMiddle; maximumLineCount: 1+ MouseArea { id: folderHover; anchors.fill: parent; hoverEnabled: true; acceptedButtons: Qt.NoButton }+ ToolTip { objectName: "archivesFolderTooltip-" + archiveGroup.index; text: archiveGroup.modelData.folder; visible: folderHover.containsMouse; delay: 300 }+ }+ Repeater {+ model: archiveGroup.modelData.files+ delegate: RowLayout {+ required property var modelData+ required property int index+ Layout.fillWidth: true; Layout.leftMargin: 12; spacing: 12+ FText { objectName: "archivesFile-" + archiveGroup.index + "-" + index; text: modelData.name; Layout.fillWidth: true; font.pixelSize: theme.micro + 1; wrapMode: Text.WrapAnywhere }+ FText { objectName: "archivesFileSize-" + archiveGroup.index + "-" + index; text: modelData.size; font.pixelSize: theme.micro + 1 }+ }+ }+ }+ }+ }+ FText { objectName: "archivesDialogFailure"; visible: s.archives_dialog.retry && !!s.archives_failed; text: s.archives_failed || ""; color: theme.danger; font.pixelSize: theme.micro; Layout.fillWidth: true }+ }+ }+ RowLayout {+ id: archivesActions; Layout.fillWidth: true; spacing: 8+ // As the update dialog: the secondary choice on the left, the primary on the right.+ FButton { objectName: "archivesKeepButton"; text: s.archives_dialog.keep_text; flat: true; enabled: !s.archives_busy; onClicked: backend.action("keep_archives", false) }+ Item { Layout.fillWidth: true }+ FButton { objectName: "archivesDeleteButton"; text: s.archives_dialog.delete_text; primary: true; enabled: s.can_delete_archives; onClicked: backend.action("delete_archives_dialog", false) }+ }+ FText { id: archivesFootnote; objectName: "archivesDialogFootnote"; text: s.archives_dialog.footnote; color: theme.muted; font.pixelSize: theme.micro; Layout.fillWidth: true }+ }+ }++ FPopup {+ id: updateDialog; visible: updateDialogWanted && !archivesDialog.visibleobjectName: "updateDialog"width: Math.min(540,win.width-40); closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside// State changes also close it (an update started from the banner or adiff --git a/freevideo_engine/launcher_session.py b/freevideo_engine/launcher_session.pyindex fae5953..a28cf97 100644--- a/freevideo_engine/launcher_session.py+++ b/freevideo_engine/launcher_session.py@@ -21,6 +21,7 @@ from .model_guidance import package_instructions, video_instructions, runtime_pafrom .setup_progress import progress_textfrom .terminal_ui import clean, durationfrom .model_upgrade import TARGET+from .runtime_alias import checked_real_path# Background launcher release checks while the window stays open.CHECK_SECONDS = 30 * 60@@ -30,6 +31,15 @@ QUEUE_POLL_SECONDS = 3RECEIPT_POLL_SECONDS = 5+# package_cleanup.failure_reason codes; the raw error stays in the details.+ARCHIVE_FAILURES = {+ 'changed': ('The file changed after the check, so it was kept.', '文件在检查后有改动,已保留。'),+ 'busy': ('An installation or a video is in progress. Try again when it finishes.', '有安装或生成正在进行,完成后可以再删除。'),+ 'in-use': ('Another program is using it, or this account does not have permission to delete it.', '正被其他程序使用,或当前账户没有删除权限。'),+ 'failed': ('It could not be deleted.', '未能删除。'),+}++class Session:# A launcher started from an offline package (portable_launcher.PortableSession).bundled = False@@ -50,6 +60,7 @@ class Session:release_details = None# The source whose earlier copies were removed once ComfyUI ran it.old_versions_retired = None+ archives_busy = Falsedef __init__(self, source=None, *, controller=None, store=None, updater=None, smoke=False):from .offline_packages import Importer@@ -69,7 +80,7 @@ class Session:self.form = dict(comfy='', destination=str(home / 'FreeVideo'), engine='', python='',url='http://127.0.0.1:8188', models='', model_dirs=[], model_method='auto', environment_method='auto',separate=False, repair=False, new_comfy=True, offline_runtime='', offline_models=[],- imported_archives=[], sampling_caches=not saved.get('installation'))+ imported_archives=[], kept_archives=[], sampling_caches=not saved.get('installation'))self.form['lan_access'] = Falseself.form.update({k: v for k, v in saved.items() if k in self.form})if 'environment_method' not in saved and self.form['offline_runtime']:@@ -106,6 +117,14 @@ class Session:self.page_error = ''self.started = Noneself.closing = False+ self.archives_busy = False+ self.archives_from_dialog = False+ self.archives_thread = self.archives_result = self.archives_deleting_offer = None+ self.archives_failures = []+ self.archives_retry_dialog = False+ self.archives_prompt_offer = None+ self.archives_freed = 0+ self.archives_toast_until = 0.self.smoke = smokeself.reported_setup = None# An explicit update continues from tick() through update_intent:@@ -192,7 +211,7 @@ class Session:raise ValueError(self.t('Pause installation before changing the token.', '请先暂停安装,再修改 Token。'))from .hf_auth import validateself.token = validate(str(value)); return- if key not in self.form or self.controller.busy or self.importer.busy or self.cleaner.busy:+ if key not in self.form or self.controller.busy or self.importer.busy or self.cleaner.busy or self.archives_busy:returnif key in ('separate', 'repair', 'new_comfy', 'sampling_caches', 'lan_access'):value = bool(value)@@ -243,7 +262,7 @@ class Session:def use_disk(self, folder):"""Move a new installation to another disk, then show the location page to confirm it."""- if not self.form['new_comfy'] or self.controller.busy or self.importer.busy or self.cleaner.busy:+ if not self.form['new_comfy'] or self.controller.busy or self.importer.busy or self.cleaner.busy or self.archives_busy:returnself.edit('destination', str(folder))self.page = 'comfy'@@ -276,7 +295,7 @@ class Session:def import_packages(self, paths):- if self.controller.busy or self.importer.busy or self.cleaner.busy:+ if self.controller.busy or self.importer.busy or self.cleaner.busy or self.archives_busy:returnif not paths:return@@ -294,6 +313,8 @@ class Session:Imported model packages are always used; the download is for anenvironment imported without any."""+ if self.archives_busy:+ returnif self.form['model_method'] == 'auto' and not self.form['offline_models']:self.importer.download(self.form['offline_runtime'], self.source, self.form['sampling_caches'])else:@@ -315,7 +336,7 @@ class Session:self.persist()def action(self, name, accepted=False):- if self.cleaner.busy:+ if self.cleaner.busy or self.archives_busy:return# The model download holds the setup lease; launching and opening# FreeVideo continue, anything that would start setup waits for it.@@ -400,6 +421,10 @@ class Session:self.open_browser(); returnif name == 'delete_archives':self.delete_archives(); return+ if name == 'delete_archives_dialog':+ self.delete_archives(dialog=True); return+ if name == 'keep_archives':+ self.keep_archives(); returnif name == 'shortcut':self.controller.run('shortcut', self.controller.state.get('status')); returnif name not in ('primary', 'launch'):@@ -447,7 +472,7 @@ class Session:def can_repair(self):"""An installed engine this launcher can check and reinstall again."""return (bool(self.selected) and getattr(self.controller, 'fixed_environment', False) is not True- and not (self.controller.busy or self.importer.busy or self.cleaner.busy or self.closing+ and not (self.controller.busy or self.importer.busy or self.cleaner.busy or self.archives_busy or self.closingor self.engine_updating or self.upgrade.active or self.model_switch))def repair_unavailable(self):@@ -481,7 +506,7 @@ class Session:return ''def cleanup_downloads(self, remove=False):- if (self.controller.busy or self.importer.busy or self.closing or self.upgrade.active or self.model_switch+ if (self.controller.busy or self.importer.busy or self.archives_busy or self.closing or self.upgrade.active or self.model_switchor self.update_intent or self.engine_updating or self.updater and self.updater.busy):returnself.cleaner.start(self.engine_root(), remove=remove)@@ -498,7 +523,7 @@ class Session:"""state = self.upgrade.stateif (state.get('status') not in ('available', 'failed', 'releasable') or self.upgrade.busy or self.model_switch- or self.closing or self.controller.busy or self.importer.busy or self.cleaner.busy or self.engine_updating):+ or self.closing or self.controller.busy or self.importer.busy or self.cleaner.busy or self.archives_busy or self.engine_updating):returnroot = self.engine_root()# Started from Settings after "Later": show the card again.@@ -533,7 +558,7 @@ class Session:def _tick_model_upgrade(self, row, busy):upgrade = self.upgradestate = upgrade.state- if self.closing or upgrade.busy:+ if self.closing or upgrade.busy or self.archives_busy:returnif (state.get('status') == 'idle' and self.page == 'launcher' and not busyand row.get('status') in ('open', 'ready')):@@ -788,7 +813,7 @@ class Session:"""One explicit update: the newest launcher if one is known, otherwisethe engine bundled with this launcher. Downloading, waiting for runningComfyUI jobs and restarting continue from tick()."""- if self.controller.busy or self.importer.busy or self.cleaner.busy or self.closing:+ if self.controller.busy or self.importer.busy or self.cleaner.busy or self.archives_busy or self.closing:if source == 'browser':self.bridge_pending = Truereturn@@ -868,6 +893,8 @@ class Session:return Falsedef _restart_when_idle(self):+ if self.archives_busy:+ returnrow = self.updater.stateif row.get('status') != 'ready' or self.update_restarting:return@@ -893,7 +920,7 @@ class Session:self.closing = Truedef _update_engine_when_idle(self):- if self.controller.busy or self.importer.busy or self.upgrade.active or self.model_switch:+ if self.controller.busy or self.importer.busy or self.archives_busy or self.upgrade.active or self.model_switch:returnbusy = self._queue_busy()self.update_waiting = bool(busy)@@ -1110,6 +1137,11 @@ class Session:if getattr(self, '_closed', False):returntry:+ # A finished deletion is recorded (and saved) inside the same guarantee:+ # a failed save never skips closing the engine.+ if self.archives_thread:+ self.archives_thread.join()+ self._finish_archives()self.persist()finally:self.closing = True@@ -1124,6 +1156,7 @@ class Session:def tick(self):if isinstance(self.controller, Controller) and not self.controller.busy:self.controller.poll_access_proxy()+ self._finish_archives()imported = self.importer.stateif not self.importer.busy and imported is not self.imported_batch:self.imported_batch = imported@@ -1274,55 +1307,161 @@ class Session:return Nonedef identity(path):try:- info = os.stat(io_path(path))- return path, info.st_size, info.st_mtime_ns+ # An alias slot is authenticated before anything below it is read.+ info = os.lstat(io_path(checked_real_path(path)))+ return path, info.st_size, info.st_mtime_ns, info.st_ino, info.st_dev, info.st_mode, info.st_nlinkexcept OSError:return path, None, None# A ZIP moved, changed or deleted while the launcher is open is noticed on the next view.- key = (engine, tuple(identity(r['path']) for r in self.form['imported_archives']))+ key = (engine, tuple((tuple(r.items()), identity(r['path'])) for r in self.form['imported_archives']),+ tuple(identity(str(Path(engine) / name)) for name in ('verified-models.json', 'portable-verified.json')))if getattr(self, 'archive_view', None) is None or self.archive_view[0] != key:from .package_cleanup import archivesself.archive_view = (key, archives(self.form['imported_archives'], engine))return self.archive_view[1]- def delete_archives(self):+ def archives_idle(self):+ """Use the engine update's queue check, including its unknown/wait state."""+ return (not (self.controller.busy or self.importer.busy or self.cleaner.busy or self.archives_busy+ or self.closing or self.update_intent or self.engine_updating or self.update_restarting+ or self.updater and self.updater.busy or self.upgrade.busy or self.model_switch)+ and self._queue_busy() is False)++ @staticmethod+ def archive_path(path):+ """The authenticated real spelling that offers and removals report."""+ try:+ return plain(checked_real_path(path))+ except (OSError, KeyError, TypeError, ValueError):+ return path++ @classmethod+ def archive_identity(cls, row):+ return dict(path=cls.archive_path(row['path']), bytes=row['bytes'], mtime_ns=row['mtime_ns'])++ @staticmethod+ def archive_size(value):+ return size_text(value, decimal_sizes=sys.platform == 'darwin')++ def keep_archives(self):+ if self.archives_busy:+ return+ offer = self.archives_prompt_offer or self.archive_offer() or {}+ recorded = [self.archive_identity(row) for row in self.form['imported_archives']]+ kept = [row for row in self.form['kept_archives'] if row in recorded]+ shown = [self.archive_identity(row) for row in offer.get('files', [])]+ self.form['kept_archives'] = kept + [row for row in shown if row not in kept]+ self.archives_retry_dialog = False+ self.archives_prompt_offer = None+ self.persist()++ def delete_archives(self, dialog=False):from .package_cleanup import delete_archivesengine = (self.controller.selection or {}).get('engine')- if self.controller.state.get('status') != 'open' or not engine:+ if self.controller.state.get('status') != 'open' or not engine or not self.archives_idle():+ return+ offer = self.archives_prompt_offer if dialog and self.archives_prompt_offer else self.archive_offer()+ if not offer or not offer['paths']:+ return+ self.archives_busy = True+ self.archives_from_dialog = dialog+ self.archives_deleting_offer = offer+ self.archives_failures = []+ records = [dict(r) for r in self.form['imported_archives']]+ def work():+ try:+ self.archives_result = delete_archives(records, engine, offered=offer)+ except Exception as error:+ self.archives_result = (0, [], [dict(path=p, reason='failed', detail=str(error)) for p in offer['paths']])+ self.archives_thread = threading.Thread(target=work, name='freevideo-delete-archives')+ self.archives_thread.start()++ def _finish_archives(self):+ if self.archives_result is None:return- offered = len((self.archive_offer() or {}).get('paths', []))- freed, removed = delete_archives(self.form['imported_archives'], engine)- self.archives_failed = max(0, offered - len(removed))- self.form['imported_archives'] = [r for r in self.form['imported_archives'] if r['path'] not in removed]+ freed, removed, failures = self.archives_result+ offered = {r['path']: r for r in (self.archives_deleting_offer or {}).get('files', [])}+ # Keep the checked size even if the file changed or is no longer eligible.+ self.archives_failures = [dict(row, bytes=offered.get(row['path'], {}).get('bytes', 0))+ for row in failures]+ self.archives_result = None+ self.archives_busy = False+ self.archives_retry_dialog = bool(self.archives_failures) and self.archives_from_dialog+ if self.archives_retry_dialog:+ failed_paths = {r['path'] for r in self.archives_failures}+ remaining = [r for r in offered.values() if r['path'] in failed_paths]+ self.archives_prompt_offer = dict(bytes=sum(r['bytes'] for r in remaining), files=remaining,+ paths=[r['path'] for r in remaining])+ else:+ self.archives_prompt_offer = None+ self.archives_deleting_offer = None+ gone = set(removed)+ self.form['imported_archives'] = [r for r in self.form['imported_archives']+ if r['path'] not in gone and self.archive_path(r['path']) not in gone]self.archive_view = None- self.archives_freed = (getattr(self, 'archives_freed', 0) or 0) + freed+ self.archives_freed = freed+ self.archives_toast_until = time.monotonic() + 3 if freed else 0.self.persist()+ def archives_dialog_view(self, offer, idle, error, update):+ files = (offer or {}).get('files', [])+ kept = self.form['kept_archives']+ new = any(self.archive_identity(row) not in kept for row in files)+ remind = (self.page == 'launcher' and not error and (not update['remind'] or self.archives_busy)+ and ((idle and ((offer or {}).get('bytes', 0) >= 2**30 and new or self.archives_retry_dialog))+ or self.archives_busy and self.archives_from_dialog))+ if remind and not self.archives_busy and not self.archives_retry_dialog:+ self.archives_prompt_offer = offer+ groups = {}+ for row in files:+ folder = str(Path(row['path']).parent)+ groups.setdefault(folder, []).append(dict(name=Path(row['path']).name, size=self.archive_size(row['bytes'])))+ size, count = self.archive_size((offer or {}).get('bytes', 0)), len(files)+ retry = self.archives_retry_dialog+ if retry:+ failed_title = self.t('%d file could not be deleted' if count == 1 else '%d files could not be deleted',+ '%d 个文件未能删除') % count+ title = (self.t('%s freed. ', '已释放 %s,') % self.archive_size(self.archives_freed)+ if self.archives_freed else '') + failed_title+ else:+ title = self.t('Free up %s of disk space', '可以释放 %s 磁盘空间') % size+ return dict(remind=bool(remind), size=size, count=count, retry=retry, title=title,+ body='' if retry else self.t(+ 'The imported offline package ZIPs are still on the drive, and FreeVideo no longer needs them. '+ 'Deleting them does not affect models, the runtime or your videos.',+ '导入过的离线包压缩包仍保留在磁盘上,FreeVideo 已不再需要。删除后,模型、运行环境和作品都不受影响。'),+ delete_text=(self.t('Deleting…', '正在删除…') if self.archives_busy else+ self.t('Try again', '再试一次') if retry else+ self.t('Delete and free %s', '删除并释放 %s') % size),+ keep_text=self.t('Keep for now', '暂时保留'),+ footnote=self.t('You can also delete them later in Settings › Preferences › Storage.',+ '以后也可以在“设置 → 偏好 → 存储”里删除。'),+ groups=[dict(folder=folder, files=rows) for folder, rows in groups.items()])+def archives_text(self):offer = self.archive_offer()- if offer and offer['bytes'] >= 2**20:- return self.t('The offline package ZIP files you imported still take %s. FreeVideo no longer needs them.',- '导入用过的离线包压缩包还占着 %s,FreeVideo 已经用不到它们。') % size_text(offer['bytes'])+ if offer and offer['bytes'] > 0:+ return self.t('The ZIPs used for importing are no longer needed. Deleting them frees %s.',+ '导入用的压缩包已不再需要,删除后可释放 %s。') % self.archive_size(offer['bytes'])return ''def archives_confirm_text(self):offer = self.archive_offer()- if not offer or offer['bytes'] < 2**20:+ if not offer or offer['bytes'] <= 0:return ''count = len(offer['paths'])english = 'Delete 1 ZIP file (%s)? This cannot be undone.' if count == 1 else 'Delete %d ZIP files (%%s)? This cannot be undone.' % count- return self.t(english % size_text(offer['bytes']), '删除 %d 个压缩包(%s)?删除后不能恢复。' % (count, size_text(offer['bytes'])))+ return self.t(english % self.archive_size(offer['bytes']), '删除 %d 个压缩包(%s)?删除后不能恢复。' % (count, self.archive_size(offer['bytes'])))def archives_done_text(self):freed = getattr(self, 'archives_freed', 0) or 0- return self.t('ZIP files deleted · %s freed', '已删除压缩包 · 释放 %s') % size_text(freed) if freed >= 2**20 else ''+ return self.t('ZIP files deleted · %s freed', '已删除压缩包 · 释放 %s') % self.archive_size(freed) if freed > 0 else ''def archives_failed_text(self):- failed = getattr(self, 'archives_failed', 0) or 0- if not failed:- return ''- return self.t('1 ZIP file could not be deleted.' if failed == 1 else '%d ZIP files could not be deleted.' % failed,- '%d 个压缩包没能删除。' % failed)+ return '\n'.join(self.t('%s (%s): %s', '%s(%s):%s') % (+ Path(row['path']).name, self.archive_size(row['bytes']),+ self.t(*ARCHIVE_FAILURES.get(row.get('reason'), ARCHIVE_FAILURES['failed'])))+ for row in self.archives_failures)def licenses(self, row):"""What the consent accepts, listed when the user reads the licences: an offline runtime's, or the installation plan's."""@@ -1485,11 +1624,15 @@ class Session:model_upgrade = dict(self.upgrade.state, busy=self.upgrade.busy)if alias_failure(model_upgrade.get('error', '')):model_upgrade['error'] = display_launcher_error(model_upgrade['error'], zh=zh)+ archive_offer = (self.archives_deleting_offer if self.archives_busy else+ self.archives_prompt_offer if self.archives_retry_dialog else self.archive_offer())+ archives_idle = bool(archive_offer and archive_offer['paths']) and self.archives_idle()+ archive_dialog = self.archives_dialog_view(archive_offer, archives_idle, error, update)return plain_data(dict(sampling_cache_bytes=total_bytes(), version=__version__,disk=disk, decimal_sizes=sys.platform == 'darwin', zh=self.language.startswith('zh'), form=dict(self.form),page=self.page, status=row.get('status', 'idle'), busy=self.controller.busy or self.importer.busy or self.cleaner.busy,cleanup=cleanup,- can_cleanup=not (self.controller.busy or self.importer.busy or self.cleaner.busy or self.closing+ can_cleanup=not (self.controller.busy or self.importer.busy or self.cleaner.busy or self.archives_busy or self.closingor self.update_intent or self.engine_updating or self.updater and self.updater.busyor self.upgrade.active or self.model_switch),model_upgrade=dict(model_upgrade, switching=bool(self.model_switch)),@@ -1520,6 +1663,9 @@ class Session:old_versions=self.old_versions_text(), copied_models=self.copied_models_text(),archives=self.archives_text(), archives_confirm=self.archives_confirm_text(),archives_done=self.archives_done_text(), archives_failed=self.archives_failed_text(),+ archives_dialog=archive_dialog, archives_busy=self.archives_busy, can_delete_archives=archives_idle,+ archives_toast=(self.t('Freed %s', '已释放 %s') % self.archive_size(self.archives_freed)+ if self.archives_freed and time.monotonic() < self.archives_toast_until else ''),can_shortcut=bool(self.controller.selection and self.controller.selection.get('ready')),update=update, engine_update_available=bool(row.get('engine_update_available')),settings_path=str(self.store.primary),diff --git a/freevideo_engine/launcher_settings.py b/freevideo_engine/launcher_settings.pyindex e2a8b8c..186b40f 100644--- a/freevideo_engine/launcher_settings.py+++ b/freevideo_engine/launcher_settings.py@@ -11,6 +11,7 @@ from .long_paths import io_path, plain_dataTEXT = ('comfy', 'destination', 'engine', 'models', 'python', 'url', 'language', 'offline_runtime')SELECTION = ('root', 'engine', 'source', 'python', 'url')ARCHIVE = ('path', 'bytes', 'mtime_ns', 'kind', 'root')+ARCHIVE_IDENTITY = ('path', 'bytes', 'mtime_ns')def default_language():@@ -48,6 +49,12 @@ def sanitize(value):{k: row[k] for k in ARCHIVE} for row in archivesif isinstance(row, dict) and all(isinstance(row.get(k), str) for k in ('path', 'root', 'kind'))and all(type(row.get(k)) is int for k in ('bytes', 'mtime_ns'))][-64:]+ kept = value.get('kept_archives')+ if isinstance(kept, list):+ result['kept_archives'] = [+ {k: row[k] for k in ARCHIVE_IDENTITY} for row in kept+ if isinstance(row, dict) and isinstance(row.get('path'), str)+ and all(type(row.get(k)) is int for k in ('bytes', 'mtime_ns'))][-64:]record = value.get('installation')if isinstance(record, dict) and all(isinstance(record.get(k), str) and record[k] for k in SELECTION):result['installation'] = {k: record[k] for k in SELECTION}diff --git a/freevideo_engine/package_cleanup.py b/freevideo_engine/package_cleanup.pyindex 4b87c36..19ce369 100644--- a/freevideo_engine/package_cleanup.py+++ b/freevideo_engine/package_cleanup.py@@ -364,21 +364,23 @@ def run(engine, comfy_root=None, running=None, dry_run=False):return result-OPTIONAL_PREFIX = 'models/base/sampling-cache/'--def archive_unchanged(record):try:- info = os.stat(io_path(checked_real_path(record['path'])))- except (OSError, KeyError, TypeError):+ path = checked_real_path(record['path'])+ if not path.is_absolute() or path.suffix.lower() != '.zip' or not local_path(Path(path.anchor), path):+ return False+ info = os.lstat(io_path(path))+ except (OSError, KeyError, TypeError, ValueError):return False- return stat.S_ISREG(info.st_mode) and info.st_size == record.get('bytes') and info.st_mtime_ns == record.get('mtime_ns')+ return (stat.S_ISREG(info.st_mode) and info.st_nlink == 1+ and info.st_size == record.get('bytes') and info.st_mtime_ns == record.get('mtime_ns'))def archive_rows(record):"""The files a recorded ZIP provides: from its extraction, or else from the ZIP's own record."""try:- value = load(io_path(checked_real_path(record['root'])) / MODELS_MARKER)+ value = load(io_path(checked_real_path(record['root']))+ / (RUNTIME_MARKER if record.get('kind') == 'runtime' else MODELS_MARKER))except AliasUnavailable:return Noneif not isinstance(value, dict):@@ -399,44 +401,101 @@ def archives(records, engine, index=None):index = verified_files(engine) if index is None else indexruntime = runtime_root(engine)runtime = io_path(runtime) if runtime is not None else None- paths, total = [], 0+ paths, files, total = [], [], 0for record in records:try:checked_real_path(record['root'])except AliasUnavailable:continue- if not archive_unchanged(record):+ try:+ named = plain(checked_real_path(record['path']))+ except (OSError, KeyError, TypeError, ValueError):continue+ # One ZIP is one offer, whichever spelling its records carry.+ if record.get('kind') not in ('runtime', 'models') or named in paths or not archive_unchanged(record):+ continue+ rows = archive_rows(record)+ held = bool(rows) and all(row.get('sha256') in index for row in rows)if record.get('kind') == 'runtime':- # The environment package was unpacked into this very installation.- held = runtime is not None and resolved(checked_real_path(record['root'])) == resolved(runtime)- else:- rows = archive_rows(record)-- def installed(row):- if row.get('sha256') in index:- return True- # Optional sampling tables an offline installation placed itself: present at full size.- placed = runtime / str(row.get('path', '')) if runtime is not None else None- return (placed is not None and str(row.get('path', '')).startswith(OPTIONAL_PREFIX)- and placed.is_file() and placed.stat().st_size == row.get('bytes'))- held = bool(rows) and all(installed(row) for row in rows)+ # Root identity alone is insufficient: the current environment must+ # still hold every imported file with its verified hash and stamp.+ try:+ held = held and runtime is not None and resolved(checked_real_path(record['root'])) == resolved(runtime)+ except AliasUnavailable:+ continueif held:- paths.append(plain(checked_real_path(record['path'])))+ try:+ real = checked_real_path(record['path'])+ info = os.lstat(io_path(real))+ except OSError:+ continue+ if not archive_unchanged(record):+ continue+ paths.append(plain(real))total += record['bytes']- return dict(bytes=total, paths=paths)+ files.append(dict(path=plain(real), bytes=record['bytes'], mtime_ns=record['mtime_ns'],+ inode=info.st_ino, device=info.st_dev))+ return dict(bytes=total, paths=paths, files=files)+++def failure_reason(error):+ """A failure code the launcher words for the user; the raw error stays in detail."""+ if isinstance(error, ValueError):+ return 'changed'+ if isinstance(error, BlockingIOError):+ return 'busy' # Setup or a video holds the installation's lease.+ if isinstance(error, PermissionError):+ return 'in-use' # Windows reports a file open elsewhere as access denied.+ return 'failed'++def delete_archives(records, engine, *, offered=None):+ """Revalidate imported ZIPs, then delete; return (freed bytes, removed paths, failures).-def delete_archives(records, engine):- """Delete the user's imported ZIPs this installation holds; returns (bytes freed, paths removed)."""- offer = archives(records, engine)- freed, removed = 0, []- for path in offer['paths']:+ Each failure is dict(path, reason, detail): reason is 'changed', 'busy',+ 'in-use' or 'failed' (failure_reason). A ZIP already gone counts as removed.+ """+ from .locking import runtime_lock+ engine = io_path(checked_real_path(engine))+ offer = archives(records, engine) if offered is None else offered+ freed, removed, failed = 0, [], []+ by_path = {}+ for item in records:try:- info = os.lstat(io_path(path))- os.unlink(io_path(path))- except OSError:- continue # In use or read-only: kept, offered again next time.- removed.append(path)- freed += info.st_size if info.st_nlink == 1 else 0- return freed, removed+ by_path[plain(checked_real_path(item['path']))] = item+ except (AliasUnavailable, KeyError, TypeError):+ continue+ try:+ # Exclude setup/generation from other launchers as well as this UI.+ with runtime_lock(engine / 'setup.lock', inherit=False), \+ runtime_lock(engine / 'engine.lock', inherit=False), \+ runtime_lock(engine / 'launcher' / 'host-setup.lock', inherit=False):+ current = set(archives(records, engine)['paths'])+ for row in offer['files']:+ path = row['path']+ try:+ if not os.path.lexists(io_path(path)):+ removed.append(path) # Deleted elsewhere meanwhile: nothing left to free.+ continue+ record = by_path.get(path)+ if path not in current or not record or not archive_unchanged(record):+ # A ZIP another program holds open cannot be read to verify it:+ # that is "in use", not "changed".+ with open(io_path(path), 'rb'):+ pass+ raise ValueError('File or installed contents changed; kept for safety.')+ info = os.lstat(io_path(path))+ if (info.st_size, info.st_mtime_ns, info.st_ino, info.st_dev) != (+ row['bytes'], row['mtime_ns'], row['inode'], row['device']):+ raise ValueError('File changed since the confirmation; kept for safety.')+ os.unlink(io_path(path))+ except (OSError, ValueError) as error:+ failed.append(dict(path=path, reason=failure_reason(error), detail=str(error)))+ continue+ removed.append(path)+ # A name that was linked after the check frees nothing.+ freed += info.st_size if info.st_nlink == 1 else 0+ except (OSError, ValueError) as error:+ failed.extend(dict(path=row['path'], reason=failure_reason(error), detail=str(error)) for row in offer['files']+ if row['path'] not in removed and row['path'] not in {r['path'] for r in failed})+ return freed, removed, failed