Skip to content

Commit a6a0947

Browse files
committed
fix: GitHub not returning anything on 1970-01-01
Not sure why, but setting it to 1970-01-02 works.
1 parent 4da5fb9 commit a6a0947

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

src/main.rs

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,9 @@ async fn get_issue_page(
242242
.per_page(100)
243243
.direction(params::Direction::Ascending)
244244
.sort(sort)
245-
.since(since.unwrap_or_default())
245+
// for some reason, the GitHub API doesn't return anything
246+
// if you give it 1970-01-01 00:00:00 UTC, so give it 1970-01-02.
247+
.since(since.unwrap_or(Utc.with_ymd_and_hms(1970, 1, 2, 0, 0, 0).unwrap()))
246248
.state(params::State::All)
247249
.page(page)
248250
.send()
@@ -577,7 +579,9 @@ async fn main() -> ExitCode {
577579
}
578580
});
579581

582+
let mut written_anything = false;
580583
while let Some(data) = receiver.recv().await {
584+
written_anything = true;
581585
if let Err(e) = write(data.clone(), args.destination.clone()) {
582586
error!(
583587
"Could not write {} to {}: {}",
@@ -591,14 +595,17 @@ async fn main() -> ExitCode {
591595
}
592596

593597
if task.await.is_ok() {
594-
if let Err(e) = write_backup_state(start_time, args.destination.clone()) {
595-
error!(
596-
"Failed to write {} to {}: {}",
597-
STATE_FILE,
598-
args.destination.clone().display(),
599-
e
600-
);
601-
return ExitCode::from(EXIT_WRITING);
598+
// only write state file if we actually wrote anything
599+
if written_anything {
600+
if let Err(e) = write_backup_state(start_time, args.destination.clone()) {
601+
error!(
602+
"Failed to write {} to {}: {}",
603+
STATE_FILE,
604+
args.destination.clone().display(),
605+
e
606+
);
607+
return ExitCode::from(EXIT_WRITING);
608+
}
602609
}
603610
} else {
604611
return ExitCode::from(EXIT_API_ERROR);

0 commit comments

Comments
 (0)