|
8 | 8 | import axios from 'axios'; |
9 | 9 | import { configs } from '../constants'; |
10 | 10 | import { getOrigin } from './origin'; |
11 | | -import { get } from 'lodash'; |
| 11 | +import { get, isEmpty } from 'lodash'; |
12 | 12 | import { MetadataProcessingResult, setMetadataHash, setMetadataProcessingCache, clearMetadataProcessingCache } from '../state/settings/reducer'; |
13 | 13 | import { getState } from '../state/store'; |
14 | 14 | import { dispatch } from '../state/dispatch'; |
@@ -120,6 +120,10 @@ async function processMetadataWithCaching( |
120 | 120 | dataFetcher: () => Promise<any>): Promise<string | undefined> { |
121 | 121 | // Fetch the data |
122 | 122 | const data = await dataFetcher() |
| 123 | + if (isEmpty(data)) { |
| 124 | + console.warn(`[minusx] No data found for ${metadataType}, skipping upload`) |
| 125 | + return undefined; // No data to process |
| 126 | + } |
123 | 127 | console.log('Retrieved data for metadata type', metadataType, data) |
124 | 128 |
|
125 | 129 | // Calculate hash of current data |
@@ -272,6 +276,10 @@ export async function processAllMetadata() : Promise<MetadataProcessingResult> { |
272 | 276 | } |
273 | 277 |
|
274 | 278 | // Cache the result for this database ID |
| 279 | + if (!result.cardsHash) { |
| 280 | + console.warn('[minusx] Cardshash is undefined, not caching result') |
| 281 | + return result; // Return even if some hashes are missing |
| 282 | + } |
275 | 283 | dispatch(setMetadataProcessingCache({ dbId: selectedDbId, result })) |
276 | 284 | console.log(`[minusx] Cached metadata processing result for database ${selectedDbId}`) |
277 | 285 |
|
|
0 commit comments