File: expiration.h

package info (click to toggle)
apt-cacher-ng 2-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 2,032 kB
  • ctags: 1,705
  • sloc: cpp: 16,869; sh: 536; ansic: 404; perl: 377; makefile: 124
file content (65 lines) | stat: -rw-r--r-- 1,611 bytes parent folder | download | duplicates (2)
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#ifndef EXPIRATION_H_
#define EXPIRATION_H_

#include "cacheman.h"
#include <list>
#include <unordered_map>

namespace acng
{

// caching all relevant file identity data and helper flags in such entries
struct tDiskFileInfo
{
	time_t nLostAt =0;
	bool bNoHeaderCheck=false;
	// this adds a couple of procent overhead so it's negligible considering
	// hashing or traversing overhead of a detached solution
	tFingerprint fpr;
};

class expiration : public cacheman
{
public:
	// XXX: g++ 4.7 is not there yet... using tCacheOperation::tCacheOperation;
	inline expiration(const tRunParms& parms) : cacheman(parms) {};

protected:

	std::unordered_map<mstring,std::map<mstring,tDiskFileInfo>> m_trashFile2dir2Info;

	void RemoveAndStoreStatus(bool bPurgeNow);
	void LoadPreviousData(bool bForceInsert);

	// callback implementations
	virtual void Action() override;
	// for FileHandler
	virtual bool ProcessRegular(const mstring &sPath, const struct stat &) override;
	void HandlePkgEntry(const tRemoteFileInfo &entry);

	void LoadHints();

	void PurgeMaintLogs();

	void DropExceptionalVersions();

	std::ofstream m_damageList;
	bool m_bIncompleteIsDamaged = false, m_bScanVolatileContents = false;

	void MarkObsolete(cmstring&) override;
	tStrVec m_killBill;

	virtual bool _checkSolidHashOnDisk(cmstring& hexname, const tRemoteFileInfo &entry,
			cmstring& srcPrefix) override;
	virtual bool _QuickCheckSolidFileOnDisk(cmstring& /* sFilePathRel */) override;
private:
	int m_nPrevFailCount =0;
	bool CheckAndReportError();

	void HandleDamagedFiles();
	void ListExpiredFiles();
};

}

#endif /*EXPIRATION_H_*/