Support multiple concurrent torrent copy operations
Update monitoring to handle multiple simultaneous torrent copy operations using the new directory-based marker structure. Changes: - Rename get_active_torrent_copy() to get_active_torrent_copies() - Read all marker files from /tmp/torrent-copy/ directory - Return Vec<String> instead of Option<String> for multiple copies - Display each active copy as separate sub-service - Unsanitize filenames by replacing _ with / This enables monitoring when multiple torrents finish simultaneously and are being copied in parallel to permanent storage.
This commit is contained in:
parent
d93260529b
commit
4a8cfbbde4
6
Cargo.lock
generated
6
Cargo.lock
generated
@ -279,7 +279,7 @@ checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d"
|
||||
|
||||
[[package]]
|
||||
name = "cm-dashboard"
|
||||
version = "0.1.257"
|
||||
version = "0.1.258"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"chrono",
|
||||
@ -301,7 +301,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "cm-dashboard-agent"
|
||||
version = "0.1.257"
|
||||
version = "0.1.258"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-trait",
|
||||
@ -325,7 +325,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "cm-dashboard-shared"
|
||||
version = "0.1.257"
|
||||
version = "0.1.258"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"serde",
|
||||
|
||||
@ -179,8 +179,8 @@ impl SystemdCollector {
|
||||
});
|
||||
}
|
||||
|
||||
// Add active torrent copy status
|
||||
if let Some(torrent_name) = self.get_active_torrent_copy() {
|
||||
// Add active torrent copy status for each copy operation
|
||||
for torrent_name in self.get_active_torrent_copies() {
|
||||
let metrics = Vec::new();
|
||||
|
||||
sub_services.push(SubServiceData {
|
||||
@ -1101,16 +1101,29 @@ impl SystemdCollector {
|
||||
Some((active_count, download_mbps, upload_mbps))
|
||||
}
|
||||
|
||||
/// Check if torrent copy script is actively running
|
||||
/// Returns: Some(torrent_name) if copy is in progress, None otherwise
|
||||
fn get_active_torrent_copy(&self) -> Option<String> {
|
||||
let marker_path = "/tmp/torrent-copy-active";
|
||||
/// Check for active torrent copy operations
|
||||
/// Returns: Vec of filenames currently being copied
|
||||
fn get_active_torrent_copies(&self) -> Vec<String> {
|
||||
let marker_dir = "/tmp/torrent-copy";
|
||||
let mut active_copies = Vec::new();
|
||||
|
||||
// Check if marker file exists and read torrent name
|
||||
std::fs::read_to_string(marker_path)
|
||||
.ok()
|
||||
.map(|content| content.trim().to_string())
|
||||
.filter(|name| !name.is_empty())
|
||||
// Read all marker files from directory
|
||||
if let Ok(entries) = std::fs::read_dir(marker_dir) {
|
||||
for entry in entries.flatten() {
|
||||
if let Ok(file_type) = entry.file_type() {
|
||||
if file_type.is_file() {
|
||||
// Filename is the marker (sanitized torrent name)
|
||||
if let Some(filename) = entry.file_name().to_str() {
|
||||
// Convert sanitized name back (replace _ with /)
|
||||
let display_name = filename.replace('_', "/");
|
||||
active_copies.push(display_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
active_copies
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user