From 788ecff32742c544907066e044aa6c6f101c72a4 Mon Sep 17 00:00:00 2001 From: deepakgarg Date: Thu, 26 Mar 2020 20:07:23 -0700 Subject: [PATCH 1/3] Fixes #996 pin expiry is updated if set in options --- cluster.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cluster.go b/cluster.go index 14ed4e8e..a56e83ec 100644 --- a/cluster.go +++ b/cluster.go @@ -1496,7 +1496,9 @@ func (c *Cluster) PinUpdate(ctx context.Context, from cid.Cid, to cid.Cid, opts if opts.Name != "" { existing.Name = opts.Name } - + if !opts.ExpireAt.IsZero() && opts.ExpireAt.After(time.Now()) { + existing.ExpireAt = opts.ExpireAt + } return existing, c.consensus.LogPin(ctx, existing) } From 4aae7080a8a51ac8111b90dbef19e89503696add Mon Sep 17 00:00:00 2001 From: deepakgarg Date: Fri, 10 Apr 2020 23:41:48 -0700 Subject: [PATCH 2/3] Fixes #996. Updated the TestClustersPinUpdate test --- ipfscluster_test.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ipfscluster_test.go b/ipfscluster_test.go index f5d9a841..58c7f1ce 100644 --- a/ipfscluster_test.go +++ b/ipfscluster_test.go @@ -736,11 +736,12 @@ func TestClustersPinUpdate(t *testing.T) { } pinDelay() - + expiry := time.Now().AddDate(1, 0, 0) opts2 := api.PinOptions{ UserAllocations: []peer.ID{clusters[0].host.ID()}, // should not be used PinUpdate: h, Name: "new name", + ExpireAt: expiry, } _, err = clusters[0].Pin(ctx, h2, opts2) // should call PinUpdate @@ -763,6 +764,10 @@ func TestClustersPinUpdate(t *testing.T) { if pinget.MaxDepth != -1 { t.Error("updated pin should be recursive like pin1") } + if pinget.ExpireAt != expiry { + t.Errorf("Expiry time didn't match. Expected: %s. Got: %s", + expiry.String(), pinget.ExpireAt.String()) + } if pinget.Name != "new name" { t.Error("name should be kept") From bf9a089ae3a691cc12d910b5d1abee0389f5f6c2 Mon Sep 17 00:00:00 2001 From: deepakgarg Date: Tue, 14 Apr 2020 12:45:34 -0700 Subject: [PATCH 3/3] Fixes #996 Rounding expiry time to 2s in TestClusterPingUpdate test --- ipfscluster_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ipfscluster_test.go b/ipfscluster_test.go index 58c7f1ce..5d593ef6 100644 --- a/ipfscluster_test.go +++ b/ipfscluster_test.go @@ -764,8 +764,9 @@ func TestClustersPinUpdate(t *testing.T) { if pinget.MaxDepth != -1 { t.Error("updated pin should be recursive like pin1") } + expiry = expiry.Round(2 * time.Second) if pinget.ExpireAt != expiry { - t.Errorf("Expiry time didn't match. Expected: %s. Got: %s", + t.Errorf("Expiry didn't match. Expected: %s. Got: %s", expiry.String(), pinget.ExpireAt.String()) }