Skip to content

Commit

Permalink
Emit LF after each object of --twitter-dump output
Browse files Browse the repository at this point in the history
  • Loading branch information
tesaguri committed May 21, 2019
1 parent d9089f5 commit 522e8b7
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,11 @@ where
);

for t in tweets {
self.with_twitter_dump(|dump| json::to_writer(dump, &t))?;
self.with_twitter_dump(|mut dump| -> io::Result<()> {
json::to_writer(&mut dump, &t)?;
dump.write_all(b"\n")?;
Ok(())
})?;
if t.retweeted_status.is_none() {
self.process_tweet(t)?;
}
Expand Down Expand Up @@ -324,7 +328,10 @@ where
e.context("error while listening to Twitter's Streaming API")
})?;

self.with_twitter_dump(|dump| dump.write_all(json.as_bytes()))?;
self.with_twitter_dump(|dump| {
dump.write_all(json.trim_end().as_bytes())?;
dump.write_all(b"\n")
})?;

let tweet = if let Maybe::Just(t) = json::from_str::<Maybe<twitter::Tweet>>(&json)? {
t
Expand Down

0 comments on commit 522e8b7

Please sign in to comment.