Unverified Commit 149d5680 authored by Steven Allen's avatar Steven Allen Committed by GitHub

Merge pull request #68 from ipfs/fix/loud-logging

fix: only log when we find a file we don't expect
parents 5498a827 4ae1b85a
...@@ -290,7 +290,12 @@ func (fs *Datastore) encode(key datastore.Key) (dir, file string) { ...@@ -290,7 +290,12 @@ func (fs *Datastore) encode(key datastore.Key) (dir, file string) {
} }
func (fs *Datastore) decode(file string) (key datastore.Key, ok bool) { func (fs *Datastore) decode(file string) (key datastore.Key, ok bool) {
if filepath.Ext(file) != extension { if !strings.HasSuffix(file, extension) {
// We expect random files like "put-". Log when we encounter
// others.
if !strings.HasPrefix(file, "put-") {
log.Warnw("failed to decode flatfs filename", "file", file)
}
return datastore.Key{}, false return datastore.Key{}, false
} }
name := file[:len(file)-len(extension)] name := file[:len(file)-len(extension)]
...@@ -1064,7 +1069,7 @@ func (fs *Datastore) walk(path string, qrb *query.ResultBuilder) error { ...@@ -1064,7 +1069,7 @@ func (fs *Datastore) walk(path string, qrb *query.ResultBuilder) error {
key, ok := fs.decode(fn) key, ok := fs.decode(fn)
if !ok { if !ok {
log.Warnw("failed to decode flatfs entry", "file", fn) // not a block.
continue continue
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment