From 5a9cd6bd80091554c9be8b91d7aee4a8328c2c19 Mon Sep 17 00:00:00 2001 From: Fabian Schlenz Date: Mon, 5 Sep 2016 06:14:52 +0200 Subject: [PATCH] Apparently there can be TLDocuments without any TLDocumentAttributes. This interrupted the message download with an NPE. Fixes #10. --- .../telegram_backup/mediafilemanager/DocumentFileManager.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/de/fabianonline/telegram_backup/mediafilemanager/DocumentFileManager.java b/src/main/java/de/fabianonline/telegram_backup/mediafilemanager/DocumentFileManager.java index 29700ab..5ba6699 100644 --- a/src/main/java/de/fabianonline/telegram_backup/mediafilemanager/DocumentFileManager.java +++ b/src/main/java/de/fabianonline/telegram_backup/mediafilemanager/DocumentFileManager.java @@ -60,7 +60,7 @@ public class DocumentFileManager extends AbstractMediaFileManager { public boolean isSticker() { TLDocumentAttributeSticker sticker = null; - for(TLAbsDocumentAttribute attr : doc.getAttributes()) { + if (doc.getAttributes() != null) for(TLAbsDocumentAttribute attr : doc.getAttributes()) { if (attr instanceof TLDocumentAttributeSticker) { sticker = (TLDocumentAttributeSticker)attr; } @@ -78,7 +78,7 @@ public class DocumentFileManager extends AbstractMediaFileManager { if (doc == null) return "empty"; String ext = null; String original_filename = null; - for(TLAbsDocumentAttribute attr : doc.getAttributes()) { + if (doc.getAttributes() != null) for(TLAbsDocumentAttribute attr : doc.getAttributes()) { if (attr instanceof TLDocumentAttributeFilename) { original_filename = ((TLDocumentAttributeFilename)attr).getFileName(); }