Skip to content

Commit

Permalink
Closes DistributedNonsense/CorrugatedIron #30
Browse files Browse the repository at this point in the history
Removed calls in CorrugatedIron to update LastModified on saves
Updated unit tests.
  • Loading branch information
peschkaj committed Nov 18, 2011
1 parent ceed5e7 commit ba920d8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 18 deletions.
4 changes: 2 additions & 2 deletions CorrugatedIron.Tests.Live/GeneralIntegrationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -490,14 +490,14 @@ public void DeleteBucketDeletesAllKeysInABucketAsynchronously()
public void LastModifiedShouldChangeAfterAPutRequest()
{
var o = new RiakObject(TestBucket, "1234", new { value = 1234 });
Client.Put(o);
o = Client.Put(o).Value;

var lm2 = o.LastModified;
var lmu2 = o.LastModifiedUsec;

Thread.Sleep(500);
o.SetObject(new { value = 12345 });
Client.Put(o);
o = Client.Put(o).Value;

var lm3 = o.LastModified;
var lmu3 = o.LastModifiedUsec;
Expand Down
16 changes: 0 additions & 16 deletions CorrugatedIron/Models/RiakObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,6 @@ internal RiakObject(string bucket, string key, ICollection<RpbContent> contents,

internal RpbPutReq ToMessage()
{
UpdateLastModified();

var message = new RpbPutReq
{
Bucket = Bucket.ToRiakString(),
Expand All @@ -269,8 +267,6 @@ internal RpbPutReq ToMessage()
VTag = VTag.ToRiakString(),
UserMeta = UserMetaData.Select(kv => new RpbPair { Key = kv.Key.ToRiakString(), Value = kv.Value.ToRiakString() }).ToList(),
Indexes = Indexes.Select(kv => new RpbPair { Key = kv.Key.ToRiakString(), Value = kv.Value.ToRiakString() }).ToList(),
LastMod = LastModified,
LastModUSecs = LastModifiedUsec,
Links = Links.Select(l => l.ToMessage()).ToList()
}
};
Expand All @@ -295,18 +291,6 @@ public override bool Equals(object obj)
return Equals((RiakObject)obj);
}

private void UpdateLastModified()
{
if(HasChanged)
{
var t = DateTime.UtcNow - new DateTime(1970, 1, 1);
var ms = (ulong)Math.Round(t.TotalMilliseconds);

LastModified = (uint)(ms / 1000u);
LastModifiedUsec = (uint)((ms - LastModified * 1000u) * 100u);
}
}

public bool Equals(RiakObject other)
{
if(ReferenceEquals(null, other))
Expand Down

0 comments on commit ba920d8

Please sign in to comment.