mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 11:19:04 +01:00
Make deleting a non-existent file is tolerable
This commit is contained in:
@@ -92,9 +92,13 @@ interface MailboxApi {
|
||||
* Used by owner and contacts to delete files.
|
||||
* <p>
|
||||
* Returns 200 OK (no exception) if deletion was successful.
|
||||
*
|
||||
* @throws TolerableFailureException on 404 response,
|
||||
* because file was most likely deleted already.
|
||||
*/
|
||||
void deleteFile(MailboxProperties properties, String folderId,
|
||||
String fileId) throws IOException, ApiException;
|
||||
String fileId)
|
||||
throws IOException, ApiException, TolerableFailureException;
|
||||
|
||||
/**
|
||||
* Lists all contact outboxes that have files available
|
||||
|
||||
@@ -223,7 +223,8 @@ class MailboxApiImpl implements MailboxApi {
|
||||
|
||||
@Override
|
||||
public void deleteFile(MailboxProperties properties, String folderId,
|
||||
String fileId) throws IOException, ApiException {
|
||||
String fileId)
|
||||
throws IOException, ApiException, TolerableFailureException {
|
||||
String path = "/files/" + folderId + "/" + fileId;
|
||||
Request request = getRequestBuilder(properties.getAuthToken())
|
||||
.delete()
|
||||
@@ -231,6 +232,7 @@ class MailboxApiImpl implements MailboxApi {
|
||||
.build();
|
||||
OkHttpClient client = httpClientProvider.get();
|
||||
Response response = client.newCall(request).execute();
|
||||
if (response.code() == 404) throw new TolerableFailureException();
|
||||
if (response.code() != 200) throw new ApiException();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user