Skip to content

Commit

Permalink
use PathItem.Metadata.UpdatedAt
Browse files Browse the repository at this point in the history
  • Loading branch information
maurycy authored Oct 21, 2020
1 parent 833529c commit d68a24d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
6 changes: 3 additions & 3 deletions core/space/services/services_fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
13 changes: 13 additions & 0 deletions core/space/space_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"path/filepath"
"strings"
"testing"
"time"

"github.com/FleekHQ/space-daemon/core/space/domain"

Expand Down Expand Up @@ -182,20 +183,29 @@ func TestService_ListDirs(t *testing.T) {
IsDir: false,
Size: 16,
Cid: "bafkreia4q63he72sgzrn64kpa2uu5it7utmqkdby6t3xck6umy77x7p2a1",
Metadata: &buckets_pb.Metadata{
UpdatedAt: time.Now().Unix(),
},
},
{
Path: bucketPath + "/somedir",
Name: "somedir",
IsDir: true,
Size: 0,
Cid: "",
Metadata: &buckets_pb.Metadata{
UpdatedAt: time.Now().Unix(),
},
},
{
Path: bucketPath + "/example.txt",
Name: "example.txt",
IsDir: false,
Size: 16,
Cid: "bafkreia4q63he72sgzrn64kpa2uu5it7utmqkdby6t3xck6umy77x7p2ae",
Metadata: &buckets_pb.Metadata{
UpdatedAt: time.Now().Unix(),
},
},
},
},
Expand All @@ -210,6 +220,9 @@ func TestService_ListDirs(t *testing.T) {
IsDir: false,
Size: 16,
Cid: "bafkreia4q63he72sgzrn64kpa2uu5it7utmqkdby6t3xck6umy77x7p2ae",
Metadata: &buckets_pb.Metadata{
UpdatedAt: time.Now().Unix(),
},
},
},
},
Expand Down
3 changes: 2 additions & 1 deletion core/textile/sharing.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit d68a24d

Please sign in to comment.