-
Type:
Bug
-
Resolution: Won't Fix
-
Priority:
Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
Environment:Ubuntu 10.10 AMD64 pymongo 1.9
-
None
-
None
-
None
-
None
-
None
-
None
-
None
Calling delete() does not completely get rid of a file. Additionally it never throws errors.
g is a gridfs.GridFS
>>> g.delete("i made this up")
>>> g.delete(321312312)
(Note no exceptions thrown)
>>> v=g.get_version("grammar/grammar", -4)
>>> v._id
ObjectId('4cb39cbef047051a37000000')
>>> g.delete(v._id)
>>> g.delete(v._id)
>>> g.delete(v._id)
Repeatedly deleting the same file and again no exceptions.
What I was actually trying to do is remove all old versions of files. Maybe you want to include that in the examples. (The reason is to make dumps smaller.)
for name in g.list():
try:
while True:
v=g.get_version(name, -2)
g.delete(v._id)
except gridfs.NoFile:
pass