Skip to content

Commit 98b31f3

Browse files
authored
Merge pull request #569 from textileio/sander/buckignore
Adds buckignore and updates threads
2 parents d1b47e5 + 3d0e679 commit 98b31f3

7 files changed

Lines changed: 56 additions & 16 deletions

File tree

buckets/local/bucket.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,14 +137,18 @@ func (b *Bucket) LocalSize() (int64, error) {
137137
if err != nil {
138138
return 0, err
139139
}
140+
ig, err := IgnoreFile(bp)
141+
if err != nil {
142+
return 0, err
143+
}
140144
var size int64
141145
err = filepath.Walk(bp, func(n string, info os.FileInfo, err error) error {
142146
if err != nil {
143147
return fmt.Errorf("getting fileinfo of %s: %s", n, err)
144148
}
145149
if !info.IsDir() {
146150
f := strings.TrimPrefix(n, bp+string(os.PathSeparator))
147-
if Ignore(n) || (strings.HasPrefix(f, b.conf.Dir) && f != buckets.SeedName) {
151+
if Ignore(n, ig) || (strings.HasPrefix(f, b.conf.Dir) && f != buckets.SeedName) {
148152
return nil
149153
}
150154
size += info.Size()

buckets/local/diff.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,21 @@ func (b *Bucket) DiffLocal() ([]Change, error) {
9999
}
100100

101101
func (b *Bucket) walkPath(pth string) (names []string, err error) {
102+
bp, err := b.Path()
103+
if err != nil {
104+
return
105+
}
106+
ig, err := IgnoreFile(bp)
107+
if err != nil {
108+
return
109+
}
102110
err = filepath.Walk(pth, func(n string, info os.FileInfo, err error) error {
103111
if err != nil {
104112
return err
105113
}
106114
if !info.IsDir() {
107115
f := strings.TrimPrefix(n, pth+string(os.PathSeparator))
108-
if Ignore(n) ||
116+
if Ignore(n, ig) ||
109117
f == buckets.SeedName ||
110118
strings.HasPrefix(f, b.conf.Dir) ||
111119
strings.HasSuffix(f, PatchExt) {

buckets/local/repo.go

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030
"github.com/ipfs/go-unixfs/importer/trickle"
3131
options "github.com/ipfs/interface-go-ipfs-core/options"
3232
mh "github.com/multiformats/go-multihash"
33+
ignore "github.com/sabhiram/go-gitignore"
3334
)
3435

3536
func init() {
@@ -217,12 +218,16 @@ func (b *Repo) recursiveAddPath(
217218
if err != nil {
218219
return nil, nil, err
219220
}
221+
ig, err := IgnoreFile(b.path)
222+
if err != nil {
223+
return nil, nil, err
224+
}
220225
if err = filepath.Walk(abs, func(n string, info os.FileInfo, err error) error {
221226
if err != nil {
222227
return err
223228
}
224229
if !info.IsDir() {
225-
if Ignore(n) {
230+
if Ignore(n, ig) {
226231
return nil
227232
}
228233
p := n
@@ -435,15 +440,29 @@ func (b *Repo) Close() error {
435440
}
436441

437442
// Ignore returns true if the path contains an ignored file.
438-
func Ignore(pth string) bool {
443+
func Ignore(pth string, ig *ignore.GitIgnore) bool {
439444
for _, n := range ignoredFilenames {
440445
if strings.HasSuffix(pth, n) {
441446
return true
442447
}
443448
}
449+
if ig != nil {
450+
return ig.MatchesPath(pth)
451+
}
444452
return false
445453
}
446454

455+
// IgnoreFile returns the ignore file at path if it exists
456+
func IgnoreFile(pth string) (*ignore.GitIgnore, error) {
457+
ig, err := ignore.CompileIgnoreFile(filepath.Join(pth, ".buckignore"))
458+
if errors.Is(err, os.ErrNotExist) {
459+
return nil, nil
460+
} else if err != nil {
461+
return nil, err
462+
}
463+
return ig, nil
464+
}
465+
447466
// addFile chunks reader with layout and adds blocks to the dag service.
448467
// SHA2-256 is used as the hash function and CidV1 as the cid version.
449468
func addFile(dag ipld.DAGService, layout options.Layout, prefix cid.Prefix, r io.Reader) (ipld.Node, error) {

cmd/buck/cli/remote.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ var remoteAddCmd = &cobra.Command{
3939
defer cancel()
4040
buck, err := bucks.GetLocalBucket(ctx, conf)
4141
cmd.ErrCheck(err)
42+
bp, err := buck.Path()
43+
cmd.ErrCheck(err)
44+
ig, err := local.IgnoreFile(bp)
45+
cmd.ErrCheck(err)
4246

4347
var events chan local.Event
4448
if !quiet {
@@ -62,7 +66,7 @@ var remoteAddCmd = &cobra.Command{
6266
}
6367
if !info.IsDir() {
6468
f := strings.TrimPrefix(n, pth+string(os.PathSeparator))
65-
if local.Ignore(n) ||
69+
if local.Ignore(n, ig) ||
6670
strings.Contains(f, buckets.SeedName) ||
6771
strings.Contains(f, buck.ConfDir()) ||
6872
strings.HasSuffix(f, local.PatchExt) {

core/core.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,8 @@ func NewTextile(ctx context.Context, conf Config, opts ...Option) (*Textile, err
268268
// Configure threads
269269
netOptions := []tc.NetOption{
270270
tc.WithNetHostAddr(conf.AddrThreadsHost),
271+
tc.WithNoNetPulling(true),
272+
tc.WithNoExchangeEdgesMigration(true),
271273
tc.WithNetDebug(conf.Debug),
272274
}
273275
if args.ThreadsMongoUri != "" {

go.mod

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ require (
6262
github.com/robfig/cron/v3 v3.0.1
6363
github.com/rs/cors v1.7.0
6464
github.com/russross/blackfriday/v2 v2.1.0 // indirect
65+
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06
6566
github.com/segmentio/backo-go v0.0.0-20200129164019-23eae7c10bd3 // indirect
6667
github.com/spf13/afero v1.2.2 // indirect
6768
github.com/spf13/cast v1.3.1 // indirect
@@ -75,7 +76,7 @@ require (
7576
github.com/textileio/dcrypto v0.0.1
7677
github.com/textileio/go-assets v0.0.0-20200430191519-b341e634e2b7
7778
github.com/textileio/go-ds-mongo v0.1.5
78-
github.com/textileio/go-threads v1.1.2-0.20211007203214-1842e70155ec
79+
github.com/textileio/go-threads v1.1.2-0.20211029155120-3479a196d9b7
7980
github.com/textileio/powergate/v2 v2.3.0
8081
github.com/textileio/swagger-ui v0.3.29-0.20210224180244-7d73a7a32fe7
8182
github.com/xakep666/mongo-migrate v0.2.1

go.sum

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1750,6 +1750,8 @@ github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf
17501750
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
17511751
github.com/rwcarlsen/goexif v0.0.0-20190401172101-9e8deecbddbd/go.mod h1:hPqNNc0+uJM6H+SuU8sEs5K5IQeKccPqeSjfgcKGgPk=
17521752
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
1753+
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 h1:OkMGxebDjyw0ULyrTYWeN0UNCCkmCWfjPnIA2W6oviI=
1754+
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06/go.mod h1:+ePHsJ1keEjQtpvf9HHw0f4ZeJ0TLRsxhunSI2hYJSs=
17531755
github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E=
17541756
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
17551757
github.com/segmentio/backo-go v0.0.0-20200129164019-23eae7c10bd3 h1:ZuhckGJ10ulaKkdvJtiAqsLTiPrLaXSdnVgXJKJkTxE=
@@ -1886,23 +1888,23 @@ github.com/textileio/go-libp2p-pubsub-rpc v0.0.5 h1:De54sqNpQocJebf7P+4RrwtuUw8s
18861888
github.com/textileio/go-libp2p-pubsub-rpc v0.0.5/go.mod h1:MlOMOz3KZxexobvUuFXT/QY9Vjh9eKJpZPr48hDUdVo=
18871889
github.com/textileio/go-log/v2 v2.1.3-gke-1 h1:7e3xSUXQB8hn4uUe5fp41kLThW1o9T65gSM7qjS323g=
18881890
github.com/textileio/go-log/v2 v2.1.3-gke-1/go.mod h1:DwACkjFS3kjZZR/4Spx3aPfSsciyslwUe5bxV8CEU2w=
1889-
github.com/textileio/go-threads v1.1.2-0.20211007203214-1842e70155ec h1:oh/OYfsHLM5cfql71Qi5JYgBk8McSuTCrwGshjqnW00=
1890-
github.com/textileio/go-threads v1.1.2-0.20211007203214-1842e70155ec/go.mod h1:mQzCfbPLpOfHoh07v5u8/i67QRcNjO8DcpS/79LJK6I=
1891+
github.com/textileio/go-threads v1.1.2-0.20211029155120-3479a196d9b7 h1:G984DCftarAL5DjWawFPjS0vi3fhtxRMKNOLEmtUzMM=
1892+
github.com/textileio/go-threads v1.1.2-0.20211029155120-3479a196d9b7/go.mod h1:pC5hdRsNeprQaXVJ9b/EKF/ZCiiYl2KQ6HEAlT/CVDo=
18911893
github.com/textileio/powergate/v2 v2.3.0 h1:kelYh+ZWDQao1rL5YiMznQscd6CsDjgt6P/D1S5UYwQ=
18921894
github.com/textileio/powergate/v2 v2.3.0/go.mod h1:2j2NL1oevaVdrI6MpKfHnfgUOy1D4L7eP3I+1czxDjw=
18931895
github.com/textileio/swagger-ui v0.3.29-0.20210224180244-7d73a7a32fe7 h1:qUEurT6kJF+nFkiNjUPMJJ7hgg9OIDnb8iLn6VtBukE=
18941896
github.com/textileio/swagger-ui v0.3.29-0.20210224180244-7d73a7a32fe7/go.mod h1:IG3de1dcR5Hmcz57nScHHoq5Ju1AABd8z5GnLDgDCks=
18951897
github.com/texttheater/golang-levenshtein v0.0.0-20180516184445-d188e65d659e/go.mod h1:XDKHRm5ThF8YJjx001LtgelzsoaEcvnA7lVWz9EeX3g=
1896-
github.com/tidwall/gjson v1.8.1 h1:8j5EE9Hrh3l9Od1OIEDAb7IpezNA20UdRngNAj5N0WU=
1897-
github.com/tidwall/gjson v1.8.1/go.mod h1:5/xDoumyyDNerp2U36lyolv46b3uF/9Bu6OfyQ9GImk=
1898-
github.com/tidwall/match v1.0.3 h1:FQUVvBImDutD8wJLN6c5eMzWtjgONK9MwIBCOrUJKeE=
1899-
github.com/tidwall/match v1.0.3/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
1898+
github.com/tidwall/gjson v1.10.2 h1:APbLGOM0rrEkd8WBw9C24nllro4ajFuJu0Sc9hRz8Bo=
1899+
github.com/tidwall/gjson v1.10.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
1900+
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
1901+
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
19001902
github.com/tidwall/pretty v0.0.0-20190325153808-1166b9ac2b65/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
19011903
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
1902-
github.com/tidwall/pretty v1.1.0 h1:K3hMW5epkdAVwibsQEfR/7Zj0Qgt4DxtNumTq/VloO8=
1903-
github.com/tidwall/pretty v1.1.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
1904-
github.com/tidwall/sjson v1.0.4 h1:UcdIRXff12Lpnu3OLtZvnc03g4vH2suXDXhBwBqmzYg=
1905-
github.com/tidwall/sjson v1.0.4/go.mod h1:bURseu1nuBkFpIES5cz6zBtjmYeOQmEESshn7VpF15Y=
1904+
github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs=
1905+
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
1906+
github.com/tidwall/sjson v1.2.3 h1:5+deguEhHSEjmuICXZ21uSSsXotWMA0orU783+Z7Cp8=
1907+
github.com/tidwall/sjson v1.2.3/go.mod h1:5WdjKx3AQMvCJ4RG6/2UYT7dLrGvJUV1x4jdTAyGvZs=
19061908
github.com/tj/go-spin v1.1.0 h1:lhdWZsvImxvZ3q1C5OIB7d72DuOwP4O2NdBg9PyzNds=
19071909
github.com/tj/go-spin v1.1.0/go.mod h1:Mg1mzmePZm4dva8Qz60H2lHwmJ2loum4VIrLgVnKwh4=
19081910
github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=

0 commit comments

Comments
 (0)