Fix variable names

thanks, copilot... but no thanks. TF is idx myidx??
This commit is contained in:
Clara K 2025-12-13 09:17:19 +01:00 committed by GitHub
parent b95b9b3db1
commit f68dfe0da2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -175,8 +175,6 @@ class ImapService extends EventEmitter {
} }
this.loadingInProgress = true this.loadingInProgress = true
debug('Starting load of mail summaries') debug('Starting load of mail summaries')
// UID: Unique id of a message.
const uids = await this._getAllUids() const uids = await this._getAllUids()
const newUids = uids.filter(uid => !this.loadedUids.has(uid)) const newUids = uids.filter(uid => !this.loadedUids.has(uid))
debug(`UIDs on server: ${uids.length}, new UIDs to fetch: ${newUids.length}, already loaded: ${this.loadedUids.size}`) debug(`UIDs on server: ${uids.length}, new UIDs to fetch: ${newUids.length}, already loaded: ${this.loadedUids.size}`)
@ -189,17 +187,17 @@ class ImapService extends EventEmitter {
const uidChunks = _.chunk(newUids, chunkSize) const uidChunks = _.chunk(newUids, chunkSize)
debug(`Chunk size: ${chunkSize}, concurrency: ${concurrency}, chunks to process: ${uidChunks.length}`) debug(`Chunk size: ${chunkSize}, concurrency: ${concurrency}, chunks to process: ${uidChunks.length}`)
// Limited-concurrency runner // Limited-concurrency worker
const pool = [] const pool = []
let idx = 0 let workerId = 0
const runNext = async() => { const runNext = async() => {
if (idx >= uidChunks.length) return if (workerId >= uidChunks.length) return
const myIdx = idx++ const chunkId = workerId++
const chunk = uidChunks[myIdx] const chunk = uidChunks[chunkId]
try { try {
debug(`Worker processing chunk ${myIdx + 1}/${uidChunks.length} (size: ${chunk.length})`) debug(`Worker processing chunk ${chunkId + 1}/${uidChunks.length} (size: ${chunk.length})`)
await this._getMailHeadersAndEmitAsEvents(chunk) await this._getMailHeadersAndEmitAsEvents(chunk)
debug(`Completed chunk ${myIdx + 1}/${uidChunks.length}; loadedUids size now: ${this.loadedUids.size}`) debug(`Completed chunk ${chunkId + 1}/${uidChunks.length}; loadedUids size now: ${this.loadedUids.size}`)
} finally { } finally {
await runNext() await runNext()
} }