1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2025-02-24 23:12:55 +00:00

Explicit exceptions

This commit is contained in:
M66B 2019-03-14 07:51:22 +00:00
parent 98b84f8927
commit 0c74aa4cfa
3 changed files with 8 additions and 5 deletions

View file

@ -64,6 +64,7 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
@ -1424,7 +1425,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
DB db = DB.getInstance(context);
EntityMessage message = db.message().getMessage(id);
if (message == null)
return null;
throw new FileNotFoundException();
File file = message.getRawFile(context);
Log.i("Raw file=" + file);
@ -1498,7 +1499,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
DB db = DB.getInstance(context);
EntityAttachment attachment = db.attachment().getAttachment(id);
if (attachment == null)
return null;
throw new FileNotFoundException();
File file = attachment.getFile(context);
ParcelFileDescriptor pfd = null;

View file

@ -41,6 +41,8 @@ import android.widget.TextView;
import android.widget.Toast;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
@ -170,13 +172,13 @@ public class AdapterAttachment extends RecyclerView.Adapter<AdapterAttachment.Vi
new SimpleTask<Void>() {
@Override
protected Void onExecute(Context context, Bundle args) {
protected Void onExecute(Context context, Bundle args) throws IOException {
long id = args.getLong("id");
DB db = DB.getInstance(context);
EntityAttachment attachment = db.attachment().getAttachment(id);
if (attachment == null)
return null;
throw new FileNotFoundException();
db.attachment().setDownloaded(id, null);
attachment.getFile(context).delete();
db.attachment().deleteAttachment(id);

View file

@ -561,7 +561,7 @@ public class FragmentCompose extends FragmentBase {
DB db = DB.getInstance(context);
EntityMessage draft = db.message().getMessage(id);
if (draft == null)
return null;
throw new FileNotFoundException();
File file = draft.getFile(context);
File refFile = draft.getRefFile(context);