fix: fixed logdir index out of bounds

This commit is contained in:
imlonghao 2022-01-27 22:25:08 +08:00
parent 6c96967407
commit e3e428ad06
Failed to extract signature
2 changed files with 4 additions and 0 deletions

View file

@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed ### Fixed
- Ensure logir is not null - Ensure logir is not null
- Fixed index out of bounds caused by olded ts
### Added ### Added

View file

@ -238,6 +238,9 @@ async fn get_pkg_log(
) )
.await .await
.unwrap(); .unwrap();
if rows.len() == 0 {
return HttpResponse::BadRequest().body("ts is too old");
}
let logdir: String = rows[0].get("logdir"); let logdir: String = rows[0].get("logdir");
let filename = format!("/home/lilydjwg/.lilac/log/{}/{}.log", logdir, name); let filename = format!("/home/lilydjwg/.lilac/log/{}/{}.log", logdir, name);
let contents = match std::fs::read_to_string(&filename) { let contents = match std::fs::read_to_string(&filename) {