mirror of https://github.com/M66B/FairEmail.git
Small improvement
This commit is contained in:
parent
989bdb1cb9
commit
752aee0a3b
|
@ -52,7 +52,7 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||||
import com.google.android.material.snackbar.Snackbar;
|
import com.google.android.material.snackbar.Snackbar;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.FileNotFoundException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
@ -178,16 +178,26 @@ public class AdapterAttachment extends RecyclerView.Adapter<AdapterAttachment.Vi
|
||||||
|
|
||||||
new SimpleTask<Void>() {
|
new SimpleTask<Void>() {
|
||||||
@Override
|
@Override
|
||||||
protected Void onExecute(Context context, Bundle args) throws IOException {
|
protected Void onExecute(Context context, Bundle args) throws FileNotFoundException {
|
||||||
long id = args.getLong("id");
|
long id = args.getLong("id");
|
||||||
|
|
||||||
DB db = DB.getInstance(context);
|
DB db = DB.getInstance(context);
|
||||||
|
try {
|
||||||
|
db.beginTransaction();
|
||||||
|
|
||||||
EntityAttachment attachment = db.attachment().getAttachment(id);
|
EntityAttachment attachment = db.attachment().getAttachment(id);
|
||||||
if (attachment == null)
|
if (attachment == null)
|
||||||
return null;
|
return null;
|
||||||
db.attachment().setDownloaded(id, null);
|
|
||||||
attachment.getFile(context).delete();
|
db.attachment().deleteAttachment(attachment.id);
|
||||||
db.attachment().deleteAttachment(id);
|
|
||||||
|
db.setTransactionSuccessful();
|
||||||
|
} finally {
|
||||||
|
db.endTransaction();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!attachment.getFile(context).delete())
|
||||||
|
throw new FileNotFoundException(attachment.getFile(context).toString());
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue