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;
|
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
|
// Attachments of drafts might not have been uploaded yet
|
||||||
if (sequence > attachments.size()) {
|
if (sequence > attachments.size()) {
|
||||||
Log.w("Attachment unavailable sequence=" + sequence + " size=" + attachments.size());
|
Log.w("Attachment unavailable sequence=" + sequence + " size=" + attachments.size());
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get data
|
// Get data
|
||||||
|
@ -662,10 +662,12 @@ public class MessageHelper {
|
||||||
db.attachment().setDownloaded(id, size);
|
db.attachment().setDownloaded(id, size);
|
||||||
|
|
||||||
Log.i("Downloaded attachment size=" + size);
|
Log.i("Downloaded attachment size=" + size);
|
||||||
|
return true;
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
Log.w(ex);
|
Log.w(ex);
|
||||||
// Reset progress on failure
|
// Reset progress on failure
|
||||||
db.attachment().setError(id, Helper.formatThrowable(ex));
|
db.attachment().setError(id, Helper.formatThrowable(ex));
|
||||||
|
return false;
|
||||||
} finally {
|
} finally {
|
||||||
if (os != null)
|
if (os != null)
|
||||||
os.close();
|
os.close();
|
||||||
|
|
|
@ -2638,7 +2638,8 @@ public class ServiceSynchronize extends LifecycleService {
|
||||||
EntityAttachment attachment = attachments.get(i);
|
EntityAttachment attachment = attachments.get(i);
|
||||||
if (!attachment.available)
|
if (!attachment.available)
|
||||||
if (!metered || (attachment.size != null && attachment.size < maxSize))
|
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