Failing to remove file
Opened this issue · 0 comments
bvanderdrift commented
Dear CollectionFS team.
We have been using your package to store rendered PDF's on the server. Currently we're implementing an extremely basic function to remove those PDF's. The code is as simple as this: (it is an automated test).
let existDoc = FileCollection.findOne(fileID);
if(!existDoc) throw Error("File did not exist");
FileCollection.remove(fileID);
let goneDoc = FileCollection.findOne(fileID);
if(goneDoc) throw Error("Failed to remove file with ID: " + fileID);
This keeps on throwing Failed to remove file...
. Remember: the findOne
call is successful. We have tried:
- Printing the result of
remove
(should be the amount of docs removed):undefined
- Giving a fake ID: no errors, also returns
undefined
- Passing
{_id: fileID}
as selector. - Passing
existDoc
as selector: throwscannot remove file belongs to: "docs" not: "cfs.docs.filerecord"
- Setting both
allow
anddeny
props, or just one of them. Nothing changes (but theallow
anddeny
do get set, download stops working if we removeallow
). - Tried setting a callback. Callback is never called, either with success or fail.
- Used both
GridFS
andFilesystem
- I even tried calling
FileCollection.remove({})
and gotError: Argument passed in must be a single String of 12 bytes or a string of 24 hex characters
This code is server-side and the collection is not available client side, purely on the server.