Skip to content

Commit

Permalink
Rollback put-fun to the previous code
Browse files Browse the repository at this point in the history
  • Loading branch information
yosukehara committed Jun 16, 2015
1 parent 3b4aad8 commit 5770d2e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 30 deletions.
29 changes: 16 additions & 13 deletions src/leo_object_storage_haystack.erl
Original file line number Diff line number Diff line change
Expand Up @@ -578,19 +578,22 @@ put_fun_2(MetaDBId, StorageInfo, #?OBJECT{key = Key,
end,
Object_1 = Object#?OBJECT{ksize = byte_size(Key),
checksum = Checksum_1},
%% @TODO:
case Timestamp =< 0 of
true ->
?debugVal([{key, Key},
{timestamp, Timestamp},
{del, DelFlag},
{cause, "Not set timestamp correctly"}
]);
false ->
void
end,
Needle = create_needle(Object_1),
Metadata = leo_object_storage_transformer:object_to_metadata(Object_1),
Object_2 = case Timestamp =< 0 of
true ->
error_logger:error_msg("~p,~p,~p,~p~n",
[{module, ?MODULE_STRING},
{function, "put_fun_2/3"},
{line, ?LINE}, {body, [{key, Key},
{del, DelFlag},
{timestamp, Timestamp},
{cause, "Not set timestamp correctly"}
]}]),
Object_1#?OBJECT{timestamp = leo_date:now()};
false ->
Object_1
end,
Needle = create_needle(Object_2),
Metadata = leo_object_storage_transformer:object_to_metadata(Object_2),
put_fun_3(MetaDBId, StorageInfo, Needle, Metadata).

%% @private
Expand Down
29 changes: 12 additions & 17 deletions src/leo_object_storage_transformer.erl
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,6 @@ header_bin_to_metadata(Bin) ->
_:?BLEN_BUF >> = Bin,
Timestamp = case catch calendar:datetime_to_gregorian_seconds(
{{Year, Month, Day}, {Hour, Min, Second}}) of
{'EXIT',_} when Year == 0, Month == 0, Day == 0,
Hour == 0, Min == 0, Second == 0 ->
-1;
{'EXIT',_} ->
0;
Val when Val < 63113904000;
Expand All @@ -274,22 +271,20 @@ header_bin_to_metadata(Bin) ->
Val ->
Val
end,
Metadata_1 = #?METADATA{addr_id = AddrId,
ksize = KSize,
msize = MSize,
dsize = DSize,
csize = CSize,
cnumber = CNum,
cindex = CIndex,
offset = Offset,
clock = Clock,
checksum = Checksum,
del = Del},
case (Timestamp /= 0) of
true ->
Metadata_1#?METADATA{timestamp = Timestamp};
false when Timestamp == -1 ->
Metadata_1#?METADATA{timestamp = 0};
#?METADATA{addr_id = AddrId,
ksize = KSize,
msize = MSize,
dsize = DSize,
csize = CSize,
cnumber = CNum,
cindex = CIndex,
offset = Offset,
clock = Clock,
checksum = Checksum,
timestamp = Timestamp,
del = Del};
false ->
{error, {invalid_format, unexpected_time_format}}
end
Expand Down

0 comments on commit 5770d2e

Please sign in to comment.