mirror of https://github.com/M66B/FairEmail.git
Stop downloading attachments on error
This commit is contained in:
parent
3b06c3d027
commit
7dc4f6ecf3
|
@ -627,11 +627,11 @@ public class MessageHelper {
|
|||
return result;
|
||||
}
|
||||
|
||||
void downloadAttachment(Context context, DB db, long id, int sequence) throws IOException {
|
||||
boolean downloadAttachment(Context context, DB db, long id, int sequence) throws IOException {
|
||||
// Attachments of drafts might not have been uploaded yet
|
||||
if (sequence > attachments.size()) {
|
||||
Log.w("Attachment unavailable sequence=" + sequence + " size=" + attachments.size());
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get data
|
||||
|
@ -662,10 +662,12 @@ public class MessageHelper {
|
|||
db.attachment().setDownloaded(id, size);
|
||||
|
||||
Log.i("Downloaded attachment size=" + size);
|
||||
return true;
|
||||
} catch (Throwable ex) {
|
||||
Log.w(ex);
|
||||
// Reset progress on failure
|
||||
db.attachment().setError(id, Helper.formatThrowable(ex));
|
||||
return false;
|
||||
} finally {
|
||||
if (os != null)
|
||||
os.close();
|
||||
|
|
|
@ -2638,7 +2638,8 @@ public class ServiceSynchronize extends LifecycleService {
|
|||
EntityAttachment attachment = attachments.get(i);
|
||||
if (!attachment.available)
|
||||
if (!metered || (attachment.size != null && attachment.size < maxSize))
|
||||
parts.downloadAttachment(context, db, attachment.id, attachment.sequence);
|
||||
if (!parts.downloadAttachment(context, db, attachment.id, attachment.sequence))
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue