tdlib / td

Cross-platform library for building Telegram clients
https://core.telegram.org/tdlib
Boost Software License 1.0
7.11k stars 1.44k forks source link

db.sqlite keeps growing forever.. up to 18 Gig! #2893

Closed jpage4500 closed 5 months ago

jpage4500 commented 5 months ago

This isn't a new issue AFAIK -- I commented on this one a while back: https://github.com/tdlib/td/issues/62

I wrote a test Android app using TDLIB which isn't much more than a simple Telegram client. I had kind of forgotten about it until my test device was running low on space and found out this was the culprit.

sargo:/data/data/com.test.app/files/telegram # ls -al
...
-rw-------  1 u0_a235 u0_a235 18727751680 2024-05-21 10:42 db.sqlite
-rw-------  1 u0_a235 u0_a235      229376 2024-05-21 10:42 db.sqlite-shm
-rw-------  1 u0_a235 u0_a235  2529132072 2024-05-21 10:42 db.sqlite-wal
...

Is there some way to clean this periodically? I imagine it's just accumulating every message for every channel I'm subscribed to and never removing them. I don't see a TDLIB function to do this. I do see OptimizeStorage but that appears to be for the attachments it's downloading and not related to the database

levlam commented 5 months ago

If you don't have secret chats, and don't store important data in chat.client_data, then you can just delete the db.sqlite file when the TDLib instance is closed.

levlam commented 5 months ago

You can also disable all databases in setTdlibParameters, in which case the database will be deleted and wouldn't be used anymore.

jpage4500 commented 2 months ago

I keep running into this issue and it's a little odd that it's not marked as a bug to me.. either:

a) use a database but it'll grow and grow forever until you run out of space b) don't use a database c) delete the database yourself, possibly losing any secret/private chats?

Why not just mark it as a bug if/until someone's willing to actually fix it?

@levlam

levlam commented 2 months ago

@jpage4500 See https://github.com/tdlib/td/issues/62.