Skip to content

Commit

Permalink
textile/utils: IsMetaFileName()
Browse files Browse the repository at this point in the history
  • Loading branch information
maurycy committed Oct 5, 2020
1 parent 5dd79d6 commit 8814d68
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion core/space/services/services_fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
3 changes: 2 additions & 1 deletion core/textile/secure_bucket_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions core/textile/sync/pinning.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"io"
"strings"

"github.com/FleekHQ/space-daemon/core/textile/utils"
"github.com/FleekHQ/space-daemon/log"
)

Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}

Expand Down
11 changes: 11 additions & 0 deletions core/textile/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}

0 comments on commit 8814d68

Please sign in to comment.