feat(driver): clear download cache
This commit is contained in:
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>
|
||||
|
||||
Reference in new issue
Block a user