Meteor-Community-Packages/Meteor-CollectionFS

Failing to remove file

Opened this issue · 0 comments

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: throws cannot remove file belongs to: "docs" not: "cfs.docs.filerecord"
  • Setting both allow and deny props, or just one of them. Nothing changes (but the allow and deny do get set, download stops working if we remove allow).
  • Tried setting a callback. Callback is never called, either with success or fail.
  • Used both GridFS and Filesystem
  • I even tried calling FileCollection.remove({}) and got Error: 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.