Skip to content

Commit

Permalink
chore: fix compile err by splitting backup name and format strings as…
Browse files Browse the repository at this point in the history
… 2 `const`s
Rudxain committed Jan 16, 2025
1 parent d14ed45 commit 66021c2
Showing 2 changed files with 11 additions and 6 deletions.
9 changes: 6 additions & 3 deletions src/core/utils.rs
Original file line number Diff line number Diff line change
@@ -17,7 +17,8 @@ pub const NAME: &str = "UAD-ng";
/// [More info](https://developer.android.com/tools/variables#adb)
pub const ANDROID_SERIAL: &str = "ANDROID_SERIAL";
pub const EXPORT_FILE_NAME: &str = "selection_export.txt";
pub const UNINSTALLED_PACKAGES_FILE_NAME_FORMAT: &str = "uninstalled_packages_{}.csv";
pub const UNINSTALLED_PACKAGES_FILE_NAME: &str = "uninstalled_packages";
pub const UNINSTALLED_PACKAGES_FORMAT: &str = "csv";

#[derive(Debug, Clone)]
pub enum Error {
@@ -184,8 +185,10 @@ pub async fn export_packages(
phone_packages: Vec<Vec<PackageRow>>,
) -> Result<bool, String> {
let backup_file = format!(
UNINSTALLED_PACKAGES_FILE_NAME_FORMAT,
Local::now().format("%Y%m%d")
"{}_{}.{}",
UNINSTALLED_PACKAGES_FILE_NAME,
Local::now().format("%Y%m%d"),
UNINSTALLED_PACKAGES_FORMAT
);

let file = fs::File::create(backup_file).map_err(|err| err.to_string())?;
8 changes: 5 additions & 3 deletions src/gui/views/settings.rs
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ use crate::core::sync::{get_android_sdk, perform_adb_commands, CommandType, Phon
use crate::core::theme::Theme;
use crate::core::utils::{
export_packages, open_folder, open_url, string_to_theme, DisplayablePath,
UNINSTALLED_PACKAGES_FILE_NAME_FORMAT,
UNINSTALLED_PACKAGES_FILE_NAME, UNINSTALLED_PACKAGES_FORMAT,
};
use crate::gui::style;
use crate::gui::views::list::{List as AppsView, PackageInfo};
@@ -544,8 +544,10 @@ impl Settings {
].padding(20);

let file_row = row![text(format!(
UNINSTALLED_PACKAGES_FILE_NAME_FORMAT,
chrono::Local::now().format("%Y%m%d")
"{}_{}.{}",
UNINSTALLED_PACKAGES_FILE_NAME,
chrono::Local::now().format("%Y%m%d"),
UNINSTALLED_PACKAGES_FORMAT
))
.style(style::Text::Commentary)]
.padding(20);

0 comments on commit 66021c2

Please sign in to comment.