PiSCSI / piscsi

PiSCSI allows a Raspberry Pi to function as emulated SCSI devices (hard disk, CD-ROM, and others) for vintage SCSI-based computers and devices. This is a fork of the RaSCSI project by GIMONS.
https://piscsi.org
BSD 3-Clause "New" or "Revised" License
537 stars 82 forks source link

Web UI: File uploads in progress stored as tmp file #1270

Closed rdmark closed 11 months ago

rdmark commented 12 months ago

This is to store file uploads in progress into a temporary directory instead of directly into the target images dir; then move them to the image dir once the upload is successful.

uweseimet commented 12 months ago

The temporary directory should be /tmp. A different approach (I think Firefox does it this way) is to store the file with a unique temporary name in the final target directory, and to rename it to its actual name after a successful upload. This may be better, because it is guaranteed that both the temporary and the final file are in the same filesystem. Especially when the temporary file is in a different folder than the final file you have to check for errors/completeness twice. Once for the uploaded file, and a second time after moving the file to the final location. Having both in the same folder makes a failure (provided the upload itself was successful) when moving/renaming less likely, because you cannot run out of disk space. If you run out of disk space and the files are in different folders two files may have to be deleted in order to clean up.

If it is not the case yet, quite soon most of the web UI issues raised will not be related to piscsi as such anymore but to everything else the web UI does ;-).

rdmark commented 11 months ago

There are pros and cons to both approaches. The web UI doesn't have logic presently to automatically clean up failed or aborted file uploads.

Putting temporary files in the present dir with a temporary name, makes it easier for users to identify failed uploads and clean them up themselves. But manual intervention by the user will be needed.

By using the /tmp dir the system will eventually clean up the failed uploads automatically and no manual intervention needed. However, the latter option isn't ideal since large temp files may clog up the file system in the short term.

I will attempt the former approach.