Unverified Commit 96a0a8d7 authored by Tommaso Tocci's avatar Tommaso Tocci
Browse files

bugfix: do not append on Metadata::serialize()

Metadata::serialize() was appending result instead of ovewriting it.

The new approach is to make serialize function return a new constructed
string instead of accepting a string reference to fill.
parent 716334ce
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@ public:

    std::string to_KVentry() const;

    void serialize(std::string& s) const;
    std::string serialize() const;

    //Getter and Setter
    time_t atime() const;
+4 −4
Original line number Diff line number Diff line
@@ -127,12 +127,11 @@ void Metadata::update_ACM_time(bool a, bool c, bool m) {
 * @return
 */
std::string Metadata::to_KVentry() const {
    std::string val;
    this->serialize(val);
    return val;
    return serialize();
}

void Metadata::serialize(std::string& s) const {
std::string Metadata::serialize() const {
    std::string s;
    // The order is important. don't change.
    s += fmt::FormatInt(mode_).c_str(); // add mandatory mode
    s += dentry_val_delim + fmt::FormatInt(size_).c_str(); // add mandatory size
@@ -160,6 +159,7 @@ void Metadata::serialize(std::string& s) const {
    if (ADAFS_DATA->blocks_state()) {
        s += dentry_val_delim + fmt::FormatInt(blocks_).c_str();
    }
    return s;
}

//-------------------------------------------- GETTER/SETTER
+1 −1
Original line number Diff line number Diff line
@@ -116,7 +116,7 @@ bool MetadataMergeOperator::FullMergeV2(
    }

    md.size(fsize);
    md.serialize(merge_out->new_value);
    merge_out->new_value = md.serialize();
    return true;
}