MCPcopy Create free account
hub / github.com/Datakitpage/Datakit / getStorageInfo

Method getStorageInfo

frontend/src/lib/ai/modelManager.ts:31–60  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

29
30 // Get storage usage information
31 async getStorageInfo(): Promise<ModelStorageInfo> {
32 const models = this.getDownloadedModels();
33 const totalSizeBytes = models.reduce((sum, model) => sum + (model.size * 1024 * 1024), 0);
34
35 let availableSpace: number | undefined;
36
37 // Try to get storage quota if available
38 if ('storage' in navigator && 'estimate' in navigator.storage) {
39 try {
40 const estimate = await navigator.storage.estimate();
41 if (estimate.quota && estimate.usage) {
42 availableSpace = estimate.quota - estimate.usage;
43 }
44 } catch (error) {
45 console.warn('Could not estimate storage usage:', error);
46 }
47 }
48
49 return {
50 totalModels: models.length,
51 totalSizeBytes,
52 availableSpace,
53 models: models.map(model => ({
54 modelId: model.id,
55 sizeBytes: model.size * 1024 * 1024,
56 lastUsed: new Date(model.lastUsed || Date.now()),
57 downloadDate: new Date(model.downloadDate || Date.now()),
58 })),
59 };
60 }
61
62 // Check if there's enough space for a model
63 async canDownloadModel(modelSizeMB: number): Promise<{ canDownload: boolean; reason?: string }> {

Callers 2

canDownloadModelMethod · 0.95
loadDataFunction · 0.80

Calls 1

getDownloadedModelsMethod · 0.95

Tested by

no test coverage detected