File tree Expand file tree Collapse file tree 2 files changed +9
-5
lines changed Expand file tree Collapse file tree 2 files changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -103,8 +103,9 @@ func (d *Datastore) Query(q query.Query) (query.Results, error) {
103
103
104
104
walkFn := func (path string , info os.FileInfo , err error ) error {
105
105
// remove ds path prefix
106
- if strings .HasPrefix (path , d .path ) {
107
- path = path [len (d .path ):]
106
+ relPath , err := filepath .Rel (d .path , path )
107
+ if err == nil {
108
+ path = filepath .ToSlash (relPath )
108
109
}
109
110
110
111
if ! info .IsDir () {
@@ -167,7 +168,7 @@ func (d *Datastore) DiskUsage() (uint64, error) {
167
168
log .Println (err )
168
169
return err
169
170
}
170
- if f != nil {
171
+ if f != nil && f . Mode (). IsRegular () {
171
172
du += uint64 (f .Size ())
172
173
}
173
174
return nil
Original file line number Diff line number Diff line change @@ -96,13 +96,16 @@ func (ks *DSSuite) TestDiskUsage(c *C) {
96
96
"foo/bar/baz/barb" ,
97
97
})
98
98
99
+ totalBytes := 0
99
100
for _ , k := range keys {
100
- err := ks .ds .Put (k , []byte (k .String ()))
101
+ value := []byte (k .String ())
102
+ totalBytes += len (value )
103
+ err := ks .ds .Put (k , value )
101
104
c .Check (err , Equals , nil )
102
105
}
103
106
104
107
if ps , ok := ks .ds .(ds.PersistentDatastore ); ok {
105
- if s , err := ps .DiskUsage (); s <= 100 || err != nil {
108
+ if s , err := ps .DiskUsage (); s != uint64 ( totalBytes ) || err != nil {
106
109
c .Error ("unexpected size is: " , s )
107
110
}
108
111
} else {
You can’t perform that action at this time.
0 commit comments