Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cpp/src/StreamUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ class InputStream {
class FileInputStream : public InputStream {
public:
FileInputStream(const std::string &filename) : filename(filename) {
handle = fopen(filename.c_str(), "r");
// Open in binary mode so Windows does not alter bytes (CRLF translation).
handle = fopen(filename.c_str(), "rb");
if (!handle) {
throw std::runtime_error("Failed to open file for reading: " + filename);
}
Expand Down
3 changes: 2 additions & 1 deletion cpp/src/TypedIndex.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,8 @@ class TypedIndex : public Index {
* Save this index to the provided file path on disk.
*/
void saveIndex(const std::string &pathToIndex) {
algorithmImpl->saveIndex(pathToIndex);
// Write metadata + index once. Calling algorithmImpl->saveIndex first
// would overwrite the path with an index-only payload and break loads.
saveIndex(std::make_shared<FileOutputStream>(pathToIndex));
}

Expand Down