2013-11-16 23:00:30 +00:00
|
|
|
package index
|
|
|
|
|
|
|
|
import (
|
2017-11-26 09:05:38 +00:00
|
|
|
"context"
|
2016-04-22 04:34:24 +00:00
|
|
|
"sync"
|
2013-11-16 23:00:30 +00:00
|
|
|
"time"
|
|
|
|
|
Rename import paths from camlistore.org to perkeep.org.
Part of the project renaming, issue #981.
After this, users will need to mv their $GOPATH/src/camlistore.org to
$GOPATH/src/perkeep.org. Sorry.
This doesn't yet rename the tools like camlistored, camput, camget,
camtool, etc.
Also, this only moves the lru package to internal. More will move to
internal later.
Also, this doesn't yet remove the "/pkg/" directory. That'll likely
happen later.
This updates some docs, but not all.
devcam test now passes again, even with Go 1.10 (which requires vet
checks are clean too). So a bunch of vet tests are fixed in this CL
too, and a bunch of other broken tests are now fixed (introduced from
the past week of merging the CL backlog).
Change-Id: If580db1691b5b99f8ed6195070789b1f44877dd4
2018-01-01 22:41:41 +00:00
|
|
|
"perkeep.org/pkg/blob"
|
|
|
|
"perkeep.org/pkg/types/camtypes"
|
2013-11-16 23:00:30 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type Interface interface {
|
2016-04-22 04:34:24 +00:00
|
|
|
sync.Locker
|
|
|
|
RLock()
|
|
|
|
RUnlock()
|
|
|
|
|
2013-11-17 21:44:49 +00:00
|
|
|
// os.ErrNotExist should be returned if the blob isn't known
|
2016-04-22 04:34:24 +00:00
|
|
|
GetBlobMeta(context.Context, blob.Ref) (camtypes.BlobMeta, error)
|
2013-11-17 21:44:49 +00:00
|
|
|
|
|
|
|
// Should return os.ErrNotExist if not found.
|
2016-04-22 04:34:24 +00:00
|
|
|
GetFileInfo(ctx context.Context, fileRef blob.Ref) (camtypes.FileInfo, error)
|
2013-11-17 21:44:49 +00:00
|
|
|
|
|
|
|
// Should return os.ErrNotExist if not found.
|
2016-04-22 04:34:24 +00:00
|
|
|
GetImageInfo(ctx context.Context, fileRef blob.Ref) (camtypes.ImageInfo, error)
|
2013-11-17 21:44:49 +00:00
|
|
|
|
2014-04-04 23:23:11 +00:00
|
|
|
// Should return os.ErrNotExist if not found.
|
2016-04-22 04:34:24 +00:00
|
|
|
GetMediaTags(ctx context.Context, fileRef blob.Ref) (map[string]string, error)
|
2014-04-04 23:23:11 +00:00
|
|
|
|
2016-05-12 04:05:43 +00:00
|
|
|
// GetFileLocation returns the location info (currently Exif) of the fileRef.
|
|
|
|
// Should return os.ErrNotExist if fileRef is not found,
|
|
|
|
// is not a file, or it has no location info.
|
|
|
|
GetFileLocation(ctx context.Context, fileRef blob.Ref) (camtypes.Location, error)
|
|
|
|
|
2013-11-17 21:44:49 +00:00
|
|
|
// KeyId returns the GPG keyid (e.g. "2931A67C26F5ABDA)
|
|
|
|
// given the blobref of its ASCII-armored blobref.
|
|
|
|
// The error is ErrNotFound if not found.
|
2016-04-22 04:34:24 +00:00
|
|
|
KeyId(context.Context, blob.Ref) (string, error)
|
2013-11-17 21:44:49 +00:00
|
|
|
|
2013-11-17 22:54:30 +00:00
|
|
|
// AppendClaims appends to dst claims on the given permanode.
|
2018-01-31 18:30:47 +00:00
|
|
|
// The signerFilter - a GPG key ID (e.g. "2931A67C26F5ABDA) -
|
|
|
|
// and attrFilter are both optional. If non-zero,
|
2013-11-17 22:54:30 +00:00
|
|
|
// they filter the return items to only claims made by the given signer
|
|
|
|
// or claims about the given attribute, respectively.
|
|
|
|
// Deleted claims are never returned.
|
2013-11-18 00:52:51 +00:00
|
|
|
// The items may be appended in any order.
|
2013-12-09 13:15:34 +00:00
|
|
|
//
|
|
|
|
// TODO: this should take a context and a callback func
|
|
|
|
// instead of a dst, then it can append to a channel instead,
|
|
|
|
// and the context lets it be interrupted. The callback should
|
|
|
|
// take the context too, so the channel send's select can read
|
|
|
|
// from the Done channel.
|
2016-04-22 04:34:24 +00:00
|
|
|
AppendClaims(ctx context.Context, dst []camtypes.Claim, permaNode blob.Ref,
|
2018-01-31 18:30:47 +00:00
|
|
|
signerFilter string,
|
2013-11-17 22:54:30 +00:00
|
|
|
attrFilter string) ([]camtypes.Claim, error)
|
|
|
|
|
2013-11-17 21:44:49 +00:00
|
|
|
// TODO(bradfitz): methods below this line are slated for a redesign
|
|
|
|
// to work efficiently for the new in-memory index.
|
|
|
|
|
2013-11-16 23:00:30 +00:00
|
|
|
// dest must be closed, even when returning an error.
|
|
|
|
// limit <= 0 means unlimited.
|
2016-04-22 04:34:24 +00:00
|
|
|
GetRecentPermanodes(ctx context.Context, dest chan<- camtypes.RecentPermanode,
|
2013-11-16 23:00:30 +00:00
|
|
|
owner blob.Ref,
|
2013-11-26 04:35:59 +00:00
|
|
|
limit int,
|
|
|
|
before time.Time) error
|
2013-11-16 23:00:30 +00:00
|
|
|
|
|
|
|
// SearchPermanodes finds permanodes matching the provided
|
|
|
|
// request and sends unique permanode blobrefs to dest.
|
|
|
|
// In particular, if request.FuzzyMatch is true, a fulltext
|
|
|
|
// search is performed (if supported by the attribute(s))
|
|
|
|
// instead of an exact match search.
|
|
|
|
// If request.Query is blank, the permanodes which have
|
|
|
|
// request.Attribute as an attribute (regardless of its value)
|
|
|
|
// are searched.
|
|
|
|
// Additionally, if request.Attribute is blank, all attributes
|
|
|
|
// are searched (as fulltext), otherwise the search is
|
|
|
|
// restricted to the named attribute.
|
|
|
|
//
|
|
|
|
// dest is always closed, regardless of the error return value.
|
2016-04-22 04:34:24 +00:00
|
|
|
SearchPermanodesWithAttr(ctx context.Context, dest chan<- blob.Ref,
|
2013-11-16 23:00:30 +00:00
|
|
|
request *camtypes.PermanodeByAttrRequest) error
|
|
|
|
|
|
|
|
// ExistingFileSchemas returns 0 or more blobrefs of "bytes"
|
|
|
|
// (TODO(bradfitz): or file?) schema blobs that represent the
|
|
|
|
// bytes of a file given in bytesRef. The file schema blobs
|
|
|
|
// returned are not guaranteed to reference chunks that still
|
|
|
|
// exist on the blobservers, though. It's purely a hint for
|
|
|
|
// clients to avoid uploads if possible. Before re-using any
|
|
|
|
// returned blobref they should be checked.
|
|
|
|
//
|
|
|
|
// Use case: a user drag & drops a large file onto their
|
|
|
|
// browser to upload. (imagine that "large" means anything
|
|
|
|
// larger than a blobserver's max blob size) JavaScript can
|
|
|
|
// first SHA-1 the large file locally, then send the
|
|
|
|
// wholeFileRef to this call and see if they'd previously
|
|
|
|
// uploaded the same file in the past. If so, the upload
|
|
|
|
// can be avoided if at least one of the returned schemaRefs
|
|
|
|
// can be validated (with a validating HEAD request) to still
|
|
|
|
// all exist on the blob server.
|
2018-01-13 21:40:52 +00:00
|
|
|
ExistingFileSchemas(wholeFileRef ...blob.Ref) (schemaRefs WholeRefToFile, err error)
|
2013-11-16 23:00:30 +00:00
|
|
|
|
|
|
|
// GetDirMembers sends on dest the children of the static
|
|
|
|
// directory dirRef. It returns os.ErrNotExist if dirRef
|
|
|
|
// is nil.
|
|
|
|
// dest must be closed, even when returning an error.
|
|
|
|
// limit <= 0 means unlimited.
|
2017-04-11 13:43:19 +00:00
|
|
|
GetDirMembers(ctx context.Context, dirRef blob.Ref, dest chan<- blob.Ref, limit int) error
|
2013-11-16 23:00:30 +00:00
|
|
|
|
|
|
|
// Given an owner key, a camliType 'claim', 'attribute' name,
|
|
|
|
// and specific 'value', find the most recent permanode that has
|
|
|
|
// a corresponding 'set-attribute' claim attached.
|
|
|
|
// Returns os.ErrNotExist if none is found.
|
|
|
|
// Only attributes white-listed by IsIndexedAttribute are valid.
|
2013-11-17 21:44:49 +00:00
|
|
|
// TODO(bradfitz): ErrNotExist here is a weird error message ("file" not found). change.
|
|
|
|
// TODO(bradfitz): use keyId instead of signer?
|
2016-04-22 04:34:24 +00:00
|
|
|
PermanodeOfSignerAttrValue(ctx context.Context, signer blob.Ref, attr, val string) (blob.Ref, error)
|
2013-11-16 23:00:30 +00:00
|
|
|
|
|
|
|
// PathsOfSignerTarget queries the index about "camliPath:"
|
|
|
|
// URL-dispatch attributes.
|
|
|
|
//
|
|
|
|
// It returns a list of all the path claims that have been signed
|
|
|
|
// by the provided signer and point at the given target.
|
|
|
|
//
|
|
|
|
// This is used when editing a permanode, to figure work up
|
|
|
|
// the name resolution tree backwards ultimately to a
|
|
|
|
// camliRoot permanode (which should know its base URL), and
|
|
|
|
// then the complete URL(s) of a target can be found.
|
2016-04-22 04:34:24 +00:00
|
|
|
PathsOfSignerTarget(ctx context.Context, signer, target blob.Ref) ([]*camtypes.Path, error)
|
2013-11-16 23:00:30 +00:00
|
|
|
|
|
|
|
// All Path claims for (signer, base, suffix)
|
2016-04-22 04:34:24 +00:00
|
|
|
PathsLookup(ctx context.Context, signer, base blob.Ref, suffix string) ([]*camtypes.Path, error)
|
2013-11-16 23:00:30 +00:00
|
|
|
|
|
|
|
// Most recent Path claim for (signer, base, suffix) as of
|
|
|
|
// provided time 'at', or most recent if 'at' is nil.
|
2016-04-22 04:34:24 +00:00
|
|
|
PathLookup(ctx context.Context, signer, base blob.Ref, suffix string, at time.Time) (*camtypes.Path, error)
|
2013-11-16 23:00:30 +00:00
|
|
|
|
|
|
|
// EdgesTo finds references to the provided ref.
|
|
|
|
//
|
|
|
|
// For instance, if ref is a permanode, it might find the parent permanodes
|
|
|
|
// that have ref as a member.
|
|
|
|
// Or, if ref is a static file, it might find static directories which contain
|
|
|
|
// that file.
|
|
|
|
// This is a way to go "up" or "back" in a hierarchy.
|
|
|
|
//
|
|
|
|
// opts may be nil to accept the defaults.
|
|
|
|
EdgesTo(ref blob.Ref, opts *camtypes.EdgesToOpts) ([]*camtypes.Edge, error)
|
|
|
|
|
2017-08-19 05:26:51 +00:00
|
|
|
// EnumerateBlobMeta calls fn for each blob known to the
|
|
|
|
// indexer (which may be a subset of all total blobs, since
|
|
|
|
// the indexer is typically configured to not see non-metadata
|
|
|
|
// blobs). The blobs may be sent in any order. If the context
|
|
|
|
// finishes, the return error is ctx.Err().
|
|
|
|
// If the provided function returns false, iteration ends with a nil
|
|
|
|
// return value.
|
|
|
|
EnumerateBlobMeta(context.Context, func(camtypes.BlobMeta) bool) error
|
2013-11-16 23:00:30 +00:00
|
|
|
}
|