# Media is not removed from the database \[only 24 hours after deletion\]

**URL:** <https://forum.delta.chat/t/media-is-not-removed-from-the-database-only-24-hours-after-deletion/5616>\
**Category:** Mutual Help\
**Tags:** solved, core, art\
**Created:** [August 4, 2026, 11:48pm UTC](https://forum.delta.chat/t/media-is-not-removed-from-the-database-only-24-hours-after-deletion/5616 "2026-08-04T23:48:58Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![tentipoteni](https://forum.delta.chat/letter_avatar_proxy/v4/letter/t/94ad74/32.png) [@tentipoteni](https://forum.delta.chat/u/tentipoteni)\
**Post date:** [August 4, 2026, 11:48pm UTC](https://forum.delta.chat/t/media-is-not-removed-from-the-database-only-24-hours-after-deletion/5616/1 "2026-08-04T23:48:58Z")

</div>

When I delete a message containing an attachment from a chat (either for everyone or just for me) I expect the attachment to also be deleted from the database. However, I was doing some tests with both the Android and Desktop version and the user databases got quickly massive, although I deleted the messages from the chats.  
It doesn’t make sense to still save the message attachments if they aren’t accessible to a regular user. It is not really hard to manually delete the messages from the Desktop version, but it is impossible to do so from the mobile app.

---

<div class="post-metadata">

**Author:** ![lk108](https://forum.delta.chat/user_avatar/forum.delta.chat/lk108/32/1668_2.png) [@lk108](https://forum.delta.chat/u/lk108)\
**Post date:** [August 5, 2026, 7:00am UTC](https://forum.delta.chat/t/media-is-not-removed-from-the-database-only-24-hours-after-deletion/5616/2 "2026-08-05T07:00:26Z")

</div>

I think the attachments are deleted, just not directly, but in periodic (EDIT: once daily I think) “housekeeping” runs.

---

<div class="post-metadata">

**Author:** ![ian](https://forum.delta.chat/user_avatar/forum.delta.chat/ian/32/3164_2.png) [@ian](https://forum.delta.chat/u/ian)\
**Post date:** [August 5, 2026, 8:46am UTC](https://forum.delta.chat/t/media-is-not-removed-from-the-database-only-24-hours-after-deletion/5616/3 "2026-08-05T08:46:46Z")

</div>

Yes. More specifically, it will periodically try to remove unused files, but not within the same 24 hour period.

> <https://github.com/chatmail/core/blob/main/src/scheduler.rs#L436>

```auto
    match ctx.get_config_i64(Config::LastHousekeeping).await {
        Ok(last_housekeeping_time) => {
            let next_housekeeping_time =
                last_housekeeping_time.saturating_add(constants::HOUSEKEEPING_PERIOD);
            if next_housekeeping_time <= time() {
                sql::housekeeping(ctx).await.log_err(ctx).ok();

```

> <https://github.com/chatmail/core/blob/main/src/constants.rs#L199>

```auto
/// Period between `sql::housekeeping()` runs.
pub(crate) const HOUSEKEEPING_PERIOD: i64 = 24 * 60 * 60;

```

> <https://github.com/chatmail/core/blob/main/src/sql.rs#L807>

```auto
    if let Err(err) = remove_unused_files(context).await {

```

---

<div class="post-metadata">

**Author:** ![tentipoteni](https://forum.delta.chat/letter_avatar_proxy/v4/letter/t/94ad74/32.png) [@tentipoteni](https://forum.delta.chat/u/tentipoteni)\
**Post date:** [August 5, 2026, 12:42pm UTC](https://forum.delta.chat/t/media-is-not-removed-from-the-database-only-24-hours-after-deletion/5616/4 "2026-08-05T12:42:43Z")

</div>

Ohhh, okay! My bad, then, for being an impatient 😅

Although it is not obvious for most people, I understand it’s not a big deal, and it makes more sense from a resource viewpoint.

Thanks!!

---

<div class="post-metadata">

**Author:** ![WofWca](https://forum.delta.chat/user_avatar/forum.delta.chat/wofwca/32/1702_2.png) [@WofWca](https://forum.delta.chat/u/WofWca)\
**Post date:** [August 6, 2026, 8:28am UTC](https://forum.delta.chat/t/media-is-not-removed-from-the-database-only-24-hours-after-deletion/5616/5 "2026-08-06T08:28:52Z")

</div>

Duplicate of [The attachment is not deleted from the local storage](https://support.delta.chat/t/the-attachment-is-not-deleted-from-the-local-storage/3479).

---

<div class="post-metadata">

**Author:** ![r10s](https://forum.delta.chat/user_avatar/forum.delta.chat/r10s/32/1513_2.png) [@r10s](https://forum.delta.chat/u/r10s)\
**Post date:** [October 6, 2026, 3:41pm UTC](https://forum.delta.chat/t/media-is-not-removed-from-the-database-only-24-hours-after-deletion/5616/6 "2026-10-06T15:41:03Z")

</div>


