gofmt fix and sharness test
gofmt fixes to fsrepo.go The sharness test checks that IPFS_PATHS that are symbolically linked to another directory are returning an appropriate size License: MIT Signed-off-by: John Reed <john@re2d.xyz>
Unknown committed
Oct 21, 2017 at 18:22 UTC
54d7e03303f70d88bfaa8a8aee636dd33b2dd491
2 files changed
+29
-2
repo/fsrepo/fsrepo.go
+2
-2
@@ -636,13 +636,13 @@ func (r *FSRepo) GetStorageUsage() (uint64, error) {
636
if err != nil {
637
return 0, err
638
}
639
-
639
+
640
pth, err = filepath.EvalSymlinks(pth)
641
if err != nil {
642
log.Debugf("filepath.EvalSymlinks error: %s", err)
643
return 0, err
644
}
645
-
645
+
646
var du uint64
647
err = filepath.Walk(pth, func(p string, f os.FileInfo, err error) error {
648
if err != nil {
test/sharness/t0088-repo-stat-symlink.sh
new
+27
@@ -0,0 +1,27 @@
1
+#!/bin/sh
2
+#
3
+# Copyright (c) 2017 John Reed
4
+# MIT Licensed; see the LICENSE file in this repository.
5
+#
6
+
7
+test_description="Test 'ipfs repo stat' where IPFS_PATH is a symbolic link"
8
+
9
+. lib/test-lib.sh
10
+
11
+test_expect_success "create symbolic link for IPFS_PATH" '
12
+ mkdir sym_link_target &&
13
+ ln -s sym_link_target .ipfs
14
+'
15
+
16
+test_init_ipfs
17
+
18
+# compare RepoSize when getting it directly vs via symbolic link
19
+test_expect_success "'ipfs repo stat' RepoSize is correct with sym link" '
20
+ export IPFS_PATH="sym_link_target" &&
21
+ reposize_direct=$(ipfs repo stat | grep RepoSize | awk '\''{ print $2 }'\'') &&
22
+ export IPFS_PATH=".ipfs" &&
23
+ reposize_symlink=$(ipfs repo stat | grep RepoSize | awk '\''{ print $2 }'\'') &&
24
+ test $reposize_symlink -ge $reposize_direct
25
+'
26
+
27
+test_done