Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement better temporary file management #1

Open
gocom opened this issue May 22, 2013 · 2 comments
Open

Implement better temporary file management #1

gocom opened this issue May 22, 2013 · 2 comments
Assignees
Milestone

Comments

@gocom
Copy link
Owner

gocom commented May 22, 2013

Temporary file management would be implemented using rah/eien. This would include:

  • An option, and defaults to, searching automatically for the system's temporary directory. This means the end user doesn't (necessarily) have to care about configuring it.
  • Using temporary files when doing the compressed version of the file. Current the temporary file is streamed to the final location without locking, and due to on-the-fly stream compression, the moving takes longer than simply renaming or copying the file. We should first compress, then move.
@ghost ghost assigned gocom May 22, 2013
@tvb
Copy link
Contributor

tvb commented Apr 27, 2014

@gocom Any idea when to implement this?

@gocom
Copy link
Owner Author

gocom commented Apr 28, 2014

@tristanvanbokkem Might not happen at all, actually. There is nothing wrong in how Danpu manages temporary files and does it well.

This is mainly only about moving the functionality to an external library (or using a library) and also about using temporary files the compression task, rather than streaming the file to final location. The latter would only improve things if the file and temporary location are on same volume, otherwise we still need to use copy instead of rename, resulting into the same situation.

The first point, in OP, about temporary directory location is not true. Danpu uses tempnam(), and it uses PHP's default temporary directory as a fallback. Well, it tries. Doing our own searching function is not feasible and may cause security issues since we can not know where you want to your files be put.

Unfortunately, there are no good libraries available for handling temporary files and atomic file operations do not exist in PHP. If the library can not be made atomic and completely error-aware, there is no point in writing one.

The only planned change is using temporary file for the compression task, and it will happen at some point. Due to the physical volume 'limitation' it's somewhat low priority.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants