[web-devel] Generating, serving, and deleting temporary files with Wai/Yesod

Gregory Collins greg at gregorycollins.net
Sat Oct 23 23:04:53 CEST 2010

Michael Snoyman <michael at snoyman.com> writes:

> This does seem like the right approach. Just as fair warning: using an
> enumerator for serving files loses out on the possible optimization of
> a sendfile system call. Another possibility may be to keep a pool of
> file names to use as temporary files and keep rotating their usage.
> But I *do* think your approach is the correct one.

On unixy systems the "correct" approach traditionally would be to open
the file, then unlink it before you send the data out the socket. When
the file descriptor is closed, the link count goes to zero and the file
goes away. Obviously this isn't portable though.

Gregory Collins <greg at gregorycollins.net>

More information about the web-devel mailing list