Added setting to delete old attachments

This commit is contained in:
M66B
2020-04-14 19:45:56 +02:00
parent 0656590fd0
commit 358f7214e1
5 changed files with 58 additions and 4 deletions

View File

@@ -97,6 +97,17 @@ public interface DaoAttachment {
" WHERE id = :id")
void setCid(long id, String cid);
@Query("UPDATE attachment" +
" SET available = 0" +
" WHERE EXISTS" +
" (SELECT * FROM attachment a" +
" JOIN message ON message.id = a.message" +
" JOIN folder ON folder.id = message.folder" +
" WHERE a.id = attachment.id" +
" AND a.available" +
" AND message.stored < :now - folder.sync_days * 24 * 3600 * 1000)")
int purge(long now);
@Insert
long insertAttachment(EntityAttachment attachment);