Open scus1 opened 9 years ago
You're right, the app doesn't delete any articles. Do you know how long the server keeps an article ?
The configuration says items_lifetime = 21
.
Thanks. I'll try to add this as soon as possible, unless you want to contribute ;-)
Unfortunately, I don't have the time to look deep into your code at the moment. However, I tried my best to give an usable approach:
diff --git a/app/src/main/java/fr/ydelouis/selfoss/model/ArticleDao.java b/app/src/main/java/fr/ydelouis/selfoss/model/ArticleDao.java
index 37fd852..08b1c6f 100644
--- a/app/src/main/java/fr/ydelouis/selfoss/model/ArticleDao.java
+++ b/app/src/main/java/fr/ydelouis/selfoss/model/ArticleDao.java
@@ -267,6 +267,18 @@ public class ArticleDao extends BaseDaoImpl<Article, Integer> {
}
}
+ public void deleteNotFavoriteOlderThan(long dateTime) {
+ try {
+ DeleteBuilder<Article, Integer> deleteBuilder = deleteBuilder();
+ deleteBuilder.where()
+ .eq(COLUMN_STARRED, false)
+ .and().lt(COLUMN_DATETIME, dateTime);
+ deleteBuilder.delete();
+ } catch (SQLException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
private void notifyCreation(Article article) {
broadcast(ACTION_CREATION, article);
}
diff --git a/app/src/main/java/fr/ydelouis/selfoss/sync/ArticleSync.java b/app/src/main/java/fr/ydelouis/selfoss/sync/ArticleSync.java
index 5acd123..1404d0f 100644
--- a/app/src/main/java/fr/ydelouis/selfoss/sync/ArticleSync.java
+++ b/app/src/main/java/fr/ydelouis/selfoss/sync/ArticleSync.java
@@ -12,6 +12,7 @@ import org.androidannotations.annotations.OrmLiteDao;
import org.androidannotations.annotations.RootContext;
import java.util.List;
+import java.util.Date;
import fr.ydelouis.selfoss.entity.Article;
import fr.ydelouis.selfoss.model.ArticleDao;
@@ -49,6 +50,8 @@ public class ArticleSync {
syncUnread();
syncFavorite();
}
+ // There are 1000 * 60 * 60 * 24 milliseconds in one day
+ articleDao.deleteNotFavoriteOlderThan(Date().getTime() - 1000 * 60 * 60 * 24 * 21);
sendSyncBroadcast();
}
I don't know whether it's possible to query the Restful API for items_lifetime
or the oldest unstarred article so I hard-coded the 21 days.
Maybe it would be nice to have a settings like items_lifetime = 21
also in the app, but I don't know enough about Android development for this...
Best regards, scus
The Android client doesn't seem to delete old (but unread) articles as the server does. I have, for example, about 3500 unread articles in the webinterface and about 20000 in the android client. This seems to be the reason why the reader gets slower every day...