mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-11-20 23:16:27 -05:00
Implement bespoke branch policies
Consolidate branch policy selection behind the BranchPolicy interfaces and update filesystem operations to use the bespoke policy implementations. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
parent
42ab831d97
commit
96d8232853
451 changed files with 18495 additions and 7562 deletions
70
src/func_statx_newest.cpp
Normal file
70
src/func_statx_newest.cpp
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
#include "func_statx_newest.hpp"
|
||||
|
||||
#include "fs_inode.hpp"
|
||||
#include "fs_statx.hpp"
|
||||
#include "symlinkify.hpp"
|
||||
#include "timespec_utils.hpp"
|
||||
|
||||
|
||||
std::string_view
|
||||
Func2::StatxNewest::name() const
|
||||
{
|
||||
return "newest";
|
||||
}
|
||||
|
||||
int
|
||||
Func2::StatxNewest::operator()(const Branches &branches_,
|
||||
const fs::path &fusepath_,
|
||||
const u32 flags_,
|
||||
const u32 mask_,
|
||||
struct fuse_statx *st_,
|
||||
const FollowSymlinksEnum follow_symlinks_,
|
||||
const bool symlinkify_,
|
||||
const s64 symlinkify_timeout_)
|
||||
{
|
||||
int rv;
|
||||
int err;
|
||||
fs::path fullpath;
|
||||
const Branch *newest_branch;
|
||||
|
||||
err = 0;
|
||||
newest_branch = nullptr;
|
||||
for(const auto &branch : branches_)
|
||||
{
|
||||
struct fuse_statx tmp_st;
|
||||
|
||||
fullpath = branch.path / fusepath_;
|
||||
rv = fs::statx(AT_FDCWD,
|
||||
fullpath,
|
||||
flags_|AT_SYMLINK_NOFOLLOW,
|
||||
mask_,
|
||||
&tmp_st,
|
||||
follow_symlinks_);
|
||||
if(rv < 0)
|
||||
{
|
||||
err = rv;
|
||||
continue;
|
||||
}
|
||||
|
||||
if(newest_branch && (st_->mtime > tmp_st.mtime))
|
||||
continue;
|
||||
|
||||
*st_ = tmp_st;
|
||||
newest_branch = &branch;
|
||||
}
|
||||
|
||||
if(!newest_branch)
|
||||
return err;
|
||||
|
||||
if(symlinkify_)
|
||||
{
|
||||
fullpath = newest_branch->path / fusepath_;
|
||||
symlinkify::convert_if_can_be_symlink(fullpath,
|
||||
st_,
|
||||
symlinkify_timeout_);
|
||||
}
|
||||
|
||||
fs::inode::calc(newest_branch->path,fusepath_,st_);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue