You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
listenForEvents() {
this.ffmpegEmitter.on('ffmpegNewSegment', (filepath) => {
let doc = {
id: this.id,
name: this.name,
filepath: filepath
};
db.insert(doc, function (err, newDoc) { // Callback is optional
// newDoc is the newly inserted document, including its _id
// newDoc has no key called notToBeSaved since its value was undefined
if (err) {
//TODO: log didn't save event'
}
});
console.log('inserted ', filepath);
})
}
The text was updated successfully, but these errors were encountered:
Turns out my bug had nothing to do with this library. I was writing to a file with one process while calling fs.truncate(database.txt, 0) with another. The first process must be keeping a pointer to where it left off.
When I insert into the database one of the attributes in documents contains a bunch of null characters.
When I console.log the filename before inserting I don't see the null characters.
This is a problem when I pull the documents out the extra characters are still apart of the string. Is this something I am doing wrong?
Here's what's in my file:
{ "id": "123", "name": "Crippled Cam", "filepath": "123_2016-11-10_000.mp4\n", "_id": "uMwERiGF4bUtn7M9", "createdAt": { "$$date": 1481330291431 }, "updatedAt": { "$$date": 1481330291431 } } { "id": "123", "name": "Crippled Cam", "filepath": "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000123_2016-11-10_001.mp4\n", "_id": "E6LR8fPQKig4Qn1b", "createdAt": { "$$date": 1481330299763 }, "updatedAt": { "$$date": 1481330299763 } } { "id": "123", "name": "Crippled Cam", "filepath": "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000123_2016-11-10_002.mp4\n", "_id": "pINbQwZt9kCcvKyQ", "createdAt": { "$$date": 1481330308092 }, "updatedAt": { "$$date": 1481330308092 } } { "id": "123", "name": "Crippled Cam", "filepath": "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000123_2016-11-10_003.mp4\n", "_id": "Ksjpx3DzczFm0vhj", "createdAt": { "$$date": 1481330316423 }, "updatedAt": { "$$date": 1481330316423 } }
Here's my insert:
The text was updated successfully, but these errors were encountered: