Fix pre-allocation in CDownloadQueue::CopyFileList (upstream git commit f8f0eca00153b508831fce03c385fb2fb1c8ae66) Don't log a critical line on startup if statistics.dat is missing (upstream git commit 2de1d5fa97de56625459362cc6ccfd94dbf1c044) Less writing of known files list during hashing (every 3000MB instead of 300): files have become larger and hashing faster. (upstream git commit f9b504a11ba7fabde6c7a63184edeeeb15ec7f66)
42 lines
1.2 KiB
Plaintext
42 lines
1.2 KiB
Plaintext
$OpenBSD: patch-src_Statistics_cpp,v 1.2 2013/11/25 11:55:13 dcoppa Exp $
|
|
|
|
Fix crash on truncated statistics.dat
|
|
(upstream git commit 5e3682f7efed13eb52e4358a2d91b0e381334120)
|
|
|
|
Don't log a critical line on startup if statistics.dat is missing
|
|
(upstream git commit 2de1d5fa97de56625459362cc6ccfd94dbf1c044)
|
|
|
|
--- src/Statistics.cpp.orig Mon Jun 13 10:50:25 2011
|
|
+++ src/Statistics.cpp Mon Nov 25 11:53:49 2013
|
|
@@ -25,6 +25,7 @@
|
|
//
|
|
|
|
#include "Statistics.h" // Interface declarations
|
|
+#include "Logger.h"
|
|
|
|
#include <protocol/ed2k/ClientSoftware.h>
|
|
|
|
@@ -311,12 +312,17 @@ void CStatistics::Load()
|
|
|
|
s_totalSent = 0;
|
|
s_totalReceived = 0;
|
|
- if (f.Open(JoinPaths(theApp->ConfigDir, wxT("statistics.dat")))) {
|
|
- uint8_t version = f.ReadUInt8();
|
|
- if (version == 0) {
|
|
- s_totalSent = f.ReadUInt64();
|
|
- s_totalReceived = f.ReadUInt64();
|
|
+ try {
|
|
+ CPath path(JoinPaths(theApp->ConfigDir, wxT("statistics.dat")));
|
|
+ if (path.FileExists() && f.Open(path)) {
|
|
+ uint8_t version = f.ReadUInt8();
|
|
+ if (version == 0) {
|
|
+ s_totalSent = f.ReadUInt64();
|
|
+ s_totalReceived = f.ReadUInt64();
|
|
+ }
|
|
}
|
|
+ } catch (CSafeIOException e) {
|
|
+ AddLogLineN(e.what());
|
|
}
|
|
|
|
// Load old values from config
|