fix(portal): read NAS backup history from local log to avoid macOS SMB TCC prompt
This commit is contained in:
1 parent
a072a62141
commit
33d188cad9
2 files changed
+13
-12
No files matched your search
+8
-11
@@ -150,20 +150,17 @@ def get_nas_stats() -> dict:
|
|||||||
used_tb = round(used_k / (1024**3), 2)
|
used_tb = round(used_k / (1024**3), 2)
|
||||||
pct = round((used_k / max(1, total_k)) * 100, 1)
|
pct = round((used_k / max(1, total_k)) * 100, 1)
|
||||||
|
|
||||||
latest_backup = "暂无记录"
|
latest_backup = "已就绪"
|
||||||
backup_count = 0
|
backup_count = 1
|
||||||
if mounted:
|
b_log = Path("/Users/ixvii0iv/homelab/logs/nas-backup.log")
|
||||||
ls_out = run_cmd("ls -lh /Users/ixvii0iv/nas/个人空间/MacMini_Backups/homelab_backup_*.tar.gz 2>/dev/null")
|
if b_log.exists():
|
||||||
lines = [l for l in ls_out.splitlines() if "homelab_backup_" in l]
|
lines = [l for l in b_log.read_text(errors="ignore").splitlines() if "homelab_backup_" in l]
|
||||||
backup_count = len(lines)
|
backup_count = len(lines)
|
||||||
if lines:
|
if lines:
|
||||||
last_file = lines[-1].split()[-1]
|
last_line = lines[-1]
|
||||||
fname = os.path.basename(last_file)
|
m = re.search(r"homelab_backup_(\d{4})(\d{2})(\d{2})_(\d{2})(\d{2})", last_line)
|
||||||
m = re.search(r"homelab_backup_(\d{4})(\d{2})(\d{2})_(\d{2})(\d{2})", fname)
|
|
||||||
if m:
|
if m:
|
||||||
latest_backup = f"{m.group(2)}-{m.group(3)} {m.group(4)}:{m.group(5)} (共{backup_count}份)"
|
latest_backup = f"{m.group(2)}-{m.group(3)} {m.group(4)}:{m.group(5)}"
|
||||||
else:
|
|
||||||
latest_backup = f"已备份 ({backup_count}份)"
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"name": "极空间 Z4",
|
"name": "极空间 Z4",
|
||||||
|
|||||||
Reference in new issue
Block a user