Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Database full of null characters #480

Closed
erceth opened this issue Dec 10, 2016 · 3 comments
Closed

Database full of null characters #480

erceth opened this issue Dec 10, 2016 · 3 comments

Comments

@erceth
Copy link

erceth commented Dec 10, 2016

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:

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);
})
}
@ralyodio
Copy link

is your db too big?

@erceth
Copy link
Author

erceth commented Dec 12, 2016

No, what I posted above is the contents of the whole file.

@erceth
Copy link
Author

erceth commented Dec 13, 2016

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants