MCPcopy Create free account
hub / github.com/codexu/note-gen / processQueue

Function processQueue

src/lib/sync/auto-data-sync-queue.ts:950–1109  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

948}
949
950async function processQueue() {
951 if (processing || queue.length === 0) {
952 debugAutoDataSync('skip queue processing', {
953 processing,
954 pendingCount: queue.length,
955 })
956 return
957 }
958
959 if (!await isAutoDataSyncEnabled()) {
960 queue = []
961 debugAutoDataSync('clear queue because auto data sync is disabled')
962 updateState({
963 isSyncing: false,
964 phase: 'idle',
965 currentDomain: null,
966 status: 'idle',
967 lastError: null,
968 })
969 return
970 }
971
972 if (!await isAutoDataSyncProviderConfigured()) {
973 queue = []
974 debugAutoDataSync('clear queue because provider is not configured')
975 updateState({
976 isSyncing: false,
977 phase: 'waiting_provider',
978 currentDomain: null,
979 syncMode: null,
980 status: 'waiting_provider',
981 lastError: null,
982 })
983 return
984 }
985
986 processing = true
987 const uploadedDomains = new Set<AutoDataSyncDomain>()
988 debugAutoDataSync('queue processing started', { pendingCount: queue.length })
989
990 while (queue.length > 0) {
991 const task = queue.shift()
992 if (!task) {
993 continue
994 }
995
996 debugAutoDataSync('task started', {
997 id: task.id,
998 seq: task.seq,
999 domain: task.domain,
1000 reason: task.reason,
1001 mode: task.mode,
1002 retryCount: task.retryCount,
1003 remainingCount: queue.length,
1004 })
1005 const taskStartedAt = Date.now()
1006
1007 try {

Callers 2

flushAutoDataSyncNowFunction · 0.85
scheduleProcessFunction · 0.85

Calls 13

debugAutoDataSyncFunction · 0.85
isAutoDataSyncEnabledFunction · 0.85
updateStateFunction · 0.85
getAutoDataSyncProviderFunction · 0.85
downloadAutoDataSyncNowFunction · 0.85
uploadDomainFunction · 0.85
uploadAutoDataSyncMetaFunction · 0.85
dropRedundantFrontTasksFunction · 0.85

Tested by

no test coverage detected