summaryrefslogtreecommitdiff
path: root/ept/debtags/maint/debtagsindexer.h
blob: b702c88a20f67b7871cabd92eb63ccd868152c1a (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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#ifndef EPT_DEBTAGS_DEBTAGSINDEXER_H
#define EPT_DEBTAGS_DEBTAGSINDEXER_H

#include <ept/debtags/maint/sourcedir.h>
#include <string>

namespace ept {
namespace debtags {

class Vocabulary;

struct DebtagsIndexer
{
	Vocabulary& voc;

	SourceDir mainSource;
	SourceDir userSource;
	time_t ts_main_src;
	time_t ts_user_src;
	time_t ts_main_tag;
	time_t ts_main_idx;
	time_t ts_user_tag;
	time_t ts_user_idx;

	time_t sourceTimestamp() const
	{
		time_t res = ts_main_src;
		if (ts_user_src > res) res = ts_user_src;
		return res;
	}
	bool needsRebuild() const;
	bool rebuild(const std::string& tagfname, const std::string& idxfname);
	bool rebuildIfNeeded();
	bool getUpToDateTagdb(std::string& tagfname, std::string& idxfname);

	bool userIndexIsRedundant() const;
	bool deleteRedundantUserIndex();

	void rescan();

	DebtagsIndexer(Vocabulary& voc);

	static bool obtainWorkingDebtags(Vocabulary& voc, std::string& tagfname, std::string& idxfname);
};


}
}

// vim:set ts=4 sw=4:
#endif