mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-06 18:54:17 +00:00
fix(mail-ingest): create missing IMAP archive parent on demand
This commit is contained in:
@@ -121,6 +121,18 @@ class ImapFlowSession implements ImapSession {
|
||||
const existing = await this.findFolder(parts);
|
||||
if (existing !== null) return existing;
|
||||
|
||||
try {
|
||||
return await this.createFolder(parts);
|
||||
} catch (err) {
|
||||
// Some servers require the parent to be created separately.
|
||||
const parent = parts.slice(0, -1);
|
||||
if (parent.length === 0 || (await this.findFolder(parent)) !== null) throw err;
|
||||
await this.createFolder(parent);
|
||||
return this.createFolder(parts);
|
||||
}
|
||||
}
|
||||
|
||||
private async createFolder(parts: readonly string[]): Promise<string> {
|
||||
try {
|
||||
const created = await this.client.mailboxCreate([...parts]);
|
||||
return created.path;
|
||||
|
||||
Reference in New Issue
Block a user