Skip to content
This repository was archived by the owner on Oct 18, 2021. It is now read-only.

Commit 4398cfb

Browse files
authored
Merge pull request #158 from saghm/fix-gridfs-race-condition
Fix GridFS race condition
2 parents 683cbbd + 0267dbb commit 4398cfb

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/gridfs/file.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,10 @@ impl File {
324324

325325
match result {
326326
Ok(Some(doc)) => match doc.get("data") {
327-
Some(&Bson::Binary(_, ref buf)) => cache.data = buf.clone(),
327+
Some(&Bson::Binary(_, ref buf)) => {
328+
cache.data = buf.clone();
329+
cache.err = None;
330+
},
328331
_ => cache.err = Some(OperationError("Chunk contained no data.".to_owned())),
329332
},
330333
Ok(None) => cache.err = Some(OperationError("Chunk not found.".to_owned())),
@@ -646,7 +649,7 @@ impl CachedChunk {
646649
CachedChunk {
647650
n: n,
648651
data: Vec::new(),
649-
err: None,
652+
err: Some(Error::DefaultError(String::from("Chunk has not yet been initialized"))),
650653
}
651654
}
652655
}

0 commit comments

Comments
 (0)