mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-10-26 19:01:56 -04:00
Rework policies to return branches rather than path strings
This commit is contained in:
parent
7e084ea7db
commit
86b50d2d4e
86 changed files with 1259 additions and 3088 deletions
|
|
@ -32,26 +32,6 @@ using std::vector;
|
|||
|
||||
namespace l
|
||||
{
|
||||
static
|
||||
int
|
||||
get_error(const PolicyRV &prv_,
|
||||
const string &basepath_)
|
||||
{
|
||||
for(int i = 0, ei = prv_.success.size(); i < ei; i++)
|
||||
{
|
||||
if(prv_.success[i].basepath == basepath_)
|
||||
return prv_.success[i].rv;
|
||||
}
|
||||
|
||||
for(int i = 0, ei = prv_.error.size(); i < ei; i++)
|
||||
{
|
||||
if(prv_.error[i].basepath == basepath_)
|
||||
return prv_.error[i].rv;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
removexattr_loop_core(const string &basepath_,
|
||||
|
|
@ -71,14 +51,14 @@ namespace l
|
|||
|
||||
static
|
||||
void
|
||||
removexattr_loop(const vector<string> &basepaths_,
|
||||
const char *fusepath_,
|
||||
const char *attrname_,
|
||||
PolicyRV *prv_)
|
||||
removexattr_loop(const std::vector<Branch*> &branches_,
|
||||
const char *fusepath_,
|
||||
const char *attrname_,
|
||||
PolicyRV *prv_)
|
||||
{
|
||||
for(size_t i = 0, ei = basepaths_.size(); i != ei; i++)
|
||||
for(auto &branch : branches_)
|
||||
{
|
||||
l::removexattr_loop_core(basepaths_[i],fusepath_,attrname_,prv_);
|
||||
l::removexattr_loop_core(branch->path,fusepath_,attrname_,prv_);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -86,30 +66,30 @@ namespace l
|
|||
int
|
||||
removexattr(const Policy::Action &actionFunc_,
|
||||
const Policy::Search &searchFunc_,
|
||||
const Branches &branches_,
|
||||
const Branches &ibranches_,
|
||||
const char *fusepath_,
|
||||
const char *attrname_)
|
||||
{
|
||||
int rv;
|
||||
PolicyRV prv;
|
||||
vector<string> basepaths;
|
||||
std::vector<Branch*> obranches;
|
||||
|
||||
rv = actionFunc_(branches_,fusepath_,&basepaths);
|
||||
rv = actionFunc_(ibranches_,fusepath_,obranches);
|
||||
if(rv == -1)
|
||||
return -errno;
|
||||
|
||||
l::removexattr_loop(basepaths,fusepath_,attrname_,&prv);
|
||||
if(prv.error.empty())
|
||||
l::removexattr_loop(obranches,fusepath_,attrname_,&prv);
|
||||
if(prv.errors.empty())
|
||||
return 0;
|
||||
if(prv.success.empty())
|
||||
return prv.error[0].rv;
|
||||
if(prv.successes.empty())
|
||||
return prv.errors[0].rv;
|
||||
|
||||
basepaths.clear();
|
||||
rv = searchFunc_(branches_,fusepath_,&basepaths);
|
||||
obranches.clear();
|
||||
rv = searchFunc_(ibranches_,fusepath_,obranches);
|
||||
if(rv == -1)
|
||||
return -errno;
|
||||
|
||||
return l::get_error(prv,basepaths[0]);
|
||||
return prv.get_error(obranches[0]->path);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue