timvisee / send

:mailbox_with_mail: Simple, private file sharing. Mirror of https://gitlab.com/timvisee/send
https://send.vis.ee
Mozilla Public License 2.0
4.78k stars 276 forks source link

Server does not correctly close and delete partially uploaded files #198

Open bain3 opened 2 months ago

bain3 commented 2 months ago

If the user aborts the upload in some way, for example by clicking the "Cancel" button during upload, the server does not correctly close the upload pipeline.

Steps to reproduce

  1. start the server in dev mode (following instructions in readme)
  2. start uploading a large file
  3. interrupt upload
  4. see that there is a file in the uploads folder (which should be normally deleted on this line)
  5. run lsof -p <pid> and see that the file is still open (this blocks automatic deletion by an external script! File does not get actually deleted from fs until the descriptor is closed...)
  6. be sad :(
bain3 commented 1 month ago

Ok I managed to create a hotfix for our instance. .pipe() does not properly propagate errors, and on top of that, the ws stream is not properly closed.

https://git.nolog.cz/NoLog.cz/send/commit/f7e889b875538d57ec95f0a5be7a5f7ca25e16db

bain3 commented 1 month ago

If you've been running send for a long time with a bit of traffic, then I recommend running fsck on the filesystem where you store files. This reclaimed multiple hundreds of gigs of disk space for us. I assume ext4 did not like all the open but deleted files.