Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d4f72ef

Browse filesBrowse files
Samuel CorderSamuel Corder
Samuel Corder
authored and
Samuel Corder
committed
GridFileInfo.Exists()
1 parent 3b68126 commit d4f72ef
Copy full SHA for d4f72ef

File tree

3 files changed

+18
-5
lines changed
Filter options

3 files changed

+18
-5
lines changed

‎MongoDB.GridFS.Tests/GridFileInfoTest.cs

Copy file name to clipboardExpand all lines: MongoDB.GridFS.Tests/GridFileInfoTest.cs
+10-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,16 @@ public void TestMoveTo(){
7474
Assert.IsFalse(gf.Exists(filename), "File should have been moved.");
7575
Assert.IsTrue(gf.Exists(filename2), "File wasn't");
7676
}
77-
77+
78+
[Test]
79+
public void TestFileExists(){
80+
string filename = "gfi-exists.txt";
81+
GridFileInfo gfi = new GridFileInfo(db["tests"], "gfexists", filename);
82+
Assert.IsFalse(gfi.Exists());
83+
GridFileStream gfs = gfi.Create();
84+
Assert.IsTrue(gfi.Exists());
85+
}
86+
7887
[Test]
7988
public void TestOpenNonExistentFails(){
8089
string filename = "gfi-opennothere.txt";

‎MongoDB.GridFS/GridFileInfo.cs

Copy file name to clipboardExpand all lines: MongoDB.GridFS/GridFileInfo.cs
+5
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,15 @@ public void Delete(){
184184
}
185185
}
186186

187+
187188
public void MoveTo(String newFileName){
188189
this.gridFile.Move(this.FileName, newFileName);
189190
}
190191

192+
public Boolean Exists(){
193+
return this.gridFile.Exists(this.FileName);
194+
}
195+
191196
public void Truncate(){
192197
if(filedata.Contains("_id") == false) return;
193198
this.gridFile.Chunks.Delete(new Document().Append("files_id", filedata["_id"]));

‎README.rst

Copy file name to clipboardExpand all lines: README.rst
+3-4
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ Current Features
2323
- GridFS support
2424
- Map Reduce helpers.
2525
- hint, explain, $where
26+
- Safemode
27+
- Exceptions
2628

2729
Missing Features
2830
================
2931
- Auto reconnect options
3032
- Connection pooling (In progress)
31-
- Exceptions (In progress)
32-
- Safemode (Scheduled)
3333
- database profiling: set/get profiling level, get profiling info
3434
- Many unit tests
3535

@@ -63,7 +63,6 @@ Contributors
6363
- Sam Corder (samus)
6464
- Seth Edwards (Sedward)
6565
- Arne Classen (Sdether)
66+
- Steve Wagner (lanwin)
6667
- Andrew Kempe
6768
- Sergey Bartunov (sbos)
68-
69-

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.