teldrive: [Bug]: Orphaned Telegram channel messages persist despite successful check --clean

Describe the bug

After restoring a month-old Postgres database for Teldrive, I noticed several orphaned files still present in the associated Telegram channel. To clean these up, I ran the check command using:

docker compose run --rm --entrypoint /teldrive teldrive check --clean --config /config.toml

This command completed successfully without any errors in the terminal. However, the orphaned files in the Telegram channel were not deleted. While reviewing the Teldrive logs, I occasionally encountered the following error:

failed to delete messages  {"error": "callback: rpcDoRequest: rpc error code 400: CHANNEL_INVALID", ...}

Interestingly, uploading and then deleting a new file through the Teldrive WebUI works perfectly, the file gets deleted from both Teldrive and the Telegram channel. This suggests the issue only affects older/orphaned files after database restoration.

Repoduction

  1. Restore an older Postgres backup for Teldrive (in this case, one month old).
  2. Observe that several orphaned files still exist in the linked Telegram channel.
  3. Run the following cleanup command from the directory containing the Docker Compose file:
docker compose run --rm --entrypoint /teldrive teldrive check --clean --config /config.toml
  1. Wait for the process to complete (no error output is shown).
  2. Check the Telegram channel, orphaned files remain undeleted.
  3. Review Teldrive logs, intermittently shows CHANNEL_INVALID error during deletion attempts.

Expected behavior

The teldrive check --clean command should identify and delete orphaned files from the Telegram channel especially after restoring an older database. All messages/files no longer tracked in the database should be properly removed from the channel. The CHANNEL_INVALID error should not occur during this cleanup if the channel is configured correctly and accessible.

Version

v1.6.17

Which Platform are you using?

docker (Linux)

About this issue

Most upvoted comments

It didn’t occur to me at the time that I could simply skip Teldrive’s orphan check altogether and delete the files manually,

Yes, but that’s not what i meant. Of course you can do that, but if you want to have this bug in Teldrive fixed before doing anything (which you said you were hoping for), then the script you linked to should of course not be used. It is thus irrelevant unless it is determined that this bug will never be fixed, and I doubt that it will.

I mean, you give off mixed signals, because initially you did imply that you wanted to use the script by saying

However, I’m a bit hesitant to use it now, as it may not have been updated to remain compatible with recent upstream changes in Teldrive.

and I only say this because you countered my comment about using the script, even though you were the one who brought it up, that’s all.

Anyway, yeah, I’ll perhaps look more into what the issue might be later, maybe. If i have the time and feel up to it.