mirror of
https://github.com/Cyrix126/gupaxx.git
synced 2024-12-22 22:59:27 +00:00
Status Submenu: add Unix [750] perms for Gupax data folder
This commit is contained in:
parent
553081d2aa
commit
08cda22e68
3 changed files with 34 additions and 8 deletions
|
@ -179,8 +179,8 @@ pub const STATUS_SUBMENU_PAYOUT: &str = "The total amount of payouts received
|
|||
pub const STATUS_SUBMENU_XMR: &str = "The total of XMR mined via P2Pool across all time";
|
||||
pub const STATUS_SUBMENU_LATEST: &str = "Sort the logs latest to oldest";
|
||||
pub const STATUS_SUBMENU_OLDEST: &str = "Sort the logs oldest to latest";
|
||||
pub const STATUS_SUBMENU_BIGGEST: &str = "Sort the logs by biggest payouts first";
|
||||
pub const STATUS_SUBMENU_SMALLEST: &str = "Sort the logs by smallest payouts first";
|
||||
pub const STATUS_SUBMENU_BIGGEST: &str = "Sort the logs by the biggest payouts first";
|
||||
pub const STATUS_SUBMENU_SMALLEST: &str = "Sort the logs by the smallest payouts first";
|
||||
|
||||
// Gupax
|
||||
pub const GUPAX_UPDATE: &str = "Check for updates on Gupax, P2Pool, and XMRig via GitHub's API and upgrade automatically";
|
||||
|
|
28
src/disk.rs
28
src/disk.rs
|
@ -51,6 +51,8 @@ use crate::{
|
|||
P2poolRegex,
|
||||
};
|
||||
use log::*;
|
||||
#[cfg(target_family = "unix")]
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
|
||||
//---------------------------------------------------------------------------------------------------- Const
|
||||
// State file
|
||||
|
@ -133,6 +135,26 @@ pub fn get_gupax_data_path() -> Result<PathBuf, TomlError> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn set_unix_750_perms(path: &PathBuf) -> Result<(), TomlError> {
|
||||
#[cfg(target_os = "windows")]
|
||||
return Ok(());
|
||||
#[cfg(target_family = "unix")]
|
||||
match fs::set_permissions(path, fs::Permissions::from_mode(0o750)) {
|
||||
Ok(_) => { info!("OS | Unix 750 permissions on path [{}] ... OK", path.display()); Ok(()) },
|
||||
Err(e) => { error!("OS | Unix 750 permissions on path [{}] ... FAIL ... {}", path.display(), e); Err(TomlError::Io(e)) },
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_unix_660_perms(path: &PathBuf) -> Result<(), TomlError> {
|
||||
#[cfg(target_os = "windows")]
|
||||
return Ok(());
|
||||
#[cfg(target_family = "unix")]
|
||||
match fs::set_permissions(path, fs::Permissions::from_mode(0o660)) {
|
||||
Ok(_) => { info!("OS | Unix 660 permissions on path [{}] ... OK", path.display()); Ok(()) },
|
||||
Err(e) => { error!("OS | Unix 660 permissions on path [{}] ... FAIL ... {}", path.display(), e); Err(TomlError::Io(e)) },
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_gupax_p2pool_path(os_data_path: &PathBuf) -> PathBuf {
|
||||
let mut gupax_p2pool_dir = os_data_path.clone();
|
||||
gupax_p2pool_dir.push(GUPAX_P2POOL_API_DIRECTORY);
|
||||
|
@ -142,9 +164,10 @@ pub fn get_gupax_p2pool_path(os_data_path: &PathBuf) -> PathBuf {
|
|||
pub fn create_gupax_dir(path: &PathBuf) -> Result<(), TomlError> {
|
||||
// Create Gupax directory
|
||||
match fs::create_dir_all(path) {
|
||||
Ok(_) => { info!("OS | Create data path ... OK"); Ok(()) },
|
||||
Err(e) => { error!("OS | Create data path ... FAIL ... {}", e); Err(TomlError::Io(e)) },
|
||||
Ok(_) => info!("OS | Create data path ... OK"),
|
||||
Err(e) => { error!("OS | Create data path ... FAIL ... {}", e); return Err(TomlError::Io(e)) },
|
||||
}
|
||||
set_unix_750_perms(&path)
|
||||
}
|
||||
|
||||
pub fn create_gupax_p2pool_dir(path: &PathBuf) -> Result<(), TomlError> {
|
||||
|
@ -1156,6 +1179,7 @@ mod test {
|
|||
|
||||
[status]
|
||||
submenu = "P2pool"
|
||||
payout_view = "Oldest"
|
||||
monero_enabled = true
|
||||
manual_hash = false
|
||||
hashrate = 1241.23
|
||||
|
|
|
@ -142,17 +142,19 @@ pub fn show(&mut self, sys: &Arc<Mutex<Sys>>, p2pool_api: &Arc<Mutex<PubP2poolAp
|
|||
ui.add_sized([width, text], Label::new(RichText::new(format!("Total XMR: {}", api.xmr)).underline().color(LIGHT_GRAY))).on_hover_text(STATUS_SUBMENU_XMR);
|
||||
let width = width / 4.0;
|
||||
ui.separator();
|
||||
if ui.add_sized([width, text], SelectableLabel::new(self.payout_view == PayoutView::Latest, "Latest")).on_hover_text(STATUS_SUBMENU_LATEST).clicked() { self.payout_view = PayoutView::Latest; }
|
||||
if ui.add_sized([width, text], SelectableLabel::new(self.payout_view == PayoutView::Latest, "Latest")).on_hover_text(STATUS_SUBMENU_LATEST).clicked() {
|
||||
self.payout_view = PayoutView::Latest;
|
||||
}
|
||||
ui.separator();
|
||||
if ui.add_sized([width, text], SelectableLabel::new(self.payout_view == PayoutView::Oldest, "Oldest")).on_hover_text(STATUS_SUBMENU_OLDEST).clicked() { self.payout_view = PayoutView::Oldest; }
|
||||
if ui.add_sized([width, text], SelectableLabel::new(self.payout_view == PayoutView::Oldest, "Oldest")).on_hover_text(STATUS_SUBMENU_OLDEST).clicked() {
|
||||
self.payout_view = PayoutView::Oldest;
|
||||
}
|
||||
ui.separator();
|
||||
if ui.add_sized([width, text], SelectableLabel::new(self.payout_view == PayoutView::Biggest, "Biggest")).on_hover_text(STATUS_SUBMENU_BIGGEST).clicked() {
|
||||
api.update_payout_high();
|
||||
self.payout_view = PayoutView::Biggest;
|
||||
}
|
||||
ui.separator();
|
||||
if ui.add_sized([width, text], SelectableLabel::new(self.payout_view == PayoutView::Smallest, "Smallest")).on_hover_text(STATUS_SUBMENU_SMALLEST).clicked() {
|
||||
api.update_payout_low();
|
||||
self.payout_view = PayoutView::Smallest;
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue