fix: properly trim volume content before stripping percentage sign (#18)

This commit is contained in:
Timo Furrer 2024-10-08 16:11:50 +02:00 committed by GitHub
parent 4207016e82
commit 5eeee8069c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -44,7 +44,8 @@ impl InitialProperties {
// Basically just read from the volume file if it exists, otherwise return 100.
let volume = if volume.exists() {
let contents = fs::read_to_string(volume).await?;
let stripped = contents.trim().strip_suffix("%").unwrap_or(&contents);
let trimmed = contents.trim();
let stripped = trimmed.strip_suffix("%").unwrap_or(&trimmed);
stripped
.parse()
.map_err(|_| eyre!("volume.txt file is invalid"))?