-
Type: Bug
-
Resolution: Unresolved
-
Priority: Minor - P4
-
None
-
Affects Version/s: 3.4.2, 3.4.6
-
Component/s: mongofiles
-
None
-
Environment:Tested under MacOS Sierra v 10.12.5
Tested with v3.4.2 and v3.4.6
Case 1:
Delete a non-existent file:
I only have one GridFS file "mongodb-mms-3.4.6.443-1.x86_64.rpm"
MongoDB Enterprise replset:PRIMARY> db.fs.files.find() { "_id" : ObjectId("59794d50f6f6152271bc57f6"), "chunkSize" : 261120, "uploadDate" : ISODate("2017-07-27T02:19:31.781Z"), "length" : 500329668, "md5" : "ab09ca9a7b9d1c7dbd6225f977c3c057", "filename" : "mongodb-mms-3.4.6.443-1.x86_64.rpm" }
When I tried to delete a non-existent file "something.log", mongofiles still reporting successfully deleted all instances of 'something.log' from GridFS.
10gens-MacBook-Pro-3:3.4.2 tomli$ mongofiles delete something.log -vvvvv 2017-07-28T14:04:54.285+1000 will listen for SIGTERM, SIGINT, and SIGKILL 2017-07-28T14:04:54.289+1000 connected to node type: replset 2017-07-28T14:04:54.289+1000 using write concern: w='majority', j=false, fsync=false, wtimeout=0 2017-07-28T14:04:54.289+1000 connected to: localhost 2017-07-28T14:04:54.289+1000 handling mongofiles 'delete' command... successfully deleted all instances of 'something.log' from GridFS
Case 2:
I have added a file called “mongod.log” using mongofiles, then I have manually deleted the metadata doc in fs.files, so there would be no reference of “filename”: “mongod.log” in the fs.files collection.
10gens-MacBook-Pro-3:3.4.2 tomli$ mongofiles put mongod.log 2017-07-28T14:07:41.958+1000 connected to: localhost added file: mongod.log
MongoDB Enterprise replset:PRIMARY> db.fs.files.deleteOne({filename:"mongod.log"}) { "acknowledged" : true, "deletedCount" : 1 }
When I tried to delete the "mongod.log" file using mongofiles, it reports successfully deleted all instances of "mongod.log" from GridFS. Which it isn't, since all chunks in fs.chunks are not deleted.
10gens-MacBook-Pro-3:3.4.2 tomli$ mongofiles delete mongod.log -vvvvv 2017-07-28T14:10:22.545+1000 will listen for SIGTERM, SIGINT, and SIGKILL 2017-07-28T14:10:22.549+1000 connected to node type: replset 2017-07-28T14:10:22.549+1000 using write concern: w='majority', j=false, fsync=false, wtimeout=0 2017-07-28T14:10:22.549+1000 connected to: localhost 2017-07-28T14:10:22.549+1000 handling mongofiles 'delete' command... successfully deleted all instances of 'mongod.log' from GridFS
I think it would be good to catch the exception and return related error message, like: " file not found" etc.