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 nom::{
AsChar, IResult, Parser,
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},
combinator::map,
AsChar, IResult, Parser,
};
use std::{ffi, path::Path, vec};

View File

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

View File

@@ -12,8 +12,8 @@ use is_executable::is_executable;
use java_properties::PropertiesIter;
use log::{info, warn};
use std::fs::OpenOptions;
use std::fs;
use std::fs::OpenOptions;
use std::io;
use std::{
collections::HashMap,
@@ -381,26 +381,25 @@ fn _install_module(zip: &str) -> Result<()> {
fn parse_size(size_str: &str) -> io::Result<u64> {
let size_str = size_str.trim();
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 = 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() {
"G" => 1 << 30,
"M" => 1 << 20,
"K" => 1 << 10,
_ => 1, // Default to bytes if no unit is specified
};
Ok(num * multiplier)
}
fn get_sparse_image_size() -> u64 {
let default_size = 6 << 30; // 6GB
let custom_size_file = "/data/adb/ksu/custom_sparse_size.txt";
match fs::read_to_string(custom_size_file) {
Ok(contents) => match parse_size(&contents) {
Ok(size) => size,