Fix gokapi-cli download and add E2E download support#365
Fix gokapi-cli download and add E2E download support#365Forceu merged 4 commits intoForceu:masterfrom
Conversation
checkRequiredUploadParameter had no return true path for a valid download command. When --id was provided, execution fell through to the upload/Docker logic which returned false, triggering os.Exit(2) with no output. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Move HTTP request before file creation so no file is left behind on server errors (502, 404, etc.). Also clean up partial files on streaming errors and fix defer placement on os.Create. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
serveDecryptedFile unconditionally called encryption.DecryptReader even for non-encrypted files, causing crypto/aes: invalid key size 0 panic that crashed the entire process. Only decrypt when the file is actually encrypted, matching the existing behavior in Stream(). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Server: remove E2E download rejection from API and serve encrypted bytes without server-side decryption for E2E files. Add IsDecryptionAvailable guard to prevent server crash on encrypted files with missing master key. CLI: detect E2E files, retrieve per-file cipher from /api/e2e/get, restore the real filename, and decrypt in streaming using the E2E key. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Hi please state what percentage of the code was generated with AI |
|
Hi, thanks for the quick reply, and thanks for Gokapi! it's a great project 👍 The code changes were written with AI assistance (Claude), as reflected by the Co-Authored-By tag on each commit. I identified the bugs during real usage, directed the investigation and fixes, and tested everything manually on my setup (Docker + S3 + Nginx reverse proxy). The AI helped with navigating the codebase and writing the actual patches. I'd estimate the code writing itself was ~90% AI-assisted, but the debugging direction and testing was all manual. |
|
Thanks for the info, I will have a look at it in the next couple of days |
|
Thanks a lot for your contribution! The issues you mentioned had been unnoticed by me and had no code coverage yet. |
|
You're welcome, glad I could help! I hit these bugs while using Gokapi in production, so fixing them upstream felt like the natural thing to do. I won't be much help on the unit testing side, but I do a fair amount of real-world testing on my setup — happy to report anything I find along the way. Great project, keep it up! 🙏 |
Summary
gokapi-cli download --id XXXsilently exited with code 2 without making any network call. ThecheckRequiredUploadParameterfunction had noreturn truepath for valid download mode, causing execution to fall through to upload/Docker validation logic.os.Createwas called before the HTTP request. Reordered to create the file only after a successful response, and added cleanup on streaming errors.serveDecryptedFileunconditionally calledencryption.DecryptReader()even for non-encrypted files, causingcrypto/aes: invalid key size 0panic that killed the server process (vialog.Fatalin the encryption chain). AddedIsEncryptedcheck andIsDecryptionAvailable()guard./api/e2e/get, then decrypts in streaming during download.Test plan
🤖 Generated with Claude Code