From d68a24d395c69af98fd557e2f67839d1600c0e86 Mon Sep 17 00:00:00 2001 From: maurycy <5383+maurycy@users.noreply.github.com> Date: Wed, 21 Oct 2020 16:14:56 +0200 Subject: [PATCH] use PathItem.Metadata.UpdatedAt --- core/space/services/services_fs.go | 6 +++--- core/space/space_test.go | 13 +++++++++++++ core/textile/sharing.go | 3 ++- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/core/space/services/services_fs.go b/core/space/services/services_fs.go index 9418f93f..5e78c06e 100644 --- a/core/space/services/services_fs.go +++ b/core/space/services/services_fs.go @@ -219,9 +219,9 @@ func (s *Space) listDirAtPath( Name: item.Name, SizeInBytes: strconv.FormatInt(item.Size, 10), FileExtension: strings.Replace(filepath.Ext(item.Name), ".", "", -1), - // TODO: Get these fields from Textile Buckets - Created: time.Now().Format(time.RFC3339), - Updated: time.Now().Format(time.RFC3339), + // FIXME: real created at needed + Created: time.Unix(item.Metadata.UpdatedAt, 0).Format(time.RFC3339), + Updated: time.Unix(item.Metadata.UpdatedAt, 0).Format(time.RFC3339), Members: members, }, IpfsHash: item.Cid, diff --git a/core/space/space_test.go b/core/space/space_test.go index 1dd7fea3..08883a6b 100644 --- a/core/space/space_test.go +++ b/core/space/space_test.go @@ -12,6 +12,7 @@ import ( "path/filepath" "strings" "testing" + "time" "github.com/FleekHQ/space-daemon/core/space/domain" @@ -182,6 +183,9 @@ func TestService_ListDirs(t *testing.T) { IsDir: false, Size: 16, Cid: "bafkreia4q63he72sgzrn64kpa2uu5it7utmqkdby6t3xck6umy77x7p2a1", + Metadata: &buckets_pb.Metadata{ + UpdatedAt: time.Now().Unix(), + }, }, { Path: bucketPath + "/somedir", @@ -189,6 +193,9 @@ func TestService_ListDirs(t *testing.T) { IsDir: true, Size: 0, Cid: "", + Metadata: &buckets_pb.Metadata{ + UpdatedAt: time.Now().Unix(), + }, }, { Path: bucketPath + "/example.txt", @@ -196,6 +203,9 @@ func TestService_ListDirs(t *testing.T) { IsDir: false, Size: 16, Cid: "bafkreia4q63he72sgzrn64kpa2uu5it7utmqkdby6t3xck6umy77x7p2ae", + Metadata: &buckets_pb.Metadata{ + UpdatedAt: time.Now().Unix(), + }, }, }, }, @@ -210,6 +220,9 @@ func TestService_ListDirs(t *testing.T) { IsDir: false, Size: 16, Cid: "bafkreia4q63he72sgzrn64kpa2uu5it7utmqkdby6t3xck6umy77x7p2ae", + Metadata: &buckets_pb.Metadata{ + UpdatedAt: time.Now().Unix(), + }, }, }, }, diff --git a/core/textile/sharing.go b/core/textile/sharing.go index bff14a2b..a2fd56dc 100644 --- a/core/textile/sharing.go +++ b/core/textile/sharing.go @@ -160,6 +160,7 @@ func (tc *textileClient) GetReceivedFiles(ctx context.Context, accepted bool, se isDir := false size := f.GetItem().Size ext := strings.Replace(filepath.Ext(name), ".", "", -1) + updatedAt := f.GetItem().Metadata.UpdatedAt rs, err := sbc.PullPathAccessRoles(ctx, file.BucketKey, file.Path) if err != nil { @@ -210,7 +211,7 @@ func (tc *textileClient) GetReceivedFiles(ctx context.Context, accepted bool, se SizeInBytes: strconv.FormatInt(size, 10), FileExtension: ext, Created: strconv.FormatInt(time.Unix(0, file.CreatedAt).Unix(), 10), - Updated: strconv.FormatInt(time.Unix(0, file.CreatedAt).Unix(), 10), // NOTE: there is no modified yet so using same as create + Updated: strconv.FormatInt(time.Unix(updatedAt, 0).Unix(), 10), }, }, Members: members,