void TakeStats() { std::string sectionName(section ? section->Name() : ""); for (const auto& kv : nukees) { if (kv.second.kBytes > 0) { db::stats::UploadDecr(kv.first, kv.second.kBytes, modTime, sectionName, kv.second.files); } } }
void TakeCredits() { if (multiplier == 0) return; std::string sectionName(section && section->SeparateCredits() ? section->Name() : ""); if (totalKBytes < config.NukeStyle().EmptyKBytes()) { TakeCreditsEmpty(sectionName); } else { TakeCreditsNotEmpty(sectionName); } }
void UpdateDatabase() { std::vector<db::nuking::Nukee> nukees2; for (const auto& kv : nukees) { nukees2.emplace_back(kv.first, kv.second.kBytes, kv.second.files, kv.second.credits); } // remove old unnuke data if dir was unnuked in past auto unnuke = LookupUnnuke(); if (unnuke) db::nuking::DelUnnuke(*unnuke); nuke = db::nuking::Nuke(path.ToString(), section ? section->Name() : "", reason, nukerUID, multiplier, isPercent, modTime, nukees2); db::nuking::AddNuke(*nuke); }
int UploadRatio(const acl::User& user, const fs::VirtualPath& path, const boost::optional<const cfg::Section&>& section) { if (section) { int ratio = user.SectionRatio(section->Name()); if (ratio >= 0) return ratio; } auto cc = acl::CreditCheck(user, path); if (cc && cc->Ratio() >= 0) return cc->Ratio(); if (section && section->Ratio() >= 0) return section->Ratio(); assert(user.DefaultRatio() >= 0); return user.DefaultRatio(); }
int DownloadRatio(const acl::User& user, const fs::VirtualPath& path, const boost::optional<const cfg::Section&>& section) { if (acl::path::FileAllowed<acl::path::Freefile>(user, path)) return 0; if (section) { int ratio = user.SectionRatio(section->Name()); if (ratio == 0) return 0; } auto cl = acl::CreditLoss(user, path); if (cl && cl->Ratio() >= 0) return cl->Ratio(); if (section && section->Ratio() >= 0) return section->Ratio(); assert(user.DefaultRatio() >= 0); return user.DefaultRatio() == 0 ? 0 : 1; }