-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add initial option to back up shortcuts * Show list of backups * Reload backups on change * Restore backups * Improve UX of backup ui * Reorganize ui * Update version in cargo.toml * Update flatpak description * Update cargo-lock.json
- Loading branch information
Showing
9 changed files
with
265 additions
and
33 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,61 @@ | ||
[package] | ||
name = "boilr" | ||
version = "1.3.6" | ||
edition = "2021" | ||
name = "boilr" | ||
version = "1.3.7" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
[dependencies] | ||
steam_shortcuts_util = "1.1.7" | ||
steamgriddb_api = "^0.3.0" | ||
serde = { version = "^1.0.137", features = ["derive"] } | ||
serde_json = "^1.0.81" | ||
tokio = { version = "^1.18.2", features = ["full"] } | ||
reqwest = { version = "^0.11.10", default_features = false } | ||
base64 = "^0.13.0" | ||
chrono = "^0.4.19" | ||
config = "^0.11.0" | ||
copypasta = "0.7.1" | ||
failure = "^0.1.8" | ||
nom = "^7.1.1" | ||
flate2 = "^1.0.23" | ||
futures = { version = "^0.3.21" } | ||
dashmap = { version = "^5.3.3", features = ["serde"] } | ||
is_executable = "^1.0.1" | ||
nom = "^7.1.1" | ||
rusty-leveldb = "^0.3.6" | ||
base64 = "^0.13.0" | ||
eframe = { version = "^0.18.0" } | ||
egui = { version = "^0.18.1" } | ||
image = { version = "0.24.2", features = ["png"] } | ||
toml = { version = "^0.5.9" } | ||
serde_json = "^1.0.81" | ||
sqlite = "^0.26.0" | ||
steam_shortcuts_util = "^1.1.7" | ||
steamgriddb_api = "^0.3.0" | ||
sysinfo = "^0.23.12" | ||
sqlite = "0.26.0" | ||
copypasta = "0.7.1" | ||
|
||
[target.'cfg(windows)'.dependencies] | ||
winreg = "0.10.1" | ||
[dependencies.dashmap] | ||
features = ["serde"] | ||
version = "^5.3.3" | ||
|
||
[dependencies.eframe] | ||
version = "^0.18.0" | ||
|
||
[dependencies.egui] | ||
version = "^0.18.1" | ||
|
||
[dependencies.futures] | ||
version = "^0.3.21" | ||
|
||
[dependencies.image] | ||
features = ["png"] | ||
version = "^0.24.2" | ||
|
||
[dependencies.reqwest] | ||
default_features = false | ||
version = "^0.11.10" | ||
|
||
[dependencies.serde] | ||
features = ["derive"] | ||
version = "^1.0.137" | ||
|
||
[dependencies.tokio] | ||
features = ["full"] | ||
version = "^1.18.2" | ||
|
||
[dependencies.toml] | ||
version = "^0.5.9" | ||
|
||
[target] | ||
[target."cfg(windows)"] | ||
[target."cfg(windows)".build-dependencies] | ||
winres = "^0.1" | ||
|
||
[target."cfg(windows)".dependencies] | ||
winreg = "^0.10.1" | ||
|
||
[target.'cfg(windows)'.build-dependencies] | ||
winres = "0.1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
use std::path::{Path, PathBuf}; | ||
|
||
use chrono::Local; | ||
use egui::ScrollArea; | ||
|
||
use crate::{ | ||
config::get_backups_flder, | ||
steam::{get_shortcuts_paths, SteamSettings}, | ||
}; | ||
|
||
use super::MyEguiApp; | ||
|
||
#[derive(Default)] | ||
pub struct BackupState { | ||
pub available_backups: Option<Vec<PathBuf>>, | ||
pub last_restore: Option<PathBuf>, | ||
} | ||
|
||
impl MyEguiApp { | ||
pub fn render_backup(&mut self, ui: &mut egui::Ui) { | ||
ui.heading("Backups"); | ||
ui.label("Here you can restore backed up shortcuts files"); | ||
ui.label("Click a backup to restore it, your current shortcuts will be backed up first"); | ||
ui.add_space(15.0); | ||
|
||
if let Some(last_restore) = self.backup_state.last_restore.as_ref() { | ||
ui.heading(format!("Last restored {:?}", last_restore)); | ||
} | ||
|
||
if ui.button("Click here to create a new backup").clicked() { | ||
backup_shortcuts(&self.settings.steam); | ||
self.backup_state.available_backups = None; | ||
} | ||
|
||
let available_backups = self | ||
.backup_state | ||
.available_backups | ||
.get_or_insert_with(|| load_backups()); | ||
|
||
if available_backups.is_empty() { | ||
ui.label("No backups found, they will be created every time you run import"); | ||
} else { | ||
ScrollArea::vertical() | ||
.stick_to_right() | ||
.auto_shrink([false, true]) | ||
.show(ui, |ui| { | ||
for backup_path in available_backups { | ||
if ui | ||
.button(backup_path.to_string_lossy().to_string()) | ||
.clicked() | ||
{ | ||
//Restore | ||
backup_shortcuts(&self.settings.steam); | ||
if restore_backup(&self.settings.steam, backup_path.as_path()) { | ||
self.backup_state.last_restore = Some(backup_path.clone()); | ||
} | ||
} | ||
} | ||
}); | ||
} | ||
|
||
|
||
} | ||
} | ||
|
||
pub fn restore_backup(steam_settings: &SteamSettings, shortcut_path: &Path) -> bool { | ||
let file_name = shortcut_path.file_name().unwrap(); | ||
let paths = get_shortcuts_paths(steam_settings); | ||
if let Ok(paths) = paths { | ||
for user in paths { | ||
if let Some(user_shortcut_path) = user.shortcut_path { | ||
if file_name.to_string_lossy().starts_with(&user.user_id) { | ||
std::fs::copy(shortcut_path, Path::new(&user_shortcut_path)).unwrap(); | ||
println!("Restored shortcut to path : {}", user_shortcut_path); | ||
return true; | ||
} | ||
} | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
pub fn load_backups() -> Vec<PathBuf> { | ||
let backup_folder = get_backups_flder(); | ||
let files = std::fs::read_dir(&backup_folder); | ||
let mut result = vec![]; | ||
if let Ok(files) = files { | ||
for file in files { | ||
if let Ok(file) = file { | ||
if file | ||
.path() | ||
.extension() | ||
.unwrap_or_default() | ||
.to_string_lossy() | ||
== "vdf" | ||
{ | ||
result.push(file.path().to_path_buf()); | ||
} | ||
} | ||
} | ||
} | ||
result.sort(); | ||
result.reverse(); | ||
return result; | ||
} | ||
|
||
pub fn backup_shortcuts(steam_settings: &SteamSettings) { | ||
let backup_folder = get_backups_flder(); | ||
let paths = get_shortcuts_paths(&steam_settings); | ||
let date = Local::now(); | ||
let date_string = date.format("%Y-%m-%d-%H-%M-%S"); | ||
if let Ok(user_infos) = paths { | ||
for user_info in user_infos { | ||
if let Some(shortcut_path) = user_info.shortcut_path { | ||
let new_path = backup_folder.join(format!( | ||
"{}-{}-shortcuts.vdf", | ||
user_info.user_id, date_string | ||
)); | ||
println!("Backed up shortcut at: {:?}", new_path); | ||
std::fs::copy(&shortcut_path, &new_path).unwrap(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.