feat(driver): clear download cache

This commit is contained in:
zipg authored and GitHub committed 2026-07-08 20:21:05 +08:00
1 parent ac4b98c97c
commit 33b4fc1dac
18 files changed
+168 -28

No files matched your search

@@ -166,6 +166,7 @@ const javaRuntimeConfig = ref<JavaRuntimeConfig>({ mode: "managed", custom_java_
const customJavaPath = ref("");
const savingJavaRuntime = ref(false);
const driverStoreUsage = ref<DriverStoreUsage | null>(null);
const clearingDownloadCache = ref(false);
const runtimeSummary = ref<DriverRuntimeSummary | null>(null);
const runtimeLoading = ref(false);
const runtimeError = ref("");
@@ -215,6 +216,7 @@ function resetInstallProgress() {
}
const updatableCount = computed(() => (props.updateNotificationsEnabled ? drivers.value.filter((d) => d.update_available).length : 0));
const downloadCacheBytes = computed(() => Number(driverStoreUsage.value?.download_cache_bytes || 0));
const usageSummary = computed(() => {
const usage = driverStoreUsage.value;
if (!usage) return [];
@@ -222,10 +224,12 @@ const usageSummary = computed(() => {
{ key: "total", label: t("driverStore.usageTotalLabel"), bytes: usage.total_bytes },
{ key: "jre", label: t("driverStore.usageManagedJre"), bytes: usage.jre_bytes },
{ key: "agent", label: t("driverStore.usageAgentDrivers"), bytes: usage.agent_driver_bytes },
{ key: "download-cache", label: t("driverStore.usageDownloadCache"), bytes: usage.download_cache_bytes || 0 },
{ key: "jdbc-plugin", label: t("driverStore.usageJdbcPlugin"), bytes: usage.jdbc_plugin_bytes },
{ key: "jdbc-driver", label: t("driverStore.usageJdbcDriverJars"), bytes: usage.jdbc_driver_bytes },
];
});
const canClearDownloadCache = computed(() => !clearingDownloadCache.value && installing.value === null && !upgradingAll.value && reinstallingJre.value === null && downloadCacheBytes.value > 0);
const jreUsageByKey = computed(() => {
const map = new Map<string, number>();
for (const item of driverStoreUsage.value?.jres || []) {
@@ -807,6 +811,20 @@ async function loadDriverStoreUsage() {
}
}
async function clearDownloadCache() {
if (!canClearDownloadCache.value) return;
clearingDownloadCache.value = true;
try {
await api.clearDriverDownloadCache();
await loadDriverStoreUsage();
toast(t("driverStore.downloadCacheClearSuccess"));
} catch (e: any) {
toast(t("driverStore.downloadCacheClearFailed", { error: e?.message || String(e) }), 5000);
} finally {
clearingDownloadCache.value = false;
}
}
async function loadJdbcPluginStatus() {
try {
jdbcPluginStatus.value = await api.jdbcPluginStatus();
@@ -1293,11 +1311,18 @@ watch(driverStoreTab, (tab) => {
<div class="rounded-xl border bg-muted/20 p-4 space-y-3">
<div class="flex items-center justify-between gap-3">
<div class="text-sm font-medium">{{ t("driverStore.usageTitle") }}</div>
<div class="text-xs text-muted-foreground">
{{ usageSummary.length ? t("driverStore.usageTotal", { size: formatBytes(usageSummary[0].bytes) }) : t("driverStore.calculating") }}
<div class="flex shrink-0 items-center gap-2">
<div class="text-xs text-muted-foreground">
{{ usageSummary.length ? t("driverStore.usageTotal", { size: formatBytes(usageSummary[0].bytes) }) : t("driverStore.calculating") }}
</div>
<Button variant="outline" size="sm" class="h-7 gap-1.5 rounded-[6px] text-xs" :disabled="!canClearDownloadCache" @click="clearDownloadCache">
<Loader2 v-if="clearingDownloadCache" class="h-3.5 w-3.5 animate-spin" />
<Trash2 v-else class="h-3.5 w-3.5" />
{{ clearingDownloadCache ? t("common.loading") : t("driverStore.clearDownloadCache") }}
</Button>
</div>
</div>
<div v-if="usageSummary.length" class="grid grid-cols-2 gap-2 sm:grid-cols-5">
<div v-if="usageSummary.length" class="grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-6">
<div v-for="item in usageSummary" :key="item.key" class="rounded-lg border bg-background/50 px-2.5 py-2 text-center">
<div class="text-[11px] text-muted-foreground">{{ item.label }}</div>
<div class="mt-0.5 text-xs font-medium">{{ formatBytes(item.bytes) }}</div>
+4
View File
@@ -3223,8 +3223,12 @@ export default {
calculating: "Calculating...",
usageManagedJre: "Managed JRE",
usageAgentDrivers: "Built-in driver agents",
usageDownloadCache: "Download cache",
usageJdbcPlugin: "JDBC plugin",
usageJdbcDriverJars: "JDBC driver JARs",
clearDownloadCache: "Clear cache",
downloadCacheClearSuccess: "Download cache cleared",
downloadCacheClearFailed: "Failed to clear download cache: {error}",
offlineDownloadHint: "For air-gapped environments, download offline driver packages on an internet-connected machine, then import them here.",
offlineDownloadLink: "Offline driver downloads",
searchDrivers: "Search driver name, type, version...",
+4
View File
@@ -3124,8 +3124,12 @@ export default withEnglishFallback({
calculating: "Calculando...",
usageManagedJre: "JRE administrado",
usageAgentDrivers: "Agentes de driver integrados",
usageDownloadCache: "Caché de descargas",
usageJdbcPlugin: "Plugin JDBC",
usageJdbcDriverJars: "JARs de driver JDBC",
clearDownloadCache: "Limpiar caché",
downloadCacheClearSuccess: "Caché de descargas limpiada",
downloadCacheClearFailed: "Error al limpiar la caché de descargas: {error}",
offlineDownloadHint: "Para entornos sin conexión a internet, descarga los paquetes de drivers offline en una máquina con conexión, luego impórtalos aquí.",
offlineDownloadLink: "Descargas de drivers offline",
searchDrivers: "Buscar nombre de driver, tipo, versión...",
+4
View File
@@ -3122,8 +3122,12 @@ export default withEnglishFallback({
calculating: "Calcolo in corso...",
usageManagedJre: "JRE gestito",
usageAgentDrivers: "Agenti driver integrati",
usageDownloadCache: "Cache download",
usageJdbcPlugin: "Plugin JDBC",
usageJdbcDriverJars: "JAR dei driver JDBC",
clearDownloadCache: "Pulisci cache",
downloadCacheClearSuccess: "Cache download pulita",
downloadCacheClearFailed: "Pulizia cache download non riuscita: {error}",
offlineDownloadHint: "Per ambienti air-gapped, scarica i pacchetti driver offline su una macchina connessa a Internet, quindi importali qui.",
offlineDownloadLink: "Download driver offline",
searchDrivers: "Cerca nome driver, tipo, versione...",
+4
View File
@@ -3122,8 +3122,12 @@ export default withEnglishFallback({
calculating: "計算中...",
usageManagedJre: "管理対象JRE",
usageAgentDrivers: "組み込みドライバーエージェント",
usageDownloadCache: "ダウンロードキャッシュ",
usageJdbcPlugin: "JDBCプラグイン",
usageJdbcDriverJars: "JDBCドライバーJAR",
clearDownloadCache: "キャッシュを削除",
downloadCacheClearSuccess: "ダウンロードキャッシュを削除しました",
downloadCacheClearFailed: "ダウンロードキャッシュの削除に失敗しました: {error}",
offlineDownloadHint: "エアギャップ環境の場合は、インターネット接続されたマシンでオフラインドライバーパッケージをダウンロードし、ここでインポートしてください。",
offlineDownloadLink: "オフラインドライバーダウンロード",
searchDrivers: "ドライバー名、タイプ、バージョンを検索...",
+4
View File
@@ -3123,8 +3123,12 @@ export default withEnglishFallback({
calculating: "Calculando...",
usageManagedJre: "JRE gerenciada",
usageAgentDrivers: "Agentes de driver integrados",
usageDownloadCache: "Cache de downloads",
usageJdbcPlugin: "Plugin JDBC",
usageJdbcDriverJars: "JARs de driver JDBC",
clearDownloadCache: "Limpar cache",
downloadCacheClearSuccess: "Cache de downloads limpo",
downloadCacheClearFailed: "Falha ao limpar cache de downloads: {error}",
offlineDownloadHint: "Para ambientes sem internet, baixe pacotes de driver offline em uma máquina com acesso à internet e importe-os aqui.",
offlineDownloadLink: "Downloads de driver offline",
searchDrivers: "Pesquisar nome, tipo, versão do driver...",
+4
View File
@@ -3223,8 +3223,12 @@ export default withEnglishFallback({
calculating: "统计中...",
usageManagedJre: "托管 JRE",
usageAgentDrivers: "内置驱动 Agent",
usageDownloadCache: "下载缓存",
usageJdbcPlugin: "JDBC 插件",
usageJdbcDriverJars: "JDBC 驱动 JAR",
clearDownloadCache: "清理缓存",
downloadCacheClearSuccess: "下载缓存已清理",
downloadCacheClearFailed: "下载缓存清理失败: {error}",
offlineDownloadHint: "内网环境可先在有网机器下载离线驱动包,再回到这里导入。",
offlineDownloadLink: "离线驱动下载",
searchDrivers: "搜索驱动名称、类型、版本...",
+4
View File
@@ -3023,8 +3023,12 @@ export default withEnglishFallback({
calculating: "統計中……",
usageManagedJre: "託管 JRE",
usageAgentDrivers: "內建驅動程式 Agent",
usageDownloadCache: "下載快取",
usageJdbcPlugin: "JDBC 外掛程式",
usageJdbcDriverJars: "JDBC 驅動程式 JAR",
clearDownloadCache: "清理快取",
downloadCacheClearSuccess: "下載快取已清理",
downloadCacheClearFailed: "下載快取清理失敗: {error}",
javaRuntimeSaved: "Java 執行環境設定已儲存",
javaRuntimeSaveFailed: "Java 執行環境設定失敗: {error}",
chooseJavaExecutable: "選擇 Java 可執行檔",
+1
View File
@@ -76,6 +76,7 @@ export const uninstallJdbcPlugin = forward("uninstallJdbcPlugin");
export const listInstalledAgentsLocal = forward("listInstalledAgentsLocal");
export const listInstalledAgents = forward("listInstalledAgents");
export const getDriverStoreUsage = forward("getDriverStoreUsage");
export const clearDriverDownloadCache = forward("clearDriverDownloadCache");
export const getDriverRuntimeSummary = forward("getDriverRuntimeSummary");
export const stopDriverRuntime = forward("stopDriverRuntime");
export const restartDriverRuntime = forward("restartDriverRuntime");
+4
View File
@@ -337,6 +337,10 @@ export async function getDriverStoreUsage(): Promise<DriverStoreUsage> {
return get("/api/agents/storage-usage");
}
export async function clearDriverDownloadCache(): Promise<void> {
await del("/api/agents/download-cache");
}
export async function getDriverRuntimeSummary(): Promise<DriverRuntimeSummary> {
return get("/api/agents/runtime");
}
+4
View File
@@ -1108,6 +1108,10 @@ export async function getDriverStoreUsage(): Promise<DriverStoreUsage> {
return invoke("get_driver_store_usage");
}
export async function clearDriverDownloadCache(): Promise<void> {
return invoke("clear_driver_download_cache");
}
export async function getDriverRuntimeSummary(): Promise<DriverRuntimeSummary> {
return invoke("get_driver_runtime_summary");
}