Copy attachments to sent folder

This commit is contained in:
M66B
2019-01-22 18:02:30 +00:00
parent 5d8ad7ef9c
commit ee7771dedd
3 changed files with 25 additions and 18 deletions

View File

@@ -22,6 +22,8 @@ package eu.faircode.email;
import android.content.Context;
import java.io.File;
import java.io.IOException;
import java.util.List;
import javax.mail.Part;
@@ -79,6 +81,26 @@ public class EntityAttachment {
return new File(dir, Long.toString(id));
}
static void copy(Context context, DB db, long oldid, long newid) {
List<EntityAttachment> attachments = db.attachment().getAttachments(oldid);
for (EntityAttachment attachment : attachments) {
long aid = attachment.id;
attachment.id = null;
attachment.message = newid;
attachment.progress = null;
attachment.id = db.attachment().insertAttachment(attachment);
if (attachment.available)
try {
Helper.copy(
EntityAttachment.getFile(context, aid),
EntityAttachment.getFile(context, attachment.id));
} catch (IOException ex) {
Log.e(ex);
db.attachment().setProgress(attachment.id, null);
}
}
}
@Override
public boolean equals(Object obj) {
if (obj instanceof EntityAttachment) {