CreatePack in memory?
Posted: Fri Oct 06, 2023 4:32 pm
Hi all,
I have a case where a web service needs to create an archive and return that archive to a client via CGI. Currently I have this implemented such that it uses CreatePack() with a temp file, and then reads the temp file. This works after a fashion, but it seems like it would be better to do it entirely in memory.
Recently though, I've started getting intermittent failures with this process which I strongly suspect are to do with the antivirus software on the server (which I don't have any control over), causing file locking issues. Such that after calling ClosePack() and moving on to ReadFile(), I'm finding the file locked. I could probably work around this or add a retry mechanism or something, but again it seems like a neater solution would be to do it all in memory and avoid the temp file in the first place.
The archive is not large - 10s of KBs at most. It will typically contain multiple files, and I need their filenames stored such that the client can use ExaminePack to get the names and extract the files. This means I can't just use CompressMemory() as that just results in a compressed block with no filename information. The files may change at any time, so although caching the archive is an option, I will still need a way to reliably build the archive first in order to have something to cache.
One option that comes to mind is using a named pipe for the temp file, which I think should work, but are there better options?
I have a case where a web service needs to create an archive and return that archive to a client via CGI. Currently I have this implemented such that it uses CreatePack() with a temp file, and then reads the temp file. This works after a fashion, but it seems like it would be better to do it entirely in memory.
Recently though, I've started getting intermittent failures with this process which I strongly suspect are to do with the antivirus software on the server (which I don't have any control over), causing file locking issues. Such that after calling ClosePack() and moving on to ReadFile(), I'm finding the file locked. I could probably work around this or add a retry mechanism or something, but again it seems like a neater solution would be to do it all in memory and avoid the temp file in the first place.
The archive is not large - 10s of KBs at most. It will typically contain multiple files, and I need their filenames stored such that the client can use ExaminePack to get the names and extract the files. This means I can't just use CompressMemory() as that just results in a compressed block with no filename information. The files may change at any time, so although caching the archive is an option, I will still need a way to reliably build the archive first in order to have something to cache.
One option that comes to mind is using a named pipe for the temp file, which I think should work, but are there better options?