gocom / danpu

Optimized MySQL dump library written in PHP
MIT License
62 stars 15 forks source link

Implement better temporary file management #1

Open gocom opened 11 years ago

gocom commented 11 years ago

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

tvb commented 10 years ago

@gocom Any idea when to implement this?

gocom commented 10 years ago

@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.