From 8814d68dde767ca58358a8ebd0ffbc5498ddc20b Mon Sep 17 00:00:00 2001 From: maurycy <5383+maurycy@users.noreply.github.com> Date: Thu, 1 Oct 2020 22:42:49 +0200 Subject: [PATCH] textile/utils: IsMetaFileName() --- core/space/services/services_fs.go | 2 +- core/textile/secure_bucket_client.go | 3 ++- core/textile/sync/pinning.go | 5 +++-- core/textile/utils/utils.go | 11 +++++++++++ 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/core/space/services/services_fs.go b/core/space/services/services_fs.go index fc6b0b7c..ad8d0d23 100644 --- a/core/space/services/services_fs.go +++ b/core/space/services/services_fs.go @@ -178,7 +178,7 @@ func (s *Space) listDirAtPath( entries := make([]domain.FileInfo, 0) for _, item := range dir.Item.Items { - if item.Name == ".textileseed" || item.Name == ".textile" { + if utils.IsMetaFileName(item.Name) { continue } diff --git a/core/textile/secure_bucket_client.go b/core/textile/secure_bucket_client.go index e42b7ce7..d95e57fb 100644 --- a/core/textile/secure_bucket_client.go +++ b/core/textile/secure_bucket_client.go @@ -9,6 +9,7 @@ import ( "strings" "github.com/FleekHQ/space-daemon/core/textile/common" + "github.com/FleekHQ/space-daemon/core/textile/utils" "github.com/FleekHQ/space-daemon/log" @@ -132,7 +133,7 @@ func (s *SecureBucketClient) overwriteDecryptedItem(ctx context.Context, item *b if err != nil { return err } - if item.Name == ".textileseed" || item.Name == ".textile" { + if utils.IsMetaFileName(item.Name) { return nil } // decrypt file name diff --git a/core/textile/sync/pinning.go b/core/textile/sync/pinning.go index 1bb5b660..48879a6d 100644 --- a/core/textile/sync/pinning.go +++ b/core/textile/sync/pinning.go @@ -5,6 +5,7 @@ import ( "io" "strings" + "github.com/FleekHQ/space-daemon/core/textile/utils" "github.com/FleekHQ/space-daemon/log" ) @@ -67,7 +68,7 @@ func (s *synchronizer) uploadAllFilesInPath(ctx context.Context, bucket, path st } for _, item := range dir.Item.Items { - if item.Name == ".textileseed" || item.Name == ".textile" { + if utils.IsMetaFileName(item.Name) { continue } @@ -116,7 +117,7 @@ func (s *synchronizer) deleteAllFilesInPath(ctx context.Context, bucket, path st } for _, item := range dir.Item.Items { - if item.Name == ".textileseed" || item.Name == ".textile" { + if utils.IsMetaFileName(item.Name) { continue } diff --git a/core/textile/utils/utils.go b/core/textile/utils/utils.go index dba5242a..4de7a32a 100644 --- a/core/textile/utils/utils.go +++ b/core/textile/utils/utils.go @@ -7,6 +7,7 @@ import ( "encoding/base32" "encoding/binary" "encoding/hex" + "path/filepath" "github.com/FleekHQ/space-daemon/core/keychain" "github.com/FleekHQ/space-daemon/core/textile/hub" @@ -126,3 +127,13 @@ func RandBytes(size int) ([]byte, error) { _, err := rand.Read(b) return b, err } + +func IsMetaFileName(pathOrName string) bool { + _, name := filepath.Split(pathOrName) + + if name == ".textileseed" || name == ".textile" { + return true + } + + return false +}