I want to run the following code
const files_stream = Readdirp ({
root : folder,
entryType : 'files',
fileFilter : info => !FilesAlreadyRead.findOne(info.name)
})
where Readdirp is an npm package to read recursively all the files in a folder.
That code raises a ‘cannot run ouside of a fiber’ error message. My understanding from the Meteor Guide was that the solution was to wrap my Meteor call with Meteor.bindEnvironment
const files_stream = Readdirp ({
root : folder,
entryType : 'files',
fileFilter : Meteor.bindEnvironment (info => !FilesAlreadyRead.findOne(info.name))
})
But that code is not doing anything. I have tried to print the value returned by the collection but it never prints anything
Meteor.bindEnvironment(info => {
const v = FilesAlreadyRead.findOne(info.name)
console.log("meteor", info.name, v)
return !v
})
My workaround till now was to save all the files returned by Readdirp in an array, use a future to wait till the readdirp completes and filter it afterwards in a Meteor code. But the amount of files on the server has grown so much it doesn’t work anymore.