-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: 1.1.10
-
Component/s: GridFS
-
Environment:Any
-
Fully Compatible
There's two seek related issues with GridFS fixed by Pull Request https://github.com/mongodb/mongo-c-driver/pull/251/files
1. If system tries to fetch a page with _mongoc_gridfs_file_refresh_page() not available in cursor anymore, it will fail doing so because comparison to detect the range of available pages had < and > signs reverse in this code (diff from PR):
if (file->cursor &&
- !(file->cursor_range[0] >= n && file->cursor_range[1] <= n)) {
+ !(file->cursor_range[0] <= n && file->cursor_range[1] >= n)) { mongoc_cursor_destroy (file->cursor); file->cursor = NULL; }
2. When reading/writing into GridFSFile, if doing so exactly on blocks matching the chunk size, the proper chunk was not getting flushed to database because the calculation of chunk to flush overflowed into the next chunk because the pos field was pointing to the next byte to be written/read.
The other diffs in the Pull Request try to address that issue by keeping track of "how" the pos field was updated:
a. By direct seeking
b. By movement to next byte by read or write operation
Depending on this state, we calculate number of page to flush by subtracting 1 (or not) to current pos field.
- related to
-
CDRIVER-870 Handle GridFS I/O operations beyond end-of-file
- Closed