Commit 6c68de44 authored by Marc Vef's avatar Marc Vef
Browse files

Review and remove dead code

parent 779f54cc
Loading
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -64,6 +64,8 @@ private:
#endif
#endif

    void
    init_time();

public:
    Metadata() = default;
@@ -82,11 +84,12 @@ public:
    std::string
    serialize() const;

    // currently unused
    void
    init_ACM_time();
    update_atime_now();

    void
    update_ACM_time(bool a, bool c, bool m);
    update_mtime_now();

    // Getter and Setter
    time_t
+23 −18
Original line number Diff line number Diff line
@@ -69,22 +69,36 @@ gen_unique_id(const std::string& path) {
    return static_cast<uint16_t>(hash_value & 0xFFFF);
}

inline void
Metadata::init_time() {
    if constexpr(gkfs::config::metadata::use_ctime) {
        ctime_ = std::time(nullptr);
    }
    if constexpr(gkfs::config::metadata::use_mtime) {
        mtime_ = std::time(nullptr);
    }
    if constexpr(gkfs::config::metadata::use_atime) {
        atime_ = std::time(nullptr);
    }
}

Metadata::Metadata(const mode_t mode)
    : atime_(), mtime_(), ctime_(), mode_(mode), link_count_(0), size_(0),
      blocks_(0) {
    : mode_(mode), link_count_(0), size_(0), blocks_(0) {
    assert(S_ISDIR(mode_) || S_ISREG(mode_));
    init_time();
}

#ifdef HAS_SYMLINKS

Metadata::Metadata(const mode_t mode, const std::string& target_path)
    : atime_(), mtime_(), ctime_(), mode_(mode), link_count_(0), size_(0),
      blocks_(0), target_path_(target_path) {
    : mode_(mode), link_count_(0), size_(0), blocks_(0),
      target_path_(target_path) {
    assert(S_ISLNK(mode_) || S_ISDIR(mode_) || S_ISREG(mode_));
    // target_path should be there only if this is a link
    assert(target_path_.empty() || S_ISLNK(mode_));
    // target_path should be absolute
    assert(target_path_.empty() || target_path_[0] == '/');
    init_time();
}

#endif
@@ -205,23 +219,14 @@ Metadata::serialize() const {
}

void
Metadata::init_ACM_time() {
    std::time_t time;
    std::time(&time);
Metadata::update_atime_now() {
    auto time = std::time(nullptr);
    atime_ = time;
    mtime_ = time;
    ctime_ = time;
}

void
Metadata::update_ACM_time(bool a, bool c, bool m) {
    std::time_t time;
    std::time(&time);
    if(a)
        atime_ = time;
    if(c)
        ctime_ = time;
    if(m)
Metadata::update_mtime_now() {
    auto time = std::time(nullptr);
    mtime_ = time;
}

+1 −4
Original line number Diff line number Diff line
@@ -182,7 +182,7 @@ MetadataMergeOperator::FullMergeV2(const MergeOperationInput& merge_in,
        auto parameters = MergeOperand::get_params(serialized_op);

        if constexpr(gkfs::config::metadata::use_mtime) {
            md.mtime(std::time(nullptr));
            md.update_mtime_now();
        }

        if(operand_id == OperandID::increase_size) {
@@ -203,9 +203,6 @@ MetadataMergeOperator::FullMergeV2(const MergeOperationInput& merge_in,
            assert(op.size() < fsize); // we assume no concurrency here
            fsize = op.size();
        } else if(operand_id == OperandID::create) {
            if constexpr(gkfs::config::metadata::use_ctime) {
                md.ctime(std::time(nullptr));
            }
            continue;
        } else {
            throw ::runtime_error("Unrecognized merge operand ID: " +
+1 −1
Original line number Diff line number Diff line
@@ -76,7 +76,7 @@ create(const std::string& path, Metadata& md) {
        if(GKFS_DATA->ctime_state())
            md.ctime(time);
    }
    if(gkfs::config::metadata::create_exist_check) {
    if constexpr(gkfs::config::metadata::create_exist_check) {
        GKFS_DATA->mdb()->put_no_exist(path, md.serialize());
    } else {
        GKFS_DATA->mdb()->put(path, md.serialize());