builds again

This commit is contained in:
Jeffrey Paul 2019-09-26 15:47:04 -07:00
parent 5b1ba9a3f2
commit 1e45ea3e24

39
main.go
View File

@ -14,6 +14,7 @@ import "os"
import "io" import "io"
import "flag" import "flag"
import "time" import "time"
import "strconv"
var Version string var Version string
var Buildtime string var Buildtime string
@ -144,7 +145,7 @@ func HashFile(fp *os.File) (string, error) {
return "", err return "", err
} }
mHashBuf, err := multihash.EncodeName(h.Sum(nil), "sha1") mHashBuf, err := multihash.EncodeName(h.Sum(nil), "sha2-256")
if err != nil { if err != nil {
return "", err return "", err
@ -158,12 +159,15 @@ func HashFile(fp *os.File) (string, error) {
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
type xsf struct { type xsf struct {
fi *os.FileInfo fi *os.FileInfo
fp *os.File fp *os.File
multihash string multihash string
mtime string xmultihash string
path string mtime string
size int64 xmtime string
path string
size uint64
xsize uint64
} }
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
@ -184,13 +188,32 @@ func (x *xsf) readXattrs(fp *os.File) error {
xn = fmt.Sprintf("%s.%s", namespacePrefix, "mtime") xn = fmt.Sprintf("%s.%s", namespacePrefix, "mtime")
v, err = xattr.FGet(x.fp, xn) v, err = xattr.FGet(x.fp, xn)
if err != nil {
return err
}
x.xmtime = string(v)
xn = fmt.Sprintf("%s.%s", namespacePrefix, "size") xn = fmt.Sprintf("%s.%s", namespacePrefix, "size")
v, err = xattr.FGet(x.fp, xn) v, err = xattr.FGet(x.fp, xn)
if err != nil {
return err
}
a, b := strconv.ParseInt(string(v), 10, 64)
if b != nil {
return b
}
x.xsize = uint64(a)
xn = fmt.Sprintf("%s.%s", namespacePrefix, "multihash") xn = fmt.Sprintf("%s.%s", namespacePrefix, "multihash")
v, err = xattr.FGet(x.fp, xn) v, err = xattr.FGet(x.fp, xn)
if err != nil {
return err
}
x.xmultihash = string(v)
return nil //FIXME return nil //FIXME
} }
@ -229,7 +252,7 @@ func (x *xsf) stat(fp *os.File) error {
if err != nil { if err != nil {
return err return err
} }
x.size = fi.Size() x.size = uint64(fi.Size())
log.Debugf("size: %d", x.size) log.Debugf("size: %d", x.size)
t := fi.ModTime().UTC().Format(time.RFC3339) t := fi.ModTime().UTC().Format(time.RFC3339)
log.Debugf("modtime: %s", t) log.Debugf("modtime: %s", t)