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

Throw exception if disk is full #6

Open
aleksmitov opened this issue Dec 22, 2013 · 5 comments
Open

Throw exception if disk is full #6

aleksmitov opened this issue Dec 22, 2013 · 5 comments

Comments

@aleksmitov
Copy link

So for some reason when I pass big files, on some (no idea on what criteria) I get that finfo_file() doesn't recieve a file path. And indeed, when I var_dump() the $path variable passed to setTypeFromPath(), it is empty.

@aleksmitov
Copy link
Author

So I found the problem. I didn't have enough space on the disk. It would be better if the script threw an Exception to find the problem. It took me a lot of time to go through the script and find the problematic spot.

@Gargron
Copy link
Owner

Gargron commented Dec 23, 2013

@AlexanderMitov An exception in case the disk does not have enough space to host the file (but validation is passed)? That's a good idea but I'm not certain right now how to best do it.

Gargron added a commit that referenced this issue Feb 20, 2014
FileUploadFactory API improved, validator argument now optional array
@Gargron
Copy link
Owner

Gargron commented Feb 20, 2014

I am still not sure where to throw an exception. Basically, if the $path in setTypeFromPath() is empty, that means $tmp_filename passed from processAll() is empty too. That can happen when the request contains no uploads at all. Now we discard empty uploads, so that should be resolved, but there is still no exception thrown on full disk, and I don't know how to differentiate empty uploads from uploads that didn't happen because the disk was full.

If anyone else has ideas on this, you're welcome to post them.

@thenovacreator
Copy link
Contributor

I think there are to points where this could happen.

The first one is while uploading the file. It breaks becaus there is to less space on disk free. Maybe you have an error code reflectiong something like this. Another Option is to use the size provided by "content-disposition" and compare it with the value that "disk_free_space" gives you.

The second point to throw an exception then the file is moved. Here its totally possible to get the filesize and check it against the disk_free_space.

@enricodias
Copy link

I know it's an old issue, but wouldn't be better to set a minimum free space value to accept uploads? If the server really doesn't have space, the upload may fail even before the php code gets executed. It would be better if could prevent getting to this point.

The class could check that if the upload is completed, the free space will remain above the minimum threshold. In case it won't, an exception would be thrown.

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

4 participants