provide flag to determine whether to perform GC
Brian Tiger Chow committed
Jan 29, 2015 at 02:27 UTC
bbc809108534bfa18b790a3ad7b46c3af98781b5
1 file changed
+9
-8
cmd/ipfs-gateway-fs/main.go
+9
-8
@@ -21,6 +21,7 @@ var (
21
garbageCollectInterval = flag.Duration("gc-interval", 24*time.Hour, "frequency of repo garbage collection")
22
assetsPath = flag.String("assets-path", "", "if provided, periodically adds contents of path to IPFS")
23
host = flag.String("host", "/ip4/0.0.0.0/tcp/8080", "override the HTTP host listening address")
24
+ performGC = flag.Bool("gc", false, "perform garbage collection")
25
nBitsForKeypair = flag.Int("b", 1024, "number of bits for keypair (if repo is uninitialized)")
26
)
27
@@ -63,13 +64,15 @@ func run() error {
64
}
65
defer node.Close()
66
66
- go func() {
67
- for _ = range time.Tick(*garbageCollectInterval) {
68
- if err := corerepo.GarbageCollect(node, ctx); err != nil {
69
- log.Println("failed to run garbage collection", err)
67
+ if *performGC {
68
+ go func() {
69
+ for _ = range time.Tick(*garbageCollectInterval) {
70
+ if err := corerepo.GarbageCollect(node, ctx); err != nil {
71
+ log.Println("failed to run garbage collection", err)
72
+ }
73
}
71
- }
72
- }()
74
+ }()
75
+ }
76
77
if *assetsPath != "" {
78
fi, err := os.Stat(*assetsPath)
@@ -95,7 +98,5 @@ func run() error {
98
if err := corehttp.ListenAndServe(node, *host, opts...); err != nil {
99
return err
100
}
98
-
99
- // TODO serve files
101
return nil
102
}