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; }