Fix formatting (#266)

This commit is contained in:
Caner Karaca
2025-03-29 22:46:06 +03:00
committed by GitHub
parent de44373599
commit feb3c47bdc
3 changed files with 11 additions and 12 deletions

View File

@@ -1,11 +1,11 @@
use anyhow::{bail, Result}; use anyhow::{Result, bail};
use derive_new::new; use derive_new::new;
use nom::{ use nom::{
AsChar, IResult, Parser,
branch::alt, branch::alt,
bytes::complete::{tag, take_while, take_while1, take_while_m_n}, bytes::complete::{tag, take_while, take_while_m_n, take_while1},
character::complete::{space0, space1}, character::complete::{space0, space1},
combinator::map, combinator::map,
AsChar, IResult, Parser,
}; };
use std::{ffi, path::Path, vec}; use std::{ffi, path::Path, vec};

View File

@@ -1,6 +1,6 @@
use anyhow::{Context, Error, Ok, Result, bail}; use anyhow::{Context, Error, Ok, Result, bail};
use std::{ use std::{
fs::{create_dir_all, remove_file, write, File, OpenOptions}, fs::{File, OpenOptions, create_dir_all, remove_file, write},
io::{ io::{
ErrorKind::{AlreadyExists, NotFound}, ErrorKind::{AlreadyExists, NotFound},
Write, Write,

View File

@@ -12,8 +12,8 @@ use is_executable::is_executable;
use java_properties::PropertiesIter; use java_properties::PropertiesIter;
use log::{info, warn}; use log::{info, warn};
use std::fs::OpenOptions;
use std::fs; use std::fs;
use std::fs::OpenOptions;
use std::io; use std::io;
use std::{ use std::{
collections::HashMap, collections::HashMap,
@@ -381,26 +381,25 @@ fn _install_module(zip: &str) -> Result<()> {
fn parse_size(size_str: &str) -> io::Result<u64> { fn parse_size(size_str: &str) -> io::Result<u64> {
let size_str = size_str.trim(); let size_str = size_str.trim();
if size_str.is_empty() { if size_str.is_empty() {
return Err(io::Error::new(io::ErrorKind::InvalidData, "Empty size string")); return Err(io::Error::new(
io::ErrorKind::InvalidData,
"Empty size string",
));
} }
let (num, unit) = size_str.split_at(size_str.len().saturating_sub(1)); let (num, unit) = size_str.split_at(size_str.len().saturating_sub(1));
let num = u64::from_str(num.trim()).map_err(|_| io::Error::new(io::ErrorKind::InvalidData, "Invalid number"))?; let num = u64::from_str(num.trim())
.map_err(|_| io::Error::new(io::ErrorKind::InvalidData, "Invalid number"))?;
let multiplier = match unit.to_ascii_uppercase().as_str() { let multiplier = match unit.to_ascii_uppercase().as_str() {
"G" => 1 << 30, "G" => 1 << 30,
"M" => 1 << 20, "M" => 1 << 20,
"K" => 1 << 10, "K" => 1 << 10,
_ => 1, // Default to bytes if no unit is specified _ => 1, // Default to bytes if no unit is specified
}; };
Ok(num * multiplier) Ok(num * multiplier)
} }
fn get_sparse_image_size() -> u64 { fn get_sparse_image_size() -> u64 {
let default_size = 6 << 30; // 6GB let default_size = 6 << 30; // 6GB
let custom_size_file = "/data/adb/ksu/custom_sparse_size.txt"; let custom_size_file = "/data/adb/ksu/custom_sparse_size.txt";
match fs::read_to_string(custom_size_file) { match fs::read_to_string(custom_size_file) {
Ok(contents) => match parse_size(&contents) { Ok(contents) => match parse_size(&contents) {
Ok(size) => size, Ok(size) => size,