Opened 18 years ago
Closed 18 years ago
#3957 closed defect (fixed)
Missing comma in disk space sizes greater than 1000 MB
| Reported by: | anonymous | Owned by: | Isaac Richards |
|---|---|---|---|
| Priority: | trivial | Milestone: | unknown |
| Component: | mythtv | Version: | head |
| Severity: | low | Keywords: | |
| Cc: | Ticket locked: | no |
Description
Mythweb is missing a comma when you have more 1000 MB of total disk space:
Total Disk Space:
- Total Space: 1054,294 MB
Should read 1,054,294 MB.
Attachments (1)
Change History (7)
comment:1 by , 18 years ago
| Component: | mythweb → mythtv |
|---|---|
| Owner: | changed from to |
comment:2 by , 18 years ago
Following code in programs/mythbackend/httpstatus.cpp is the culprit:
os << " <li>Total Space: ";
sRep.sprintf( "%d,%03d MB ", (nTotal) / 1000, (nTotal) % 1000);
os << sRep << "</li>\r\n";
os << " <li>Space Used: ";
sRep.sprintf( "%d,%03d MB ", (nUsed) / 1000, (nUsed) % 1000);
os << sRep << "</li>\r\n";
os << " <li>Space Free: ";
sRep.sprintf( "%d,%03d MB ", (nFree) / 1000, (nFree) % 1000);
Note that the code currently will output bad strings like 0,123MB for small numbers. If there isn't an easy way to do this in Qt, we should probably add a nice formatter in libs/libmyth/util.cpp ?
comment:3 by , 18 years ago
This patch fixes it for me. I doubt that this is where you guys would like the formatting code to end up, but, I thought I'd throw it in anyway.
-- Joe Ripley vitaminjoe@…
by , 18 years ago
| Attachment: | 3957_diff.patch added |
|---|
Patch mythbackend to properly add commas to numbers > 1000 for mythweb status page
comment:4 by , 18 years ago
Thanks for the patch, Joe.
1) Here is an even simpler one:
Index: httpstatus.cpp
===================================================================
--- httpstatus.cpp (revision 14490)
+++ httpstatus.cpp (working copy)
@@ -21,6 +21,7 @@
#include <qfile.h>
#include <qregexp.h>
#include <qbuffer.h>
+#include <qlocale.h>
#include <math.h>
#include "../../config.h"
@@ -1132,16 +1133,17 @@
os << nDirs << "</li>\r\n";
}
+ QLocale c(QLocale::C);
os << " <li>Total Space: ";
- sRep.sprintf( "%d,%03d MB ", (nTotal) / 1000, (nTotal) % 1000);
+ sRep = c.toString(nTotal) + " MB ";
os << sRep << "</li>\r\n";
os << " <li>Space Used: ";
- sRep.sprintf( "%d,%03d MB ", (nUsed) / 1000, (nUsed) % 1000);
+ sRep = c.toString(nUsed) + " MB ";
os << sRep << "</li>\r\n";
os << " <li>Space Free: ";
- sRep.sprintf( "%d,%03d MB ", (nFree) / 1000, (nFree) % 1000);
+ sRep = c.toString(nFree) + " MB ";
os << sRep << "</li>\r\n";
os << " </ul>\r\n"
2) I suspect we shouldn't be anchoring this in MB. It won't be long before most users have Terabytes, and I think a signed long long can represent 1.3 Petabytes. Maybe a generic SI prefix routine?
comment:5 by , 18 years ago
Much cleaner! I think I need to review the Qt API. Thanks nigel!
-- Joe Ripley vitaminjoe@…

Mythweb should show sizes in GB.. The only place that it does, is on the recordings page. If you're looking at the "backend status" page, that's a direct passthrough from the backend.