Skip to content

Commit

Permalink
WalkHandler: pass Directory& to OnWalkAncient()
Browse files Browse the repository at this point in the history
We need to be able to take a reference (for asynchronous io_uring
calls).
  • Loading branch information
MaxKellermann committed Dec 5, 2024
1 parent 9059d8d commit 191d3bf
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/Cull.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ Cull::Start(FileDescriptor root_fd)
}

void
Cull::OnWalkAncient(FileDescriptor directory_fd,
Cull::OnWalkAncient(WalkDirectory &directory,
std::string_view filename) noexcept
{
CullFile(dev_cachefiles, directory_fd, filename);
CullFile(dev_cachefiles, directory.fd, filename);
}

void
Expand Down
2 changes: 1 addition & 1 deletion src/Cull.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ private:
void Finish() noexcept;

// virtual methods from WalkHandler
void OnWalkAncient(FileDescriptor directory_fd,
void OnWalkAncient(WalkDirectory &directory,
std::string_view filename) noexcept override;
void OnWalkFinished(WalkResult &&result) noexcept override;
};
3 changes: 2 additions & 1 deletion src/WHandler.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <string_view>

class FileDescriptor;
struct WalkDirectory;
struct WalkResult;

/**
Expand All @@ -18,7 +19,7 @@ public:
* An "ancient" file was found (that should be culled
* unconditionally).
*/
virtual void OnWalkAncient(FileDescriptor directory_fd,
virtual void OnWalkAncient(WalkDirectory &directory,
std::string_view filename) noexcept = 0;

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Walk.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ Walk::AddFile(WalkDirectory &parent, std::string &&name,
FileTime atime, uint_least64_t size)
{
if (atime < discard_older_than) {
handler.OnWalkAncient(parent.fd, name);
handler.OnWalkAncient(parent, name);
return;
}

Expand Down
2 changes: 1 addition & 1 deletion test/RunWalk.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ struct Instance final : WalkHandler {
}

// virtual methods from WalkHandler
void OnWalkAncient([[maybe_unused]] FileDescriptor directory_fd,
void OnWalkAncient([[maybe_unused]] WalkDirectory &directory,
std::string_view filename) noexcept override {
fmt::print("ancient {:?}\n", filename);
}
Expand Down

0 comments on commit 191d3bf

Please sign in to comment.