fix(mail): „Anhänge prüfen“ erkennt Duplikate auch über den Inhalt
Build and Push Multi-Platform Images / build-and-push (push) Successful in 32s
Build and Push Multi-Platform Images / build-and-push (push) Successful in 32s
check-attachments fragte nur die Checksumme bei Paperless ab. Neu erzeugte PDFs mit gleichem Inhalt wie ein bereits importierter Anhang blieben dadurch auf „Neu“. Findet Paperless die Checksumme nicht, wird jetzt per Text-Fingerprint nach einem importierten Anhang gesucht; die Mail wird dann als verarbeitet markiert und die Paperless-ID übernommen. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
797cbb9b71
commit
acb9076944
4 files changed
+138
-5
No files matched your search
@@ -88,6 +88,29 @@ export class AttachmentFingerprintService implements OnApplicationBootstrap {
|
||||
return count > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sucht einen bereits importierten Anhang mit gleichem Inhalt und liefert
|
||||
* dessen Paperless-Dokument-ID (sofern beim Import ermittelt).
|
||||
*/
|
||||
async findImportedTwin(
|
||||
attachment: Attachment,
|
||||
): Promise<{ attachmentId: number; documentId: number | null } | null> {
|
||||
const fingerprint = await this.ensure(attachment);
|
||||
if (!fingerprint) return null;
|
||||
|
||||
const twin = await this.attachmentRepo
|
||||
.createQueryBuilder('a')
|
||||
.where('a.ContentFingerprint = :fingerprint', { fingerprint })
|
||||
.andWhere('a.Id != :attachmentId', { attachmentId: attachment.Id })
|
||||
.andWhere('a.ImportStatus = 1')
|
||||
.orderBy('a.Id', 'ASC')
|
||||
.getOne();
|
||||
if (!twin) return null;
|
||||
|
||||
const ids = twin.PaperlessDocumentIds as Record<string, number> | null;
|
||||
return { attachmentId: twin.Id, documentId: ids?.full ?? null };
|
||||
}
|
||||
|
||||
/** Berechnet fehlende Fingerprints aller PDF-Anhänge in kleinen Portionen. */
|
||||
async backfill(batchSize = 25): Promise<number> {
|
||||
let lastId = 0;
|
||||
|
||||
Reference in new issue
Block a user