freezer: fix the issue of missing trim the str

When reading from the freezer file, it should trim it
first, and the string may container an '\n'.

Fixes: #48

Signed-off-by: fupan.lfp <fupan.lfp@antgroup.com>
This commit is contained in:
fupan.lfp
2021-06-30 17:41:25 +08:00
parent 45b626e0c0
commit 4b5a190ecc

View File

@@ -130,7 +130,7 @@ impl FreezerController {
let mut s = String::new();
let res = file.read_to_string(&mut s);
match res {
Ok(_) => match s.as_ref() {
Ok(_) => match s.trim() {
"FROZEN" => Ok(FreezerState::Frozen),
"THAWED" => Ok(FreezerState::Thawed),
"1" => Ok(FreezerState::Frozen),