summaryrefslogtreecommitdiffstats
path: root/logic/net/HttpMetaCache.h
blob: 161483adcbe4b7e97e657b6a2ea09615689e073f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#pragma once
#include <QString>
#include <QSharedPointer>
#include <QMap>

struct MetaEntry
{
	QString base;
	QString path;
	QString md5sum;
	QString etag;
	quint64 last_changed_timestamp = 0;
};

typedef QSharedPointer<MetaEntry> MetaEntryPtr;

class HttpMetaCache
{
public:
	// supply path to the cache index file
	HttpMetaCache(QString path);
	~HttpMetaCache();
	MetaEntryPtr getEntryForResource(QString base, QString resource_path);
	void addEntry(QString base, QString resource_path, QString etag);
	void addBase(QString base, QString base_root);
private:
	void Save();
	void Load();
	struct EntryMap
	{
		QString base_path;
		QMap<QString, MetaEntryPtr> entry_list;
	};
	QMap<QString, EntryMap> m_entries;
	QString m_index_file;
};