Fix disk usage calculations when too large file is created #155
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously if you created file having larger initial contents than the
free space in the fake filesystem, the disk usage counter was decreased
by the size of the initial contents possibly resulting in negative usage.
Basically the issue was that when ChangeDiskUsage is called with size
larger than the amount of free space, space usage is not changed but
an error is raised. Due to an exception, CreateFile removes the created
object that results in new call to ChangeDiskUsage with negative size
of the object.
Previously the object's size was set before ChangeDiskUsage was called
and then when the object was being removed the object's already set size
was used to reduce the filesystem usage (even though that size was never
added to the usage).