Skip to content

Commit

Permalink
query: deny ReturnsSizes and ReturnExpirations instead of returning w…
Browse files Browse the repository at this point in the history
…rong result
  • Loading branch information
MichaelMure committed Nov 27, 2019
1 parent 3453260 commit 2989869
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
14 changes: 8 additions & 6 deletions flatfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -401,10 +401,10 @@ func (fs *Datastore) doOp(oper *op) error {
}
}

// doWrite optmizes out write operations (put/delete) to the same
// key by queueing them and suceeding all queued
// doWrite optimizes out write operations (put/delete) to the same
// key by queueing them and succeeding all queued
// operations if one of them does. In such case,
// we assume that the first suceeding operation
// we assume that the first succeeding operation
// on that key was the last one to happen after
// all successful others.
func (fs *Datastore) doWriteOp(oper *op) error {
Expand Down Expand Up @@ -648,7 +648,9 @@ func (fs *Datastore) Query(q query.Query) (query.Results, error) {
len(q.Orders) > 0 ||
q.Limit > 0 ||
q.Offset > 0 ||
!q.KeysOnly {
!q.KeysOnly ||
q.ReturnExpirations ||
q.ReturnsSizes {
// TODO this is overly simplistic, but the only caller is
// `ipfs refs local` for now, and this gets us moving.
return nil, errors.New("flatfs only supports listing all keys in random order")
Expand Down Expand Up @@ -703,8 +705,8 @@ func (fs *Datastore) walkTopLevel(path string, result *query.ResultBuilder) erro
}

// folderSize estimates the diskUsage of a folder by reading
// up to DiskUsageFilesAverage entries in it and assumming any
// other files will have an avereage size.
// up to DiskUsageFilesAverage entries in it and assuming any
// other files will have an average size.
func folderSize(path string, deadline time.Time) (int64, initAccuracy, error) {
var du int64

Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ require (
github.com/ipfs/go-log v0.0.1
github.com/jbenet/goprocess v0.0.0-20160826012719-b497e2f366b8
)

replace github.com/ipfs/go-datastore => github.com/MichaelMure/go-datastore v0.1.1-0.20191122134937-68a77964d1eb

0 comments on commit 2989869

Please sign in to comment.