Skip to content

Commit

Permalink
Use lighter deleteArticle API method
Browse files Browse the repository at this point in the history
  • Loading branch information
di72nn committed Oct 29, 2019
1 parent d5876f2 commit 18cbd69
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,23 @@ public Article addArticle(String url) throws UnsuccessfulResponseException, IOEx
return wallabagService.addArticle(url);
}

public Article deleteArticle(int articleID)
public boolean deleteArticle(int articleID)
throws UnsuccessfulResponseException, IOException {
boolean found = false;

try {
return wallabagService.deleteArticle(articleID);
if (CompatibilityHelper.isDeleteArticleWithIdSupported(wallabagService)) {
wallabagService.deleteArticleWithId(articleID);
found = true;
} else {
LOG.debug("deleteArticle() using older API method");
found = wallabagService.deleteArticle(articleID) != null;
}
} catch(NotFoundException e) {
LOG.info("Ignoring not found exception for article ID: " + articleID, e);
LOG.info("deleteArticle() Ignoring not found exception for article ID: " + articleID, e);
}

return null;
return found;
}

public WallabagService getWallabagService() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ private Pair<ActionResult, Long> syncOfflineQueue(ActionRequest actionRequest) {
case ARTICLE_DELETE: {
canTolerateNotFound = true;

if(getWallabagServiceWrapper().deleteArticle(articleID) == null) {
if(!getWallabagServiceWrapper().deleteArticle(articleID)) {
itemResult = new ActionResult(ActionResult.ErrorType.NOT_FOUND);
}
break;
Expand Down

0 comments on commit 18cbd69

Please sign in to comment.