Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ Here is the matrix of deployed services:
| | Gitea | 3000 (Localhost) | `http://localhost:3000` | Self-hosted Git |
| | Roundcube | 8090 (Localhost) | `http://localhost:8090` | Webmail |
| | Mailserver | 25, 143, 587, 993 | - | Full Mail Server |
| | Syncthing | 8384 (Localhost), 22000 | `http://localhost:8384` | File Synchronization |
| | Syncthing | 8384 (Localhost), 22000, 21027 (UDP) | `http://localhost:8384` | File Synchronization |

---

Expand Down Expand Up @@ -328,7 +328,7 @@ Voici la matrice des services déployés :
| | Gitea | 3000 (Localhost) | `http://localhost:3000` | Self-hosted Git |
| | Roundcube | 8090 (Localhost) | `http://localhost:8090` | Webmail |
| | Mailserver | 25, 143, 587, 993 | - | Full Mail Server |
| | Syncthing | 8384 (Localhost), 22000 | `http://localhost:8384` | Synchronisation de Fichiers |
| | Syncthing | 8384 (Localhost), 22000, 21027 (UDP) | `http://localhost:8384` | Synchronisation de Fichiers |

---

Expand Down
1 change: 1 addition & 0 deletions server_manager/src/core/hardware.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ impl HardwareInfo {
sys.refresh_memory();
sys.refresh_cpu();
sys.refresh_disks_list();
sys.refresh_disks();

let total_memory = sys.total_memory(); // Bytes
let ram_gb = total_memory / 1024 / 1024 / 1024;
Expand Down
81 changes: 52 additions & 29 deletions server_manager/src/interface/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -627,21 +627,32 @@ async fn add_user_handler(State(state): State<SharedState>, session: Session, Fo
};

let mut cache = state.users_cache.write().await;
let res = tokio::task::block_in_place(|| {
cache.manager.add_user(&payload.username, &payload.password, role_enum, quota_val)
});

if let Err(e) = res {
error!("Failed to add user: {}", e);
// In a real app we'd flash a message. Here just redirect.
} else {
info!("User {} added via Web UI by {}", payload.username, session_user.username);
// Update mtime to prevent unnecessary reload
let path = std::path::Path::new("users.yaml");
let fallback_path = std::path::Path::new("/opt/server_manager/users.yaml");
let file_path = if path.exists() { path } else { fallback_path };
if let Ok(m) = std::fs::metadata(file_path) {
cache.last_modified = m.modified().ok();
let mut manager_clone = cache.manager.clone();
let username_log = payload.username.clone();

let res = tokio::task::spawn_blocking(move || -> anyhow::Result<UserManager> {
manager_clone.add_user(&payload.username, &payload.password, role_enum, quota_val)?;
Ok(manager_clone)
})
.await;

match res {
Ok(Ok(updated_manager)) => {
cache.manager = updated_manager;
info!("User {} added via Web UI by {}", username_log, session_user.username);
// Update mtime to prevent unnecessary reload
let path = std::path::Path::new("users.yaml");
let fallback_path = std::path::Path::new("/opt/server_manager/users.yaml");
let file_path = if path.exists() { path } else { fallback_path };
if let Ok(m) = std::fs::metadata(file_path) {
cache.last_modified = m.modified().ok();
}
},
Ok(Err(e)) => {
error!("Failed to add user: {}", e);
},
Err(e) => {
error!("Task join error: {}", e);
}
}

Expand All @@ -659,20 +670,32 @@ async fn delete_user_handler(State(state): State<SharedState>, session: Session,
}

let mut cache = state.users_cache.write().await;
let res = tokio::task::block_in_place(|| {
cache.manager.delete_user(&username)
});

if let Err(e) = res {
error!("Failed to delete user: {}", e);
} else {
info!("User {} deleted via Web UI by {}", username, session_user.username);
// Update mtime to prevent unnecessary reload
let path = std::path::Path::new("users.yaml");
let fallback_path = std::path::Path::new("/opt/server_manager/users.yaml");
let file_path = if path.exists() { path } else { fallback_path };
if let Ok(m) = std::fs::metadata(file_path) {
cache.last_modified = m.modified().ok();
let mut manager_clone = cache.manager.clone();
let username_clone = username.clone();

let res = tokio::task::spawn_blocking(move || -> anyhow::Result<UserManager> {
manager_clone.delete_user(&username_clone)?;
Ok(manager_clone)
})
.await;

match res {
Ok(Ok(updated_manager)) => {
cache.manager = updated_manager;
info!("User {} deleted via Web UI by {}", username, session_user.username);
// Update mtime to prevent unnecessary reload
let path = std::path::Path::new("users.yaml");
let fallback_path = std::path::Path::new("/opt/server_manager/users.yaml");
let file_path = if path.exists() { path } else { fallback_path };
if let Ok(m) = std::fs::metadata(file_path) {
cache.last_modified = m.modified().ok();
}
},
Ok(Err(e)) => {
error!("Failed to delete user: {}", e);
},
Err(e) => {
error!("Task join error: {}", e);
}
}

Expand Down