Skip to content

Commit 0c07328

Browse files
committed
refactor: remove unused content store functionality
1 parent c666223 commit 0c07328

28 files changed

Lines changed: 68 additions & 1315 deletions

File tree

‎apps/app-frontend/src/components/ui/download-manager/store-verification.ts‎

Lines changed: 0 additions & 65 deletions
This file was deleted.

‎apps/app-frontend/src/components/ui/download-manager/use-download-manager.ts‎

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import {
3232
getExternalFileDownloadRate,
3333
} from './external-file-downloads'
3434
import { createInstallJobProgressTracker } from './install-job-progress'
35-
import { storeVerificationTask } from './store-verification'
3635
import { useInstallJobDisplay } from './use-install-job-display'
3736

3837
export interface DownloadManagerJob {
@@ -62,19 +61,6 @@ export interface DownloadManagerJob {
6261
busy: boolean
6362
}
6463

65-
const verificationMessages = defineMessages({
66-
verifying: { id: 'app.download-manager.verifying', defaultMessage: 'Verifying' },
67-
title: { id: 'app.settings.resource-management.store.title', defaultMessage: 'Content storage' },
68-
complete: {
69-
id: 'app.settings.resource-management.store.verified',
70-
defaultMessage: 'Verification complete',
71-
},
72-
failed: {
73-
id: 'app.settings.resource-management.store.attention',
74-
defaultMessage: 'Some files still need attention',
75-
},
76-
})
77-
7864
const fileMessages = defineMessages({
7965
preparing: { id: 'app.file-download.preparing', defaultMessage: 'Preparing download…' },
8066
waiting: { id: 'app.file-download.waiting', defaultMessage: 'Waiting for the server…' },
@@ -176,17 +162,12 @@ export function useDownloadManager() {
176162
}),
177163
)
178164

179-
const verificationRows = computed(() => {
180-
const task = storeVerificationTask.value
181-
return task ? [buildVerificationRow(task)] : []
182-
})
183165
const fileRows = computed(() => [...externalFileDownloads.value.values()].map(buildFileRow))
184166
const debugExportRows = computed(() =>
185167
[...debugInfoExports.value.values()].map(buildDebugExportRow),
186168
)
187169
const allRows = computed(() => [
188170
...rows.value,
189-
...verificationRows.value,
190171
...fileRows.value,
191172
...debugExportRows.value,
192173
])
@@ -324,44 +305,6 @@ export function useDownloadManager() {
324305
}
325306
}
326307

327-
function buildVerificationRow(
328-
task: NonNullable<typeof storeVerificationTask.value>,
329-
): DownloadManagerJob {
330-
const progress = task.total ? Math.min(0.99, task.current / task.total) : 0
331-
const rate = task.status === 'running' && now.value - task.lastRead < 2000 ? task.rate : 0
332-
333-
return {
334-
id: task.id,
335-
instanceId: null,
336-
status: task.status,
337-
paused: false,
338-
canceling: false,
339-
canPause: false,
340-
canCancel: false,
341-
canRetry: false,
342-
title: formatMessage(verificationMessages.title),
343-
iconUrl: null,
344-
text: formatMessage(
345-
task.status === 'running'
346-
? verificationMessages.verifying
347-
: task.status === 'succeeded'
348-
? verificationMessages.complete
349-
: verificationMessages.failed,
350-
),
351-
progress,
352-
overallProgress: task.status === 'succeeded' ? 1 : progress,
353-
progressLabel:
354-
task.status === 'running'
355-
? `${formatBytes(task.current)} / ${formatBytes(task.total)} · ${display.formatRate(rate) || '0 B/s'}`
356-
: '',
357-
waiting: task.total === 0 || task.current >= task.total,
358-
eta: '',
359-
canCopyDetails: false,
360-
copied: false,
361-
busy: false,
362-
}
363-
}
364-
365308
function newestFirst(a: DownloadManagerJob, b: DownloadManagerJob) {
366309
return (b.finishedAt ?? '').localeCompare(a.finishedAt ?? '')
367310
}
@@ -491,10 +434,6 @@ export function useDownloadManager() {
491434
if (file.status !== 'running') externalFileDownloads.value.delete(id)
492435
return
493436
}
494-
if (storeVerificationTask.value?.id === id) {
495-
if (storeVerificationTask.value.status !== 'running') storeVerificationTask.value = null
496-
return
497-
}
498437
const job = jobs.value.get(id)
499438
if (!job || job.status === 'queued' || job.status === 'running') return
500439
await runAction(id, async () => {

‎apps/app-frontend/src/features/settings/system/resource-management-settings/content-storage.vue‎

Lines changed: 11 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<script setup lang="ts">
2-
import { LoaderCircleIcon, ShieldCheckIcon, TrashIcon } from '@modrinth/assets'
2+
import { LoaderCircleIcon, TrashIcon } from '@modrinth/assets'
33
import {
4-
Admonition,
54
Button,
65
defineMessages,
76
injectNotificationManager,
@@ -14,14 +13,6 @@ import { useMutation, useQuery, useQueryClient } from '@tanstack/vue-query'
1413
import { invoke } from '@tauri-apps/api/core'
1514
import { computed, ref, watch } from 'vue'
1615
17-
import {
18-
storeVerificationReport as report,
19-
verifyingStore,
20-
verifyStore,
21-
} from '@/components/ui/download-manager/store-verification'
22-
import { useAppEvent } from '@/composables/use-app-event'
23-
import { injectAppSettingsModal } from '@/features/settings/app-settings-modal/context'
24-
import { get_all as getRunningProcesses } from '@/helpers/process'
2516
2617
type StoreUsage = {
2718
unique_bytes: number
@@ -33,7 +24,6 @@ type StoreUsage = {
3324
}
3425
3526
const { handleError } = injectNotificationManager()
36-
const settingsModal = injectAppSettingsModal()
3727
const { formatMessage } = useVIntl()
3828
const formatBytes = useFormatBytes()
3929
const gibibyte = 1024 ** 3
@@ -64,27 +54,11 @@ watch(
6454
watch(storeUsageError, (error) => {
6555
if (error) handleError(error)
6656
})
67-
const runningProcessesKey = ['processes', 'running'] as const
68-
const { data: runningProcesses, error: runningProcessesError } = useQuery({
69-
queryKey: runningProcessesKey,
70-
queryFn: getRunningProcesses,
71-
})
72-
const hasRunningInstances = computed(() => (runningProcesses.value?.length ?? 0) > 0)
73-
watch(runningProcessesError, (error) => {
74-
if (error) handleError(error)
75-
})
76-
useAppEvent('process', () => queryClient.invalidateQueries({ queryKey: runningProcessesKey }))
7757
const busy = computed(
78-
() =>
79-
calculating.value ||
80-
actionMutation.isPending.value ||
81-
cacheLimitMutation.isPending.value ||
82-
verifyingStore.value,
83-
)
84-
const clearing = computed(
85-
() => actionMutation.isPending.value && actionMutation.variables.value === 'clear',
58+
() => calculating.value || clearMutation.isPending.value || cacheLimitMutation.isPending.value,
8659
)
87-
const clearedBytes = computed(() => actionMutation.data.value ?? null)
60+
const clearing = computed(() => clearMutation.isPending.value)
61+
const clearedBytes = computed(() => clearMutation.data.value ?? null)
8862
const totalBytes = computed(
8963
() => (storeUsage.value?.unique_bytes ?? 0) + (storeUsage.value?.private_copy_bytes ?? 0),
9064
)
@@ -126,22 +100,6 @@ const messages = defineMessages({
126100
id: 'app.settings.resource-management.store.clearing',
127101
defaultMessage: 'Clearing…',
128102
},
129-
repair: {
130-
id: 'app.settings.resource-management.store.repair',
131-
defaultMessage: 'Verify and repair',
132-
},
133-
repairing: {
134-
id: 'app.settings.resource-management.store.repairing',
135-
defaultMessage: 'Verifying and repairing…',
136-
},
137-
repairDescription: {
138-
id: 'app.settings.resource-management.store.repair.verify-description',
139-
defaultMessage: 'Check for missing or damaged files and repair them.',
140-
},
141-
repairRunningDescription: {
142-
id: 'app.settings.resource-management.store.repair.running-description',
143-
defaultMessage: 'This will close any running instances.',
144-
},
145103
clearDescription: {
146104
id: 'app.settings.resource-management.store.clear.description',
147105
defaultMessage: 'Delete unused downloaded content',
@@ -167,23 +125,6 @@ const messages = defineMessages({
167125
id: 'app.settings.resource-management.store.nothing-to-clear',
168126
defaultMessage: 'No unused content to clear.',
169127
},
170-
verified: {
171-
id: 'app.settings.resource-management.store.verified',
172-
defaultMessage: 'Verification complete',
173-
},
174-
attention: {
175-
id: 'app.settings.resource-management.store.attention',
176-
defaultMessage: 'Some files still need attention',
177-
},
178-
result: {
179-
id: 'app.settings.resource-management.store.verification-result',
180-
defaultMessage:
181-
'Checked {checked, plural, one {# file} other {# files}} and made {repaired, plural, one {# repair} other {# repairs}}.',
182-
},
183-
issues: {
184-
id: 'app.settings.resource-management.store.issues',
185-
defaultMessage: 'View {count, plural, one {# issue} other {# issues}}',
186-
},
187128
})
188129
189130
const categories = computed(() => {
@@ -211,27 +152,16 @@ const categories = computed(() => {
211152
]
212153
})
213154
214-
const actionMutation = useMutation({
215-
mutationFn: async (action: 'clear' | 'repair') => {
216-
if (action === 'repair') {
217-
const verification = verifyStore()
218-
settingsModal.close()
219-
await verification
220-
return null
221-
}
222-
return invoke<number>('plugin:settings|store_cleanup')
223-
},
224-
onMutate: () => {
225-
report.value = null
226-
},
155+
const clearMutation = useMutation({
156+
mutationFn: () => invoke<number>('plugin:settings|store_cleanup'),
227157
onSuccess: () => queryClient.invalidateQueries({ queryKey: storeUsageKey }),
228158
onError: handleError,
229159
})
230160
231-
function runAction(action: 'clear' | 'repair') {
161+
function clearUnused() {
232162
if (busy.value) return
233-
actionMutation.reset()
234-
actionMutation.mutate(action)
163+
clearMutation.reset()
164+
clearMutation.mutate()
235165
}
236166
237167
const cacheLimitMutation = useMutation({
@@ -321,33 +251,13 @@ function saveCacheLimit() {
321251
</div>
322252

323253
<div class="flex flex-wrap items-center gap-2">
324-
<Button
325-
v-tooltip="
326-
formatMessage(
327-
hasRunningInstances ? messages.repairRunningDescription : messages.repairDescription,
328-
)
329-
"
330-
:type="hasRunningInstances ? 'colored' : 'base'"
331-
:color="hasRunningInstances ? 'orange' : undefined"
332-
:disabled="busy || !storeUsage || storeUsage.object_count === 0"
333-
:loading="verifyingStore"
334-
@click="runAction('repair')"
335-
>
336-
<LoaderCircleIcon
337-
v-if="verifyingStore"
338-
class="motion-safe:animate-spin"
339-
aria-hidden="true"
340-
/>
341-
<ShieldCheckIcon v-else aria-hidden="true" />
342-
{{ formatMessage(verifyingStore ? messages.repairing : messages.repair) }}
343-
</Button>
344254
<Button
345255
v-tooltip="formatMessage(messages.clearDescription)"
346256
type="colored"
347257
color="red"
348258
:disabled="busy || !storeUsage || storeUsage.unused_cache_bytes === 0"
349259
:loading="clearing"
350-
@click="runAction('clear')"
260+
@click="clearUnused"
351261
>
352262
<LoaderCircleIcon v-if="clearing" class="motion-safe:animate-spin" aria-hidden="true" />
353263
<TrashIcon v-else aria-hidden="true" />
@@ -356,32 +266,7 @@ function saveCacheLimit() {
356266
</div>
357267

358268
<div aria-live="polite" class="empty:hidden">
359-
<Admonition
360-
v-if="report"
361-
:type="report.issues.length ? 'warning' : 'success'"
362-
:header="formatMessage(report.issues.length ? messages.attention : messages.verified)"
363-
>
364-
<p class="m-0">
365-
{{
366-
formatMessage(messages.result, { checked: report.checked, repaired: report.repaired })
367-
}}
368-
</p>
369-
<details v-if="report.issues.length" class="mt-2">
370-
<summary class="cursor-pointer font-semibold">
371-
{{ formatMessage(messages.issues, { count: report.issues.length }) }}
372-
</summary>
373-
<ul class="mb-0 flex flex-col gap-2 pl-5">
374-
<li
375-
v-for="(issue, index) in report.issues"
376-
:key="`${issue.sha512}-${index}`"
377-
class="break-words"
378-
>
379-
{{ issue.message }}
380-
</li>
381-
</ul>
382-
</details>
383-
</Admonition>
384-
<p v-else-if="clearedBytes !== null" class="m-0 text-sm text-green">
269+
<p v-if="clearedBytes !== null" class="m-0 text-sm text-green">
385270
{{
386271
clearedBytes > 0
387272
? formatMessage(messages.cleared, { size: formatBytes(clearedBytes, 1) })

0 commit comments

Comments
 (0)