fix(parcel-sync): sync progress visible during GPKG/bundle export

3 bugs fixed:
- syncLayer was called without jobId -> user saw no progress duringSync
- syncLayer set status:'done' prematurely -> client stopped polling before GPKG phase
- syncLayer errors were silently ignored -> confusing 'no features in DB' error

Added isSubStep option to syncLayer: when true, keeps status as 'running'
and doesn't schedule clearProgress. Export routes now pass jobId + isSubStep
so the real sync progress (Descărcare features 50/200) is visible in the UI.
This commit is contained in:
AI Assistant
2026-03-07 11:23:36 +02:00
parent b0927ee075
commit 097d010b5d
3 changed files with 26 additions and 11 deletions
@@ -50,9 +50,13 @@ export async function syncLayer(
uatName?: string;
jobId?: string;
forceFullSync?: boolean;
/** When true, don't set terminal status (done/error) on progress store.
* Used when syncLayer runs as a sub-step of a larger export flow. */
isSubStep?: boolean;
},
): Promise<SyncResult> {
const jobId = options?.jobId;
const isSubStep = options?.isSubStep ?? false;
const layer = findLayerById(layerId);
if (!layer) throw new Error(`Layer ${layerId} not found`);
@@ -261,12 +265,12 @@ export async function syncLayer(
});
push({
phase: "Finalizat",
status: "done",
phase: "Sync finalizat",
status: isSubStep ? "running" : "done",
downloaded: remoteCount,
total: remoteCount,
});
if (jobId) setTimeout(() => clearProgress(jobId), 60_000);
if (jobId && !isSubStep) setTimeout(() => clearProgress(jobId), 60_000);
return {
layerId,
@@ -283,8 +287,8 @@ export async function syncLayer(
where: { id: syncRun.id },
data: { status: "error", errorMessage: msg, completedAt: new Date() },
});
push({ phase: "Eroare", status: "error", message: msg });
if (jobId) setTimeout(() => clearProgress(jobId), 60_000);
push({ phase: "Eroare sync", status: isSubStep ? "running" : "error", message: msg });
if (jobId && !isSubStep) setTimeout(() => clearProgress(jobId), 60_000);
return {
layerId,
siruta,