refactor(data.worker): streamline logging and comments in scanMissingData function for improved clarity and resource management
This commit is contained in:
parent
81025dca42
commit
77019896e5
@ -78,8 +78,6 @@ function getMultipleObjects(db, storeName, keys) {
|
|||||||
// ============================================
|
// ============================================
|
||||||
|
|
||||||
async function scanMissingData(processesToScan) {
|
async function scanMissingData(processesToScan) {
|
||||||
console.log("[Service Worker] 🚀 Scanning with DIRECT DB ACCESS...");
|
|
||||||
|
|
||||||
let db;
|
let db;
|
||||||
try {
|
try {
|
||||||
db = await openDB();
|
db = await openDB();
|
||||||
@ -103,7 +101,6 @@ async function scanMissingData(processesToScan) {
|
|||||||
if (!process || !process.states) continue;
|
if (!process || !process.states) continue;
|
||||||
|
|
||||||
const firstState = process.states[0];
|
const firstState = process.states[0];
|
||||||
// Sécurisation : on vérifie que firstState existe
|
|
||||||
if (!firstState) continue;
|
if (!firstState) continue;
|
||||||
|
|
||||||
const processId = firstState.commited_in;
|
const processId = firstState.commited_in;
|
||||||
@ -112,7 +109,6 @@ async function scanMissingData(processesToScan) {
|
|||||||
if (state.state_id === EMPTY32BYTES) continue;
|
if (state.state_id === EMPTY32BYTES) continue;
|
||||||
|
|
||||||
for (const [field, hash] of Object.entries(state.pcd_commitment)) {
|
for (const [field, hash] of Object.entries(state.pcd_commitment)) {
|
||||||
// On ignore les données publiques ou les rôles
|
|
||||||
if (
|
if (
|
||||||
(state.public_data && state.public_data[field] !== undefined) ||
|
(state.public_data && state.public_data[field] !== undefined) ||
|
||||||
field === "roles"
|
field === "roles"
|
||||||
@ -144,7 +140,6 @@ async function scanMissingData(processesToScan) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Si on a trouvé la donnée, on est sûr de ne pas avoir besoin de la télécharger
|
|
||||||
if (toDownload.has(hash)) {
|
if (toDownload.has(hash)) {
|
||||||
toDownload.delete(hash);
|
toDownload.delete(hash);
|
||||||
}
|
}
|
||||||
@ -154,13 +149,17 @@ async function scanMissingData(processesToScan) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// On ferme la connexion BDD pour libérer les ressources
|
// On ferme la connexion BDD
|
||||||
db.close();
|
db.close();
|
||||||
|
|
||||||
console.log("[Service Worker] Scan complete:", {
|
// ✅ LOG PERTINENT UNIQUEMENT : On n'affiche que si on a trouvé quelque chose
|
||||||
|
if (toDownload.size > 0 || diffsToCreate.length > 0) {
|
||||||
|
console.log("[Service Worker] 🔄 Scan found items:", {
|
||||||
toDownload: toDownload.size,
|
toDownload: toDownload.size,
|
||||||
diffsToCreate: diffsToCreate.length,
|
diffsToCreate: diffsToCreate.length,
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
toDownload: Array.from(toDownload),
|
toDownload: Array.from(toDownload),
|
||||||
diffsToCreate: diffsToCreate,
|
diffsToCreate: diffsToCreate,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user