-
Notifications
You must be signed in to change notification settings - Fork 386
Description
Describe the bug
Description written with a touch of AI assistance, because I've given too much of my time on this already (the usual case of the sunk-cost fallacy 😉)
A user on Discord encountered this issue (see conversation).
When a file is initially uploaded with encryption enabled and then subsequently overwritten by a file of the same name with encryption disabled, the file becomes inaccessible. Attempts to download or view the file via rclone or the Teldrive web UI result in errors (e.g., unexpected EOF in rclone, indefinite loading in UI).
The core issue appears to be a mismatch in how Teldrive handles the file's metadata versus its actual state in Telegram. After the overwrite with an unencrypted version:
- The
encryptedflag in theteldrive.filesdatabase table for the file incorrectly remainstrue. - The
saltinformation is removed from thepartsJSONB column for that file record. - The actual file stored in the Telegram channel is the new, unencrypted version.
Teldrive panics with an "integer divide by zero" error within its file reading/streaming logic (calculatePartByteRanges). This is almost certainly due to the inconsistent file metadata in its database (marked as encrypted but with attributes of an unencrypted file after the overwrite), causing calculations for reading file parts to fail catastrophically. This panic is why rclone receives an "unexpected EOF" (as the connection is abruptly closed) and why the Teldrive UI hangs.
Please see logs below.
Additional observations by the user on Discord:
- Running
teldrive check --config=/path/to/config.toml --cleanafter these steps can mark the problematic file aspending_deletionin the database. - The issue does not occur if a file originally uploaded unencrypted is then overwritten by an encrypted version. That scenario works as expected.
Repoduction
- upload
test.txtwith encryption enabled in teldrive and rclone - download with rclone: no issues
- disable encryption in teldrive ui, restart teldrive server, download with rclone, and check db
- replace
text.txtwith encryption disabled in teldrive ui but not rclone (--teldrive-encrypt-files=true): no issues - replace
test.txtwith encryption disabled in both teldrive ui and rclone (--teldrive-encrypt-files=false): cannot read/download the file - check teldrive log
teldrive.files.encryptedflag in db is still set totrue, even though the part is not salted- flipping
teldrive.files.encrypteddoes not fix the issue, nor does--teldrive-encrypt-files=true - source file (telegram channel) is not encrypted
- download works again only after teldrive server is restarted once again
Expected behavior
- upload
test.txtwith encryption enabled in teldrive and rclone - disable encryption in teldrive ui, restart teldrive server
- replace
test.txtwith encryption disabled in both teldrive ui and rclone (--teldrive-encrypt-files=false): NO ISSUE - check teldrive log: NO ISSUE
teldrive.files.encryptedflag in db is set tofalse- source file (telegram channel) is not encrypted
- download works as normal
Step 3-5.
Version
| application | version |
|---|---|
| teldrive | 1.6.17 |
| rclone | 1.69.2 |
Which Platform are you using?
Linux
Additional context
In-depth steps:
1. upload test.txt with encryption enabled in teldrive and rclone: no issues
$ echo $RANDOM >/tmp/test.txt && rclone -vvv -PM copy /tmp/test.txt teldrive-testbench: --teldrive-encrypt-files=true
2025/06/16 21:30:06 DEBUG : rclone: Version "v1.69.2" starting with parameters ["rclone" "-vvv" "-PM" "copy" "/tmp/test.txt" "teldrive-testbench:" "--teldrive-encrypt-files=true"]
2025/06/16 21:30:06 DEBUG : Creating backend with remote "/tmp/test.txt"
2025/06/16 21:30:06 DEBUG : Using config file from "/home/iwconfig/.config/rclone/rclone.conf"
2025/06/16 21:30:06 DEBUG : fs cache: renaming child cache item "/tmp/test.txt" to be canonical for parent "/tmp"
2025/06/16 21:30:06 DEBUG : Creating backend with remote "teldrive-testbench:"
2025/06/16 21:30:06 DEBUG : teldrive-testbench: detected overridden config - adding "{EFBd1}" suffix to name
2025/06/16 21:30:06 DEBUG : Saving config "access_token" in section "teldrive-testbench" of the config file
2025/06/16 21:30:06 DEBUG : Keeping previous permissions for config file: -rw-rw-r--
2025/06/16 21:30:06 DEBUG : fs cache: renaming cache item "teldrive-testbench:" to be canonical "teldrive-testbench{EFBd1}:"
2025/06/16 21:30:06 DEBUG : test.txt: Need to transfer - File not found at Destination
2025/06/16 21:30:07 INFO : test.txt: Copied (new)
Transferred: 6 B / 6 B, 100%, 0 B/s, ETA -
Transferred: 1 / 1, 100%
Elapsed time: 0.6s
2025/06/16 21:30:07 INFO :
Transferred: 6 B / 6 B, 100%, 0 B/s, ETA -
Transferred: 1 / 1, 100%
Elapsed time: 0.6s
2025/06/16 21:30:07 DEBUG : 7 go routines active2. download with rclone: no issues
$ m -fv /tmp/test.txt && rclone -vvv -PM copy teldrive-testbench:/test.txt /tmp/ --teldrive-encrypt-files=true; head -v /tmp/test.txt
removed '/tmp/test.txt'
2025/06/16 21:33:47 DEBUG : rclone: Version "v1.69.2" starting with parameters ["rclone" "-vvv" "-PM" "copy" "teldrive-testbench:/test.txt" "/tmp/" "--teldrive-encrypt-files=true"]
2025/06/16 21:33:47 DEBUG : Creating backend with remote "teldrive-testbench:/test.txt"
2025/06/16 21:33:47 DEBUG : Using config file from "/home/iwconfig/.config/rclone/rclone.conf"
2025/06/16 21:33:47 DEBUG : teldrive-testbench: detected overridden config - adding "{EFBd1}" suffix to name
2025/06/16 21:33:47 DEBUG : Saving config "access_token" in section "teldrive-testbench" of the config file
2025/06/16 21:33:47 DEBUG : Keeping previous permissions for config file: -rw-rw-r--
2025/06/16 21:33:47 DEBUG : fs cache: renaming child cache item "teldrive-testbench:/test.txt" to be canonical for parent "teldrive-testbench{EFBd1}:"
2025/06/16 21:33:47 DEBUG : Creating backend with remote "/tmp/"
2025/06/16 21:33:47 DEBUG : fs cache: renaming cache item "/tmp/" to be canonical "/tmp"
2025/06/16 21:33:47 DEBUG : test.txt: Need to transfer - File not found at Destination
2025/06/16 21:33:47 DEBUG : test.txt.4cc8d11f.partial: renamed to: test.txt
2025/06/16 21:33:47 INFO : test.txt: Copied (new)
Transferred: 6 B / 6 B, 100%, 0 B/s, ETA -
Transferred: 1 / 1, 100%
Elapsed time: 0.3s
2025/06/16 21:33:47 INFO :
Transferred: 6 B / 6 B, 100%, 0 B/s, ETA -
Transferred: 1 / 1, 100%
Elapsed time: 0.3s
2025/06/16 21:33:47 DEBUG : 7 go routines active
==> /tmp/test.txt <==
188083. disable encryption in teldrive ui, restart teldrive, download with rclone, and check db: no issues
select name,encrypted,parts from teldrive.files where type = 'file';-[ RECORD 1 ]-------------------------------------------------------------------
name | test.txt
encrypted | t
parts | [{"id": 24, "salt": "Hv0RLnVr6OfQiuRGs5fnY4QM55fVkBM4opIjKhVcq-w="}]
4. replace text.txt with encryption disabled in teldrive ui but not rclone (--teldrive-encrypt-files=true): no issues
$ echo $RANDOM >/tmp/test.txt && rclone -vvv -PM copy /tmp/test.txt teldrive-testbench: --teldrive-encrypt-files=true
2025/06/16 21:52:52 DEBUG : rclone: Version "v1.69.2" starting with parameters ["rclone" "-vvv" "-PM" "copy" "/tmp/test.txt" "teldrive-testbench:" "--teldrive-encrypt-files=true"]
2025/06/16 21:52:52 DEBUG : Creating backend with remote "/tmp/test.txt"
2025/06/16 21:52:52 DEBUG : Using config file from "/home/iwconfig/.config/rclone/rclone.conf"
2025/06/16 21:52:52 DEBUG : fs cache: renaming child cache item "/tmp/test.txt" to be canonical for parent "/tmp"
2025/06/16 21:52:52 DEBUG : Creating backend with remote "teldrive-testbench:"
2025/06/16 21:52:52 DEBUG : teldrive-testbench: detected overridden config - adding "{EFBd1}" suffix to name
2025/06/16 21:52:52 DEBUG : Saving config "access_token" in section "teldrive-testbench" of the config file
2025/06/16 21:52:52 DEBUG : Keeping previous permissions for config file: -rw-rw-r--
2025/06/16 21:52:52 DEBUG : fs cache: renaming cache item "teldrive-testbench:" to be canonical "teldrive-testbench{EFBd1}:"
2025/06/16 21:52:52 DEBUG : test.txt: Modification times differ by -22m46.684662005s: 2025-06-16 21:52:52.684662005 +0200 CEST, 2025-06-16 19:30:06 +0000 UTC
2025/06/16 21:52:53 INFO : test.txt: Copied (replaced existing)
Transferred: 6 B / 6 B, 100%, 0 B/s, ETA -
Transferred: 1 / 1, 100%
Elapsed time: 0.8s
2025/06/16 21:52:53 INFO :
Transferred: 6 B / 6 B, 100%, 0 B/s, ETA -
Transferred: 1 / 1, 100%
Elapsed time: 0.8s
2025/06/16 21:52:53 DEBUG : 6 go routines active
$ rm -fv /tmp/test.txt && rclone -vvv -PM copy teldrive-testbench:/test.txt /tmp/ --teldrive-encrypt-files=false; head -v /tmp/test.txt
removed '/tmp/test.txt'
2025/06/16 21:52:56 DEBUG : rclone: Version "v1.69.2" starting with parameters ["rclone" "-vvv" "-PM" "copy" "teldrive-testbench:/test.txt" "/tmp/" "--teldrive-encrypt-files=false"]
2025/06/16 21:52:56 DEBUG : Creating backend with remote "teldrive-testbench:/test.txt"
2025/06/16 21:52:56 DEBUG : Using config file from "/home/iwconfig/.config/rclone/rclone.conf"
2025/06/16 21:52:56 DEBUG : Saving config "access_token" in section "teldrive-testbench" of the config file
2025/06/16 21:52:56 DEBUG : Keeping previous permissions for config file: -rw-rw-r--
2025/06/16 21:52:56 DEBUG : fs cache: renaming child cache item "teldrive-testbench:/test.txt" to be canonical for parent "teldrive-testbench:"
2025/06/16 21:52:56 DEBUG : Creating backend with remote "/tmp/"
2025/06/16 21:52:56 DEBUG : fs cache: renaming cache item "/tmp/" to be canonical "/tmp"
2025/06/16 21:52:56 DEBUG : test.txt: Need to transfer - File not found at Destination
2025/06/16 21:52:57 DEBUG : test.txt.a726c5d2.partial: renamed to: test.txt
2025/06/16 21:52:57 INFO : test.txt: Copied (new)
Transferred: 6 B / 6 B, 100%, 0 B/s, ETA -
Transferred: 1 / 1, 100%
Elapsed time: 0.4s
2025/06/16 21:52:57 INFO :
Transferred: 6 B / 6 B, 100%, 0 B/s, ETA -
Transferred: 1 / 1, 100%
Elapsed time: 0.4s
2025/06/16 21:52:57 DEBUG : 7 go routines active
==> /tmp/test.txt <==
22054
5. replace test.txt with encryption disabled in both teldrive ui and rclone (--teldrive-encrypt-files=false): cannot read/download the file
$ echo $RANDOM >/tmp/test.txt && rclone -vvv -PM copy /tmp/test.txt teldrive-testbench: --teldrive-encrypt-files=false
2025/06/16 21:55:30 DEBUG : rclone: Version "v1.69.2" starting with parameters ["rclone" "-vvv" "-PM" "copy" "/tmp/test.txt" "teldrive-testbench:" "--teldrive-encrypt-files=false"]
2025/06/16 21:55:30 DEBUG : Creating backend with remote "/tmp/test.txt"
2025/06/16 21:55:30 DEBUG : Using config file from "/home/iwconfig/.config/rclone/rclone.conf"
2025/06/16 21:55:30 DEBUG : fs cache: renaming child cache item "/tmp/test.txt" to be canonical for parent "/tmp"
2025/06/16 21:55:30 DEBUG : Creating backend with remote "teldrive-testbench:"
2025/06/16 21:55:30 DEBUG : Saving config "access_token" in section "teldrive-testbench" of the config file
2025/06/16 21:55:30 DEBUG : Keeping previous permissions for config file: -rw-rw-r--
2025/06/16 21:55:30 DEBUG : test.txt: Sizes differ (src 5 vs dst 6)
2025/06/16 21:55:31 INFO : test.txt: Copied (replaced existing)
Transferred: 5 B / 5 B, 100%, 5 B/s, ETA 0s
Transferred: 1 / 1, 100%
Elapsed time: 1.1s
2025/06/16 21:55:31 INFO :
Transferred: 5 B / 5 B, 100%, 5 B/s, ETA 0s
Transferred: 1 / 1, 100%
Elapsed time: 1.1s
2025/06/16 21:55:31 DEBUG : 6 go routines active
$ cat /tmp/test.txt
4787
$ rm -fv /tmp/test.txt && rclone -vvv -PM copy teldrive-testbench:/test.txt /tmp/ --teldrive-encrypt-files=false; head -v /tmp/test.txt
removed '/tmp/test.txt'
2025/06/16 21:55:37 DEBUG : rclone: Version "v1.69.2" starting with parameters ["rclone" "-vvv" "-PM" "copy" "teldrive-testbench:/test.txt" "/tmp/" "--teldrive-encrypt-files=false"]
2025/06/16 21:55:37 DEBUG : Creating backend with remote "teldrive-testbench:/test.txt"
2025/06/16 21:55:37 DEBUG : Using config file from "/home/iwconfig/.config/rclone/rclone.conf"
2025/06/16 21:55:37 DEBUG : Saving config "access_token" in section "teldrive-testbench" of the config file
2025/06/16 21:55:37 DEBUG : Keeping previous permissions for config file: -rw-rw-r--
2025/06/16 21:55:37 DEBUG : fs cache: renaming child cache item "teldrive-testbench:/test.txt" to be canonical for parent "teldrive-testbench:"
2025/06/16 21:55:37 DEBUG : Creating backend with remote "/tmp/"
2025/06/16 21:55:37 DEBUG : fs cache: renaming cache item "/tmp/" to be canonical "/tmp"
2025/06/16 21:55:37 DEBUG : test.txt: Need to transfer - File not found at Destination
2025/06/16 21:55:37 DEBUG : test.txt: Reopening on read failure after offset 0 bytes: retry 1/10: unexpected EOF
2025/06/16 21:55:37 DEBUG : test.txt: Reopening on read failure after offset 0 bytes: retry 2/10: unexpected EOF
2025/06/16 21:55:37 DEBUG : test.txt: Reopening on read failure after offset 0 bytes: retry 3/10: unexpected EOF
2025/06/16 21:55:38 DEBUG : test.txt: Reopening on read failure after offset 0 bytes: retry 4/10: unexpected EOF
2025/06/16 21:55:38 DEBUG : test.txt: Reopening on read failure after offset 0 bytes: retry 5/10: unexpected EOF
2025/06/16 21:55:38 DEBUG : test.txt: Reopening on read failure after offset 0 bytes: retry 6/10: unexpected EOF
2025/06/16 21:55:38 DEBUG : test.txt: Reopening on read failure after offset 0 bytes: retry 7/10: unexpected EOF
2025/06/16 21:55:38 DEBUG : test.txt: Reopening on read failure after offset 0 bytes: retry 8/10: unexpected EOF
2025/06/16 21:55:38 DEBUG : test.txt: Reopening on read failure after offset 0 bytes: retry 9/10: unexpected EOF
2025/06/16 21:55:38 DEBUG : test.txt: Reopening on read failure after offset 0 bytes: retry 10/10: unexpected EOF
2025/06/16 21:55:38 DEBUG : test.txt: Reopen failed after offset 0 bytes read: failed to reopen: too many retries
2025/06/16 21:55:38 NOTICE: test.txt.66924a40.partial: Removing partially written file on error: unexpected EOF
2025/06/16 21:55:38 DEBUG : test.txt: Received error: unexpected EOF - low level retry 0/10
2025/06/16 21:55:39 DEBUG : test.txt: Reopening on read failure after offset 0 bytes: retry 1/10: unexpected EOF
2025/06/16 21:55:39 DEBUG : test.txt: Reopening on read failure after offset 0 bytes: retry 2/10: unexpected EOF
2025/06/16 21:55:39 DEBUG : test.txt: Reopening on read failure after offset 0 bytes: retry 3/10: unexpected EOF
2025/06/16 21:55:39 DEBUG : test.txt: Reopening on read failure after offset 0 bytes: retry 4/10: unexpected EOF
2025/06/16 21:55:39 DEBUG : test.txt: Reopening on read failure after offset 0 bytes: retry 5/10: unexpected EOF
2025/06/16 21:55:39 DEBUG : test.txt: Reopening on read failure after offset 0 bytes: retry 6/10: unexpected EOF
2025/06/16 21:55:40 DEBUG : test.txt: Reopening on read failure after offset 0 bytes: retry 7/10: unexpected EOF
2025/06/16 21:55:40 DEBUG : test.txt: Reopening on read failure after offset 0 bytes: retry 8/10: unexpected EOF
2025/06/16 21:55:40 DEBUG : test.txt: Reopening on read failure after offset 0 bytes: retry 9/10: unexpected EOF
2025/06/16 21:55:40 DEBUG : test.txt: Reopening on read failure after offset 0 bytes: retry 10/10: unexpected EOF
2025/06/16 21:55:40 DEBUG : test.txt: Reopen failed after offset 0 bytes read: failed to reopen: too many retries
2025/06/16 21:55:40 NOTICE: test.txt.66924a40.partial: Removing partially written file on error: unexpected EOF
2025/06/16 21:55:40 DEBUG : test.txt: Received error: unexpected EOF - low level retry 1/10
2025/06/16 21:55:40 DEBUG : test.txt: Reopening on read failure after offset 0 bytes: retry 1/10: unexpected EOF
2025/06/16 21:55:40 DEBUG : test.txt: Reopening on read failure after offset 0 bytes: retry 2/10: unexpected EOF
2025/06/16 21:55:41 DEBUG : test.txt: Reopening on read failure after offset 0 bytes: retry 3/10: unexpected EOF
2025/06/16 21:55:41 DEBUG : test.txt: Reopening on read failure after offset 0 bytes: retry 4/10: unexpected EOF
2025/06/16 21:55:41 DEBUG : test.txt: Reopening on read failure after offset 0 bytes: retry 5/10: unexpected EOF
2025/06/16 21:55:41 DEBUG : test.txt: Reopening on read failure after offset 0 bytes: retry 6/10: unexpected EOF
2025/06/16 21:55:41 DEBUG : test.txt: Reopening on read failure after offset 0 bytes: retry 7/10: unexpected EOF
2025/06/16 21:55:41 DEBUG : test.txt: Reopening on read failure after offset 0 bytes: retry 8/10: unexpected EOF
2025/06/16 21:55:42 DEBUG : test.txt: Reopening on read failure after offset 0 bytes: retry 9/10: unexpected EOF
2025/06/16 21:55:42 DEBUG : test.txt: Reopening on read failure after offset 0 bytes: retry 10/10: unexpected EOF
2025/06/16 21:55:42 DEBUG : test.txt: Reopen failed after offset 0 bytes read: failed to reopen: too many retries
2025/06/16 21:55:42 NOTICE: test.txt.66924a40.partial: Removing partially written file on error: unexpected EOF
2025/06/16 21:55:42 DEBUG : test.txt: Received error: unexpected EOF - low level retry 2/10
2025/06/16 21:55:42 DEBUG : test.txt: Reopening on read failure after offset 0 bytes: retry 1/10: unexpected EOF
2025/06/16 21:55:42 DEBUG : test.txt: Reopening on read failure after offset 0 bytes: retry 2/10: unexpected EOF
2025/06/16 21:55:42 DEBUG : test.txt: Reopening on read failure after offset 0 bytes: retry 3/10: unexpected EOF
2025/06/16 21:55:43 DEBUG : test.txt: Reopening on read failure after offset 0 bytes: retry 4/10: unexpected EOF
2025/06/16 21:55:43 DEBUG : test.txt: Reopening on read failure after offset 0 bytes: retry 5/10: unexpected EOF
2025/06/16 21:55:43 DEBUG : test.txt: Reopening on read failure after offset 0 bytes: retry 6/10: unexpected EOF
2025/06/16 21:55:43 DEBUG : test.txt: Reopening on read failure after offset 0 bytes: retry 7/10: unexpected EOF
2025/06/16 21:55:43 DEBUG : test.txt: Reopening on read failure after offset 0 bytes: retry 8/10: unexpected EOF
2025/06/16 21:55:43 DEBUG : test.txt: Reopening on read failure after offset 0 bytes: retry 9/10: unexpected EOF
2025/06/16 21:55:44 DEBUG : test.txt: Reopening on read failure after offset 0 bytes: retry 10/10: unexpected EOF
2025/06/16 21:55:44 DEBUG : test.txt: Reopen failed after offset 0 bytes read: failed to reopen: too many retries
2025/06/16 21:55:44 NOTICE: test.txt.66924a40.partial: Removing partially written file on error: unexpected EOF
2025/06/16 21:55:44 DEBUG : test.txt: Received error: unexpected EOF - low level retry 3/10
2025/06/16 21:55:44 DEBUG : test.txt: Reopening on read failure after offset 0 bytes: retry 1/10: unexpected EOF
2025/06/16 21:55:44 DEBUG : test.txt: Reopening on read failure after offset 0 bytes: retry 2/10: unexpected EOF
2025/06/16 21:55:44 DEBUG : test.txt: Reopening on read failure after offset 0 bytes: retry 3/10: unexpected EOF
2025/06/16 21:55:44 DEBUG : test.txt: Reopening on read failure after offset 0 bytes: retry 4/10: unexpected EOF
2025/06/16 21:55:44 INFO : Signal received: interrupt
2025/06/16 21:55:44 INFO : test.txt.66924a40.partial: Removing failed copy
2025/06/16 21:55:44 INFO : Exiting...
Transferred: 0 B / 5 B, 0%, 0 B/s, ETA -
Transferred: 0 / 1, 0%
Elapsed time: 7.6s
Transferring:
* test.txt: 0% /5, 0/s, -6. teldrive log: panics with an "integer divide by zero"
teldrive | panic: recovered from errgroup.Group: runtime error: integer divide by zero
teldrive | goroutine 2014 [running]:
teldrive | runtime/debug.Stack()
teldrive | runtime/debug/stack.go:26 +0x5e
teldrive | golang.org/x/sync/errgroup.(*Group).add.func1.1()
teldrive | golang.org/x/sync@v0.15.0/errgroup/errgroup.go:117 +0x1ff
teldrive | panic({0x1e31b20?, 0x3c054b0?})
teldrive | runtime/panic.go:792 +0x132
teldrive | github.com/tgdrive/teldrive/internal/reader.calculatePartByteRanges(...)
teldrive | github.com/tgdrive/teldrive/internal/reader/reader.go:36
teldrive | github.com/tgdrive/teldrive/internal/reader.NewLinearReader({0x297a310?, 0xc0015220c0?}, 0xff?, {0x2977960?, 0xc0003c6030?}, 0x3c2c4a0?, {0xc0014e0000?, 0x0?, 0x22032b4?}, 0x0, ...)
teldrive | github.com/tgdrive/teldrive/internal/reader/reader.go:71 +0x446
teldrive | github.com/tgdrive/teldrive/pkg/services.(*extendedService).FilesStream.func2()
teldrive | github.com/tgdrive/teldrive/pkg/services/file.go:846 +0x135
teldrive | github.com/tgdrive/teldrive/pkg/services.(*extendedService).FilesStream.func3({0x21fbf5a?, 0x22032b4?})
teldrive | github.com/tgdrive/teldrive/pkg/services/file.go:863 +0x13
teldrive | github.com/tgdrive/teldrive/pkg/services.(*extendedService).FilesStream.RunWithAuth.func8({0x2979f20, 0xc001520230})
teldrive | github.com/tgdrive/teldrive/internal/tgc/run.go:40 +0x5a4
teldrive | github.com/gotd/td/telegram.(*Client).Run.func3({0x2979f20, 0xc001520230})
teldrive | github.com/gotd/td@v0.125.0/telegram/connect.go:173 +0xb4
teldrive | github.com/gotd/td/tdsync.(*CancellableGroup).Go.func1()
teldrive | github.com/gotd/td@v0.125.0/tdsync/cancel_group.go:48 +0x23
teldrive | golang.org/x/sync/errgroup.(*Group).add.func1()
teldrive | golang.org/x/sync@v0.15.0/errgroup/errgroup.go:128 +0x7e
teldrive | created by golang.org/x/sync/errgroup.(*Group).add in goroutine 2010
teldrive | golang.org/x/sync@v0.15.0/errgroup/errgroup.go:96 +0x76
teldrive |
teldrive |
teldrive | -> golang.org/x/sync/errgroup.(*Group).Wait
teldrive | -> golang.org/x/sync@v0.15.0/errgroup/errgroup.go:70
teldrive |
teldrive | github.com/gotd/td/tdsync.(*CancellableGroup).Wait
teldrive | github.com/gotd/td@v0.125.0/tdsync/cancel_group.go:62
teldrive | github.com/gotd/td/telegram.(*Client).Run
teldrive | github.com/gotd/td@v0.125.0/telegram/connect.go:183
teldrive | github.com/tgdrive/teldrive/internal/tgc.RunWithAuth
teldrive | github.com/tgdrive/teldrive/internal/tgc/run.go:13
teldrive | github.com/tgdrive/teldrive/pkg/services.(*extendedService).FilesStream
teldrive | github.com/tgdrive/teldrive/pkg/services/file.go:862
teldrive | github.com/tgdrive/teldrive/pkg/services.(*extendedMiddleware).ServeHTTP
teldrive | github.com/tgdrive/teldrive/pkg/services/api.go:132
teldrive | github.com/tgdrive/teldrive/cmd.setupServer.StripPrefix.func3
teldrive | net/http/server.go:2356
teldrive | net/http.HandlerFunc.ServeHTTP
teldrive | net/http/server.go:2294
teldrive | github.com/go-chi/chi/v5.(*Mux).Mount.func1
teldrive | github.com/go-chi/chi/v5@v5.2.1/mux.go:327
teldrive | net/http.HandlerFunc.ServeHTTP
teldrive | net/http/server.go:2294
teldrive | github.com/go-chi/chi/v5.(*Mux).routeHTTP
teldrive | github.com/go-chi/chi/v5@v5.2.1/mux.go:480
teldrive | net/http.HandlerFunc.ServeHTTP
teldrive | net/http/server.go:2294
teldrive | github.com/tgdrive/teldrive/internal/appcontext.Middleware.func1
teldrive | github.com/tgdrive/teldrive/internal/appcontext/appcontext.go:30
teldrive | net/http.HandlerFunc.ServeHTTP
teldrive | net/http/server.go:2294
teldrive | github.com/tgdrive/teldrive/cmd.setupServer.ChizapWithConfig.func2.1
teldrive | github.com/tgdrive/teldrive/internal/chizap/chizap.go:109
teldrive | net/http.HandlerFunc.ServeHTTP
teldrive | net/http/server.go:2294
teldrive | github.com/tgdrive/teldrive/cmd.setupServer.InjectLogger.func1.1
teldrive | github.com/tgdrive/teldrive/internal/middleware/middleware.go:20
teldrive | net/http.HandlerFunc.ServeHTTP
teldrive | net/http/server.go:2294
teldrive | github.com/go-chi/chi/v5/middleware.RealIP.func1
teldrive | github.com/go-chi/chi/v5@v5.2.1/middleware/realip.go:36
teldrive | net/http.HandlerFunc.ServeHTTP
teldrive | net/http/server.go:2294
teldrive | github.com/go-chi/cors.(*Cors).Handler-fm.(*Cors).Handler.func1
teldrive | github.com/go-chi/cors@v1.2.1/cors.go:228
teldrive | net/http.HandlerFunc.ServeHTTP
teldrive | net/http/server.go:2294
teldrive | github.com/go-chi/chi/v5/middleware.Recoverer.func1
teldrive | github.com/go-chi/chi/v5@v5.2.1/middleware/recoverer.go:45
teldrive | net/http.HandlerFunc.ServeHTTP
teldrive | net/http/server.go:2294
teldrive | github.com/go-chi/chi/v5.(*Mux).ServeHTTP
teldrive | github.com/go-chi/chi/v5@v5.2.1/mux.go:90
teldrive | net/http.serverHandler.ServeHTTP
teldrive | net/http/server.go:3301
teldrive | net/http.(*conn).serve
teldrive | net/http/server.go:2102
teldrive | created by net/http.(*Server).Serve in goroutine 65
teldrive | net/http/server.go:3454
teldrive |
teldrive | 2025/06/16 21:59:55 http: superfluous response.WriteHeader call from github.com/go-chi/chi/v5/middleware.Recoverer.func1.1 (recoverer.go:40)
7. teldrive.files.encrypted flag in db is still set to true, even though the part is not salted
postgres=# select name,encrypted,parts from teldrive.files where type = 'file';
-[ RECORD 1 ]-----------
name | test.txt
encrypted | t
parts | [{"id": 26}]
8. flipping teldrive.files.encrypted does not fix the issue, nor does --teldrive-encrypt-files=true
postgres=# update teldrive.files set encrypted = false where name = 'test.txt';
UPDATE 1
postgres=# select name,encrypted,parts from files where type = 'file';
-[ RECORD 1 ]-----------
name | test.txt
encrypted | f
parts | [{"id": 26}]$ rm -fv /tmp/test.txt && rclone -vvv -PM copy teldrive-testbench:/test.txt /tmp/ --teldrive-encrypt-files=false
2025/06/16 22:12:38 DEBUG : rclone: Version "v1.69.2" starting with parameters ["rclone" "-vvv" "-PM" "copy" "teldrive-testbench:/test.txt" "/tmp/" "--teldrive-encrypt-files=false"]
2025/06/16 22:12:38 DEBUG : Creating backend with remote "teldrive-testbench:/test.txt"
2025/06/16 22:12:38 DEBUG : Using config file from "/home/iwconfig/.config/rclone/rclone.conf"
2025/06/16 22:12:38 DEBUG : Saving config "access_token" in section "teldrive-testbench" of the config file
2025/06/16 22:12:38 DEBUG : Keeping previous permissions for config file: -rw-rw-r--
2025/06/16 22:12:38 DEBUG : fs cache: renaming child cache item "teldrive-testbench:/test.txt" to be canonical for parent "teldrive-testbench:"
2025/06/16 22:12:38 DEBUG : Creating backend with remote "/tmp/"
2025/06/16 22:12:38 DEBUG : fs cache: renaming cache item "/tmp/" to be canonical "/tmp"
2025/06/16 22:12:38 DEBUG : test.txt: Need to transfer - File not found at Destination
2025/06/16 22:12:39 DEBUG : test.txt: Reopening on read failure after offset 0 bytes: retry 1/10: unexpected EOF
2025/06/16 22:12:39 DEBUG : test.txt: Reopening on read failure after offset 0 bytes: retry 2/10: unexpected EOF
2025/06/16 22:12:39 DEBUG : test.txt: Reopening on read failure after offset 0 bytes: retry 3/10: unexpected EOF
2025/06/16 22:12:39 DEBUG : test.txt: Reopening on read failure after offset 0 bytes: retry 4/10: unexpected EOF
2025/06/16 22:12:39 DEBUG : test.txt: Reopening on read failure after offset 0 bytes: retry 5/10: unexpected EOF
2025/06/16 22:12:40 DEBUG : test.txt: Reopening on read failure after offset 0 bytes: retry 6/10: unexpected EOF
2025/06/16 22:12:40 DEBUG : test.txt: Reopening on read failure after offset 0 bytes: retry 7/10: unexpected EOF
2025/06/16 22:12:40 DEBUG : test.txt: Reopening on read failure after offset 0 bytes: retry 8/10: unexpected EOF
2025/06/16 22:12:41 DEBUG : test.txt: Reopening on read failure after offset 0 bytes: retry 9/10: unexpected EOF
2025/06/16 22:12:41 DEBUG : test.txt: Reopening on read failure after offset 0 bytes: retry 10/10: unexpected EOF
2025/06/16 22:12:41 DEBUG : test.txt: Reopen failed after offset 0 bytes read: failed to reopen: too many retries
2025/06/16 22:12:41 NOTICE: test.txt.66924a40.partial: Removing partially written file on error: unexpected EOF
2025/06/16 22:12:41 DEBUG : test.txt: Received error: unexpected EOF - low level retry 0/10
2025/06/16 22:12:41 DEBUG : test.txt: Reopening on read failure after offset 0 bytes: retry 1/10: unexpected EOF9. source file (telegram channel) is not encrypted: no issues
$ cat 5b765146888a70546e86b57fb4388232
478710. downloading only works again after teldrive server has been restarted once again
root@dev:~/teldrive-testbench# docker compose restart teldrive-server
[+] Restarting 1/1
✔ Container teldrive Started $ rm -fv /tmp/test.txt && rclone -vvv -PM copy teldrive-testbench:/test.txt /tmp/ --teldrive-encrypt-files=true; head -v /tmp/test.txt
2025/06/16 22:55:23 DEBUG : rclone: Version "v1.69.2" starting with parameters ["rclone" "-vvv" "-PM" "copy" "teldrive-testbench:/test.txt" "/tmp/" "--teldrive-encrypt-files=true"]
2025/06/16 22:55:23 DEBUG : Creating backend with remote "teldrive-testbench:/test.txt"
2025/06/16 22:55:23 DEBUG : Using config file from "/home/iwconfig/.config/rclone/rclone.conf"
2025/06/16 22:55:23 DEBUG : teldrive-testbench: detected overridden config - adding "{EFBd1}" suffix to name
2025/06/16 22:55:23 DEBUG : Saving config "access_token" in section "teldrive-testbench" of the config file
2025/06/16 22:55:23 DEBUG : Keeping previous permissions for config file: -rw-rw-r--
2025/06/16 22:55:23 DEBUG : fs cache: renaming child cache item "teldrive-testbench:/test.txt" to be canonical for parent "teldrive-testbench{EFBd1}:"
2025/06/16 22:55:23 DEBUG : Creating backend with remote "/tmp/"
2025/06/16 22:55:23 DEBUG : fs cache: renaming cache item "/tmp/" to be canonical "/tmp"
2025/06/16 22:55:23 DEBUG : test.txt: Need to transfer - File not found at Destination
2025/06/16 22:55:23 DEBUG : test.txt.66924a40.partial: renamed to: test.txt
2025/06/16 22:55:23 INFO : test.txt: Copied (new)
Transferred: 5 B / 5 B, 100%, 0 B/s, ETA -
Transferred: 1 / 1, 100%
Elapsed time: 0.4s
2025/06/16 22:55:23 INFO :
Transferred: 5 B / 5 B, 100%, 0 B/s, ETA -
Transferred: 1 / 1, 100%
Elapsed time: 0.4s
2025/06/16 22:55:23 DEBUG : 7 go routines active
==> /tmp/test.txt <==
4787