Skip to content

Commit b9be6c5

Browse files
committed
Die if fail to write to file
1 parent 2126625 commit b9be6c5

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

src/main.rs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -236,33 +236,35 @@ fn main() {
236236

237237
if old_entry != new_entry {
238238
if transactions {
239-
writeln!(output, "BEGIN;");
239+
writeln!(output, "BEGIN;").unwrap();
240240
}
241241

242242
writeln!(
243243
output,
244244
"DELETE FROM state_group_edges WHERE state_group = {};",
245245
sg
246-
);
246+
)
247+
.unwrap();
247248

248249
if let Some(prev_sg) = new_entry.prev_state_group {
249-
writeln!(output, "INSERT INTO state_group_edges (state_group, prev_state_group) VALUES ({}, {});", sg, prev_sg);
250+
writeln!(output, "INSERT INTO state_group_edges (state_group, prev_state_group) VALUES ({}, {});", sg, prev_sg).unwrap();
250251
}
251252

252253
writeln!(
253254
output,
254255
"DELETE FROM state_groups_state WHERE state_group = {};",
255256
sg
256-
);
257+
)
258+
.unwrap();
257259
if new_entry.state_map.len() > 0 {
258-
writeln!(output, "INSERT INTO state_groups_state (state_group, room_id, type, state_key, event_id) VALUES");
260+
writeln!(output, "INSERT INTO state_groups_state (state_group, room_id, type, state_key, event_id) VALUES").unwrap();
259261
let mut first = true;
260262
for ((t, s), e) in new_entry.state_map.iter() {
261263
if first {
262-
write!(output, " ");
264+
write!(output, " ").unwrap();
263265
first = false;
264266
} else {
265-
write!(output, " ,");
267+
write!(output, " ,").unwrap();
266268
}
267269
writeln!(
268270
output,
@@ -272,15 +274,16 @@ fn main() {
272274
PGEscapse(t),
273275
PGEscapse(s),
274276
PGEscapse(e)
275-
);
277+
)
278+
.unwrap();
276279
}
277-
writeln!(output, ";");
280+
writeln!(output, ";").unwrap();
278281
}
279282

280283
if transactions {
281-
writeln!(output, "COMMIT;");
284+
writeln!(output, "COMMIT;").unwrap();
282285
}
283-
writeln!(output);
286+
writeln!(output).unwrap();
284287
}
285288

286289
pb.inc(1);

0 commit comments

Comments
 (0)