Skip to content

Commit ddf1426

Browse files
authored
Fix CSV quoting for last_comment (#17)
Always quote and escape last_comment while keeping other fields unquoted Update README and CHANGELOG for the adjusted CSV format Bump version to 2.10.1
2 parents 038805f + b9042d1 commit ddf1426

3 files changed

Lines changed: 9 additions & 8 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# 📝 Changelog
22

3+
- 2.10.1
4+
- Always quote only the `last_comment` CSV field to avoid delimiter-related parsing issues (semicolon-separated).
35
- 2.10.0
46
- Add CSV reporting for full datastore scans (`--all-guests`), written atomically at the end with an ISO 8601 timestamp filename.
5-
- Include namespace path with VM/CT ID, latest snapshot comment, and unique chunk size in GiB (fixed precision) in the CSV output.
7+
- Include namespace path with VM/CT ID, latest snapshot comment (always quoted), and unique chunk size in GiB (fixed precision) in the CSV output.
68
- Allow selecting the CSV output directory via `--csv-dir` and the interactive Options menu.
79
- 2.9.0
810
- Add an optional `--show-comments` flag and corresponding interactive option to show a short label derived from the latest PBS snapshot comment next to each VM/CT in the per‑guest summary and interactive search‑path selector (best‑effort, using `proxmox-backup-debug api get /admin/datastore/<DATASTORE>/snapshots`).
@@ -21,4 +23,3 @@
2123
- Keep `--version` as pure version output again.
2224
- 2.7.1
2325
- Split version and update logic: `--version` prints version; `--check-updates` checks and offers updates.
24-
+

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ It calculates the **real disk space usage** of a specific **namespace**, **VM**,
99

1010
This allows accurate insights into space consumption per tenant or object — useful for chargeback, reporting, and storage optimization.
1111

12-
**Current version:** 2.10.0 (`./pbs_chunk_checker.py --version`)
12+
**Current version:** 2.10.1 (`./pbs_chunk_checker.py --version`)
1313

1414
See full changes in `CHANGELOG.md`.
1515

@@ -153,6 +153,7 @@ When running with `--all-guests`, the script writes a CSV report **after** the s
153153
- Output directory: current working directory by default, or via `--csv-dir` / the Options overlay
154154
- Separator: `;` (semicolon)
155155
- Columns: `namespace_path`, `last_comment`, `unique_size_gib`
156+
- The `last_comment` field is always quoted (other fields are not).
156157
- Size unit: GiB (1024^3 bytes), fixed 3-decimal precision
157158
- The CSV is written automically at the end so no partial file is left behind on errors
158159

pbs_chunk_checker.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,9 @@
1818
- Repository: https://github.com/VoltKraft/PBS_Chunk_Checker
1919
"""
2020

21-
__version__ = "2.10.0"
21+
__version__ = "2.10.1"
2222

2323
import argparse
24-
import csv
2524
import concurrent.futures as futures
2625
import hashlib
2726
import json
@@ -2236,10 +2235,10 @@ def _write_full_scan_csv(
22362235
tmp_path = Path(tmp_file.name)
22372236
try:
22382237
with tmp_file as handle:
2239-
writer = csv.writer(handle, delimiter=";")
2240-
writer.writerow(["namespace_path", "last_comment", "unique_size_gib"])
2238+
handle.write("namespace_path;last_comment;unique_size_gib\n")
22412239
for path_label, comment, unique_bytes in rows:
2242-
writer.writerow([path_label, comment, _bytes_to_gib(unique_bytes)])
2240+
escaped_comment = (comment or "").replace('"', '""')
2241+
handle.write(f'{path_label};"{escaped_comment}";{_bytes_to_gib(unique_bytes)}\n')
22432242
os.replace(tmp_path, final_path)
22442243
except Exception:
22452244
try:

0 commit comments

Comments
 (0)