From 6b0b095eae384ed7606eef171bcf04968dcf37f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Mur=C3=A9?= Date: Wed, 27 Nov 2019 17:04:18 +0100 Subject: [PATCH] query: deny ReturnsSizes and ReturnExpirations instead of returning wrong result --- flatfs.go | 14 ++++++++------ go.mod | 6 ++++-- go.sum | 10 +++++----- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/flatfs.go b/flatfs.go index 24ba811..873e3d4 100644 --- a/flatfs.go +++ b/flatfs.go @@ -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 { @@ -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") @@ -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 diff --git a/go.mod b/go.mod index 1d6b285..0084a83 100644 --- a/go.mod +++ b/go.mod @@ -1,7 +1,9 @@ module github.com/ipfs/go-ds-flatfs require ( - github.com/ipfs/go-datastore v0.1.1 + github.com/ipfs/go-datastore v0.2.0 github.com/ipfs/go-log v0.0.1 - github.com/jbenet/goprocess v0.0.0-20160826012719-b497e2f366b8 + github.com/jbenet/goprocess v0.1.3 ) + +go 1.12 diff --git a/go.sum b/go.sum index b895c0f..83ef54c 100644 --- a/go.sum +++ b/go.sum @@ -6,15 +6,15 @@ github.com/gogo/protobuf v1.2.1 h1:/s5zKNz0uPFCZ5hddgPdo2TK2TVrUNMn0OOX8/aZMTE= github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/ipfs/go-datastore v0.1.0 h1:TOxI04l8CmO4zGtesENhzm4PwkFwJXY3rKiYaaMf9fI= -github.com/ipfs/go-datastore v0.1.0/go.mod h1:d4KVXhMt913cLBEI/PXAy6ko+W7e9AhyAKBGh803qeE= -github.com/ipfs/go-datastore v0.1.1 h1:F4k0TkTAZGLFzBOrVKDAvch6JZtuN4NHkfdcEZL50aI= -github.com/ipfs/go-datastore v0.1.1/go.mod h1:w38XXW9kVFNp57Zj5knbKWM2T+KOZCGDRVNdgPHtbHw= +github.com/ipfs/go-datastore v0.2.0 h1:5Wjw6YXzZmtqU1MSrlws64+oLmSqea7gEajTcJickh8= +github.com/ipfs/go-datastore v0.2.0/go.mod h1:w38XXW9kVFNp57Zj5knbKWM2T+KOZCGDRVNdgPHtbHw= github.com/ipfs/go-ipfs-delay v0.0.0-20181109222059-70721b86a9a8/go.mod h1:8SP1YXK1M1kXuc4KJZINY3TQQ03J2rwBG9QfXmbRPrw= github.com/ipfs/go-log v0.0.1 h1:9XTUN/rW64BCG1YhPK9Hoy3q8nr4gOmHHBpgFdfw6Lc= github.com/ipfs/go-log v0.0.1/go.mod h1:kL1d2/hzSpI0thNYjiKfjanbVNU+IIGA/WnNESY9leM= -github.com/jbenet/goprocess v0.0.0-20160826012719-b497e2f366b8 h1:bspPhN+oKYFk5fcGNuQzp6IGzYQSenLEgH3s6jkXrWw= +github.com/jbenet/go-cienv v0.1.0/go.mod h1:TqNnHUmJgXau0nCzC7kXWeotg3J9W34CUv5Djy1+FlA= github.com/jbenet/goprocess v0.0.0-20160826012719-b497e2f366b8/go.mod h1:Ly/wlsjFq/qrU3Rar62tu1gASgGw6chQbSh/XgIIXCY= +github.com/jbenet/goprocess v0.1.3 h1:YKyIEECS/XvcfHtBzxtjBBbWK+MbvA6dG8ASiqwvr10= +github.com/jbenet/goprocess v0.1.3/go.mod h1:5yspPrukOVuOLORacaBi858NqyClJPQxYZlqdZVfqY4= github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=