summaryrefslogtreecommitdiffstats
path: root/src/network
diff options
context:
space:
mode:
authorNikita Krupenko <krnekit@gmail.com>2014-06-13 20:04:16 +0300
committerNikita Krupenko <krnekit@gmail.com>2014-07-17 11:28:18 +0200
commitfeb1afc78290433b0c22b1b3f6d65542eeb5b957 (patch)
tree7f6b865c09210bc22a7bb4690ab8dd273f08bfad /src/network
parent6186dd857176fd119e0c6e0732238e0aa20c4ce4 (diff)
Added stream version into network cache file format
At the moment, there is no stream information in the cache file. This can lead to a problem when current stream version differs from version cache file written with. As an example, if file written with Qt 5.1.1, QTimeDate in the metadata stored as 13-bytes value, but Qt 5.2 and later can read additional 4 bytes which breaks following data, leading to network request just hangs forever. Adding stream version fixes this problem. As cache format changed, cache version bumped. Task-number: QTBUG-36219 Change-Id: I467d8c9fda82bcf9302192f51e7a00d2f6a9ff66 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
Diffstat (limited to 'src/network')
-rw-r--r--src/network/access/qnetworkdiskcache.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/network/access/qnetworkdiskcache.cpp b/src/network/access/qnetworkdiskcache.cpp
index a1cbd9364e..86a3b20a9c 100644
--- a/src/network/access/qnetworkdiskcache.cpp
+++ b/src/network/access/qnetworkdiskcache.cpp
@@ -56,7 +56,7 @@
#define CACHE_POSTFIX QLatin1String(".d")
#define PREPARED_SLASH QLatin1String("prepared/")
-#define CACHE_VERSION 7
+#define CACHE_VERSION 8
#define DATA_DIR QLatin1String("data")
#define MAX_COMPRESSION_SIZE (1024 * 1024 * 3)
@@ -686,6 +686,7 @@ void QCacheItem::writeHeader(QFile *device) const
out << qint32(CacheMagic);
out << qint32(CurrentCacheVersion);
+ out << static_cast<qint32>(out.version());
out << metaData;
bool compressed = canCompress();
out << compressed;
@@ -719,6 +720,13 @@ bool QCacheItem::read(QFile *device, bool readData)
if (v != CurrentCacheVersion)
return false;
+ qint32 streamVersion;
+ in >> streamVersion;
+ // Default stream version is also the highest we can handle
+ if (streamVersion > in.version())
+ return false;
+ in.setVersion(streamVersion);
+
bool compressed;
QByteArray dataBA;
in >> metaData;