12 "delimiter between json records, if not \\0 or \\n", 0);
14 "key for path data in json input",
"path");
16 "key for operation in json input",
"event");
18 "key for timestamp in json input",
"eventTime");
20 "format for timestamp in json input, like strptime",
21 "%Y-%m-%d_%H:%M:%S%z");
23 "offset of timestamp", copyRequest::clock_type::duration::zero());
25 "key for rename cookie in json input",
"cookie");
27 "operation value triggering a copy",
"IN_CLOSE_WRITE");
29 "operation value triggering a delete",
"IN_DELETE");
31 "operation value triggering a move from",
"IN_MOVED_FROM");
33 "operation value triggering a move to",
"IN_MOVED_TO");
35 "regegx that must be matched if set to consider a path");
44 while (lineGetter.
active()) {
55 if (line.
line().empty()) {
58 std::stringstream buffer(line.
line());
69 const std::string& key) {
70 auto jsonValue = json.find(key.c_str(), key.c_str() + key.size());
71 if (jsonValue ==
nullptr) {
74 return jsonValue->asString();
79 if (srcPath.empty()) {
86 if (operation.empty()) {
90 copyRequest::clock_type::time_point timestamp;
94 timestamp = copyRequest::clock_type::time_point(std::chrono::duration_cast<copyRequest::clock_type::duration>(std::chrono::duration<double>(jsonTimestamp->asDouble())));
97 strptime(jsonTimestamp->asCString(),
timestampFormat.c_str(), &tmStruct);
98 timestamp = copyRequest::clock_type::time_point(std::chrono::duration_cast<copyRequest::clock_type::duration>(std::chrono::duration<double>(mktime(&tmStruct)))) +
timestampOffset;
100 auto tzStart=jsonTimestamp->asString().find_last_of(
"+-");
101 if (tzStart != std::string::npos) {
102 auto offset = std::stoi(jsonTimestamp->asString().substr(tzStart));
103 timestamp -= std::chrono::hours(offset/100);
104 timestamp -= std::chrono::minutes(offset%100);
109 timestamp = copyRequest::clock_type::now();
115 handleOther(srcPath, dstPath, mapEntry, timestamp,
false);
117 handleOther(srcPath, dstPath, mapEntry, timestamp,
true);
120 if (jsonCookie.empty()) {
131 if (partner !=
nullptr) {
159 event->dstPath,
"found stale moveFrom, cookie", event->cookie,
160 "from", std::fixed, event->timestamp);
162 handleOther(event->srcPath, event->dstPath, event->mapEntry, event->timestamp,
true);
166 event->dstPath,
"found stale moveTo, cookie", event->cookie,
167 "from", std::fixed, event->timestamp);
168 handleOther(event->srcPath, event->dstPath, event->mapEntry, event->timestamp,
false);