Commit Graph

339 Commits

Author SHA1 Message Date
luz paz d605f86c82 Fix various typos
Found via `codespell -q 3 -S ./clients/web/embed,./clients/chrome -L ba,everytime,impres,keypair,msdos,pres,ro,te,ue`
2022-05-02 14:31:09 -07:00
Tamás Gulácsi 1c400bd5b3 Remove unused code
as `staticcheck -checks=U1000` suggested.
2021-08-09 17:34:14 +02:00
Alex Tsui 3891d3fe51
pkg/search: Add untagged predicate (#1393)
Add `is:untagged` predicate to query untagged permanodes via the UI
2021-08-04 22:28:05 -04:00
Tamás Gulácsi b0126ed7cf
buildsystem: update dependencies (#1394)
* Update goleveldb to v1.0.0

* Update goleveldb to 64b5b1c739545ed311fb9d9924d19d188fabdc83

- fix data race (758128399b1df3a87e92df6c26c1d2063da8fabe)
- optimizations from bytes.Buffer (42cf80bcefdf184caead3785a11b06fe6dfe9649)
- fsync after creating new manifest (eb135432c5aa4c841c91f3fdc871f07a94aa5a44)

* Update all dependencies.

Keep google.golang.org/api on v0.42.0 as that's the latest not borking
servicemanagement/v1 APIService.Enable.

* Pin bazil.org to latest version that supports macOS

Support has been removed in mid-2018 - see
https://github.com/bazil/fuse/issues/224
for details.

* pkg/blobserver/sftp: Make it pass on Windows

Translate paths with filepath.ToSlash

* Remove macos test cache

* go mod tidy

Remove zembed*.go as pkg/fileembed is history

* Remove caching in tests-linux

Co-authored-by: Tamás Gulácsi <tamas@gulacsi.eu>
2021-07-31 18:54:25 -04:00
Alexandre Viau 8171ea5b51
go 1.15 -> 1.16 (#1397) 2021-07-28 23:31:22 -04:00
Alexandre Viau fb961cf310
make codebase go-vet-clean (#1379)
Co-authored-by: Bob Glickstein <bobg@emphatic.com>
2021-07-26 21:19:53 -04:00
aviau 231ba4233f pkg/schema: create CamliType type
Create a CamliType type in pkg/schema and use it in a couple of
packages.

It can be implemented in other packages as we go.
2021-01-19 00:47:58 -05:00
Mathieu Lonjaret 9a49f0959d Merge "importer/twitter: add likes import" 2018-08-21 23:53:37 +00:00
Niklas Merz 05f86e7846
importer/twitter: add likes import
Import liked tweets via favorites API

Change-Id: I8000bcd20cd895e540ec4d3b36035531172c7cb6
2018-08-14 17:49:37 +02:00
Robert Günzler f7cc51f83b pkg/search: fix dir search with logical not constraints
As demonstrated by the test case added in this commit, a
search panics if the DirConstraint contains a LogicalConstraint
with Op set to "not". This is because the isFileOrDirConstraint
function doesn't account for unset "B".

Change-Id: I111ace62486160254ba22ab1498de78cde2a5e9b
2018-08-08 02:55:29 +02:00
mpl 2549b78425 server/perkeepd/ui: new directory view
The old directory aspect (directory_detail.js), was done before the
current (React-based) look and layout of the web UI. It is still
functional, but does not look very good, and does not match the look of
the rest of the web UI.

Therefore, this change adds a new directory layout, with a
blob container approach and layout similar to the one for permanode
sets, and replaces the old one as the default Directory aspect.

It seems to have performance issues (slow loads), but I think it's
better to enable it now, rather than wait again for many months to
land it. Especially if it forces us to address said performance issues.
If it's too bad and users want the old one in the meantime, it should be
easy to re-enable the old as the default.

Change-Id: Ieb0cde8290f0a058008cdc73b596ad1a330ded1a
2018-05-15 18:53:06 +02:00
mpl 2e052c5fe5 pkg/index: do not return error if dir is empty
When looking for the children of a directory, we used
to return an os.ErrNotExist if no children were found.
We now only return os.ErrNotExist if the directory
itself does not exist.

Fixes #1152

Change-Id: I8dd827f5597535d98c898302d0a1ca5399b03476
2018-05-08 19:51:00 +02:00
mpl 03103f00fa pkg/search: add some DirConstraint search functionality
The DirConstraint type already existed but wasn't functional as none of
the matching for any of its fields was implemented.

That functionality is required by two other features:

1) Browsing directories in the publisher requires getting information
about the children of the directory. In practice that can be achieved
with a search on the directory, accompanied with some describe rules.
But that comes with limitations, such as:
-no control over the sorting of the described children in the response
-max number of children in the response (and no way to overcome it since
you can't "continue" on a describe)
hence the need for a direct search of a directory's children.
This is implemented as DirConstraint/FileConstraint.ParentDir and will
be used in https://camlistore-review.googlesource.com/8286

2) Looking for files/directories shared by transitivity.
Knowing if an item is the target of a share claim is easy enough once
enough of ClaimConstraint is implemented. But in order to find out if an
item is effectively shared because one of its ancestors (directory) is
the target of a share claim, with transitivity set, we need some sort of
search that can do directories traversal. This is implemented as
DirConstraint.RecursiveContains and it will be used as a subquery in
https://camlistore-review.googlesource.com/9866.

Now implemented:
	DirConstraint.FileName
	DirConstraint.BlobRefPrefix
	DirConstraint.ParentDir
	DirConstraint.TopFileCount
	DirConstraint.Contains
	DirConstraint.RecursiveContains

ParentDir will also allow us to quit relying on the treeHandler in the
web UI,
and to use the more generic search queries mechanism instead.

Change-Id: I022cb51732ee4271906271fd75c6f737856b6165
2018-05-01 17:55:41 -07:00
Brad Fitzpatrick 2b720aa101 search, index: rewrite, fix the "map" sort algorithm, index camliNodeType
Change-Id: Idb0e44c3f61bea9fc2cc76619223b86aa5aa4c58
2018-04-26 15:19:03 -07:00
Brad Fitzpatrick ad0b3918b7 search: optimize searching for a single blob
Fixes #1118

Change-Id: I6e63faeb3f994a3cc4718d92894f513d38ac371f
2018-04-26 13:56:32 -07:00
mpl 8b30515218 internal/geocode: change Lookup behavior wrt to AltLookupFn
Even when AltLookupFun was defined, Lookup used to fallthrough after the
AltLookupFn, depending on what AltLookupFn returned.
This means in some cases, our tests in pkg/search did end up calling the
Google API (which was not intended). We found out because with the new
dependency on an API key for the Google service, we now rely on reading
the key from the config dir, which is wired to panic if it is accessed
during tests.

This change therefore simplifies Lookup, by making it return the results
of the AltLookupFn call, if AltLookupFn exists.

Change-Id: Ie196f892f36d309c725a6e869094364d49cffdc8
2018-04-25 18:01:39 -07:00
Brad Fitzpatrick a062b701c9 all: more log spam & logging consistency cleanup
Change-Id: Ibc38c2eed86e75afb064ba25ba586494c813f56c
2018-04-22 11:30:02 -07:00
mpl aaac9635d2 pkg/search: allow empty expression
We had checks in place to return an error if a search query had both
no constraint and no expression. However:
1) we accepted " " as a valid search expression (which is the
work-around that was used by the web UI for the index page)
2) the rest of the code seems to be coping well if we remove these
checks, which this CL does.

This allows us to remove the q=" " trick in the web UI, which does not
seem to be breaking anything, and has the side-effect of improving the
map aspect story (issue 1081). Because with this change, the index page
is not considered anymore as the result of a search query, which means
if one then clicks on an image, one then gets to the image permanode as
a "standalone" item, instead of as one item part of set.
As a consequence:
1) If one then clicks on the map aspect, one gets only this item on the
map (with the proper zoom level), instead of all the items from the
index page.
2) The other side of the coin is left/right navigation does not "work"
anymore in this context, since the item is not part of a set anymore.

In other words, this change makes the index page (i.e. the empty search)
a somewhat particular case, and makes it behave a little differently
from the result of any other (non-empty) search.

Updates issue #1081

Change-Id: Ibbb1711c67c7cf8adaf94ab5d2c68c3755e4983b
2018-04-21 17:44:43 -07:00
Brad Fitzpatrick 973df545ef search: support wildcards in filename search
Change-Id: Ic8a1b2cdad3215f7e850bcc47467e0b4f8e92c4f
2018-04-20 13:36:43 -07:00
mpl 20ffe5af92 pkg/index: convert more funcs to using a GPG key ID
corpus.AppendPermanodeAttrValues and corpus.PermanodeAttrValue now take
a GPG key ID as their signer filter attribute, instead of a blob Ref.

Fix search package accordingly.

Fixes #1069

Change-Id: I0ef519fc16cf357adb84c32fa6e5bf92d8a0de26
2018-03-02 19:58:18 +01:00
Mathieu Lonjaret 4d65ed951b Merge "pkg/search: start to make funcs use a GPG key ID instead of blobRef" 2018-02-06 23:57:16 +00:00
mpl b89bf256d1 pkg/search: start to make funcs use a GPG key ID instead of blobRef
Introduction of an Owner type  in pkg/index.
Related changes in pkg/index and pkg/serverinit.

Fixes #1047

Change-Id: Ifc316865833349d5202b5085e8f2c1235f3f2220
2018-02-07 00:54:38 +01:00
Paul Lindner 84b2c6b3e4 all: various lint fixes
- correct logging that logged functions instead of their value
- use ID vs Id naming
- use correct function names in comments

Change-Id: I61562cef7ebac7337ec6c85312cdf7915cb1a84b
2018-02-05 11:59:00 -08:00
Mathieu Lonjaret 6e8a5930c9 all: make server advertise when it has legacy SHA-1 indexes, use that info
when its wholeref index lines contain any "sha1-" wholeref lines.

Then, have the client use that info when uploading files to also
compute the sha-1 (in addition to the sha-224) and ask the server for
both.

By client, we mean changes to cmd/camput, to pkg/client functions (for
camput and other Go clients, such as the apps), and to the web UI.

Also, add a -sha1 mode to devcam server, as well as the
CAMLI_SHA1_ENABLED env var, to facilitate testing/debugging of the
legacy sha1 mode.  Fix/document unrelated options in devcam server
while we're at it.

Change-Id: I369679d2a4719f6f8b409f78dd4d065e13a3f62f
2018-01-31 01:10:52 +01:00
Paul Lindner 459c75410e all: more renaming of Camlistore to Perkeep
Change-Id: I118e3cbcf20d80afeffc84f001388c4556f21628
2018-01-30 03:02:56 -08:00
Paul Lindner 6d2d9714de all: simpify constructs by running gofmt -s on all code
Change-Id: Idc12ddcfe8f735d77c6baa942f5bb7a2c7d9b40b
2018-01-21 10:27:12 -08:00
Brad Fitzpatrick 194d4f9443 blobserver, all: add contexts to ReceiveBlob, Fetch & million resulting deps
I had intended for this to be a small change.

I was going to just add context.Context to the BlobReceiver interface,
but then I saw blob.Fetcher could also use one, so I decided to do two
in one CL.

And then it got a bit infectious and ended up touching everything.

I ended up doing SubFetch in the process by necessity.

At a certain point I finally started using context.TODO() in a few
spots, but not too many. But removing context.TODO() will come in the
future. There are more blob storage interfaces lacking context, too,
like RemoveBlobs.

Updates #733

Change-Id: Idf273180b3f8e397ac5929c6d7f520ccc5cdce08
2018-01-18 16:22:16 -08:00
Paul Lindner 32e37c926d Merge "vendor: Update github.com/gorilla/websocket to v1.2.0" 2018-01-11 21:26:51 +00:00
Paul Lindner 837fe8ac46 vendor: Update github.com/gorilla/websocket to v1.2.0
Maps to rev: gorilla/websocket@ea4d1f681b

Also adjust the search websocket code to use the new API
which does proper origin checks.

Changelog: https://github.com/gorilla/websocket/releases/tag/v1.2.0

Change-Id: Ie25490b6319a98345aa6272e9eabc35c298bc06d
2018-01-11 10:42:39 -08:00
Brad Fitzpatrick 38f10a7bd0 all, testhooks: use sha224 by default, add hook for some tests to use sha-1
Remove the blob.SHA{1,224}From{Bytes,String} constructors too. No
longer used. This adds blob.RefFromBytes which was missing. We had
blob.RefFromString. Now everything uses blob.RefFrom* instead of
specifying a hash function.

Some tests set a flag to force use of SHA-1 because there was too much
golden data to update. We can remove those one-by-one over time as we
fix up tests.

Updates #537

Change-Id: Ibe6428089a6221594c2b751f53f98b03b5a28dc2
2018-01-09 20:03:38 -08:00
Brad Fitzpatrick 57648c6b83 all: update copyright holder from Google Inc to The Perkeep Authors
The AUTHORS file is the list of copyright holders.
2018-01-03 16:52:49 -08:00
Brad Fitzpatrick c3d05cdce9 Move more packages out of pkg/ and into internal/
Moved hashutil, httputil, osutil, netutil,
images, media, magic, video, and rollsum.
2018-01-02 21:03:30 -08:00
Brad Fitzpatrick 11e9c5567c Move some packages from perkeep.org/pkg to perkeep.org/internal
Notably: pkg/misc all moves.

And pkg/googlestorage is deleted, since it's not used. Only the
x/net/http2/h2demo code used to use it, but that ended in
https://go-review.googlesource.com/33230 (our vendored code is old).
So just nuke that dir for now. When it's refreshed, it'll either be
gone (dep prune) or new enough to not need googlestorage.

Also move pkg/pools, pkg/leak, and pkg/geocode to internal.

More remains.

Change-Id: I2640c4d18424062fdb8461ba451f1ce26719ae9d
2018-01-01 20:54:48 -08:00
Brad Fitzpatrick d6a0b05df0 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 16:03:34 -08:00
Steven L. Speek 13c084739c search: expression/constraint aliases
The search handler can store and retrieve search aliases.
Keyword namedSearch handles these new atoms of the form
named:foo.

Creating an alias has been implemented using a client in
the camtool subcommands named-search-get and named-search-set.

Change-Id: I7960f83bad464eb1a971c07f33631744a5eea814
2017-12-29 21:41:20 -08:00
Paul Lindner 04b9c0b1c4 pkg: lint fixes for "context.Context should be the first parameter of a function"
Change-Id: I0185eec5616c72d859978aec03880860421c7193
2017-12-13 11:33:21 -08:00
Paul Lindner 1383869054 all: lint fixes for "receiver name should be consistent with previous receiver name"
Change-Id: I05275cd20c92349e37365e2cbd29fa9f8d834101
2017-12-13 11:31:25 -08:00
Paul Lindner c58e07942e all: lint fixes for "if block ends with a return statement"
Change-Id: I1c244f14995478860c19695695f287d541a7a39c
2017-12-13 11:31:25 -08:00
Paul Lindner 15feaeb24c all: lint fixes for 'error strings should not be capitalized or end with punctuation or a newline'
Change-Id: I9c3766a51ac8be694ae76befff4b6fa9a85e34eb
2017-12-11 06:13:25 -08:00
mpl a91a98c58a pkg/test: remove FakeIndex
And fix its main users: tests in pkg/search.

Fixes #883

Change-Id: Ib04b8d6f2d56bfb24a8900520c97b24bccb3c78b
2017-12-01 19:59:26 +01:00
Paul Lindner b09cd377d7 Switch to stdlib context from golang.org/x/net/context
This switches most usages of the pre-1.7 context library to use the
standard library.  Remaining usages are in:

  app/publisher/main.go
  pkg/fs/...

Change-Id: Ia74acc39499dcb39892342a2c9a2776537cf49f1
2017-11-26 01:12:26 -08:00
mpl e8077cba6e pkg/search: print describe speed only in debug
Change-Id: I4f22ccf907702b2d2bc7ada06af7ef85b2f1963a
2017-11-17 17:42:01 +01:00
Paul Lindner fa46c3935d Correct various misspelled words
Change-Id: I236e880526e4c2b0bd318da041983d557e0aa885
2017-09-11 08:33:31 -07:00
mpl 8d4a554c3a pkg/search: fix bestByLocation test
related to 93c6d682d2

Change-Id: Ide7a120f501f4a140c039c0666b05f82efe510d2
2017-08-29 23:13:19 +02:00
mpl 088cdae82d server/camlistored/ui: map aspect improvements
-keep the browser URL bar in sync with the current search/zoom-level

-introduce the "map:" predicate, to be used as the current viewport in
the map aspect. This was previously achieved with the locrect predicate. We
try to keep this new predicate unknown to the server, and replaced on
the fly by an equivalent locrect predicate.

-stay on the map aspect when the search expression has a map predicate.
Same thing when loading a URL with a map predicate parameter: try to
load directly on map aspect, instead of going to search aspect first.

-make sure there's only at most one map query in flight at all times

Change-Id: Ibf928ee5c926670c221f212f14ca9799e1e7bb79
2017-08-29 18:13:07 +00:00
Brad Fitzpatrick 93c6d682d2 pkg/search: change corpus enumeration signatures for speed
Avoid select overhead in hot paths. Just use funcs.

Also, for sort-by-map searches, don't do a describe and pass over all
the results doing location lookups a second time. Remember the
location from the initial matching. Cache it on the search value.

Reduces some sort-by-map searches from 10 seconds to 3 seconds for
me. (still too slow, but good start)

Change-Id: I632954738df9accd802f28364ed11e48ddba0d14
2017-08-29 11:10:10 -07:00
mpl 2d3b781103 pkg/search: add "ref:" predicate support
The "ref:prefix" search predicate is simply the equivalent of the

Constraint {
	BlobRefPrefix: prefix,
}

search constraint.

The "ref:prefix" search expression was already supported by the search
box of the web UI, but as opposed to (all, I think) other search
expressions, it was not supported server-side. Which means, it had to be
converted to a search Constraint as the above, before being sent in the
query.

This change therefore fixes this inconsistency. In addition, but
relatedly, since the map aspect relies on expressing the zoom-level as a
locrect expression, it is much simpler if the search query it uses only
has to be constructed from search expressions, and without search
constraints. So if we want to be able to support marking a single node
search with the map aspect, while dealing only with search expressions,
this change is necessary.

Fixes #939

Change-Id: Ia58f410198ecd1f7e0981321da370d687df3a120
2017-08-17 01:23:55 +02:00
Mathieu Lonjaret a7ec4646ca Merge changes I28c1184a,I0004c9ff
* changes:
  server/camlistored/ui: use marker cluster in map aspect
  server/camlistored/ui: on zooming/panning on map aspect, do new search
2017-08-16 22:56:59 +00:00
mpl 7832801040 server/camlistored/ui: on zooming/panning on map aspect, do new search
This change makes zooming and panning on the map aspect send a new
"MapSort" search query, so that the (1000, by default) most relevant
results for the currently displayed area always appear as markers
after a zoom/pan.

This required completely "lifting up" (in React lingo) the currentSearch
state out of the Header class, and into the Index class, which should
have already been done in a56372830a. This
is necessary because we need the expression in the search box to be mutable
both by the user('s input) and by the map aspect, which represents the
zoom level as a trailing "locrect" predicate in the search expression.

Fixes #938

Change-Id: I0004c9ff09f03b4f1d95a35e54605689eebf0c1a
2017-08-16 21:39:46 +02:00
mpl 7c02f7eb57 pkg/search: fix Around algo with unsorted source
The search for the Around blobRef was using the equality operator,
instead of an ordering operator, which was incorrect.

Also, if the Around blob.Ref had not been found during the search, we
were only returning early for special cases, which is incorrect. As soon
as we know that an Around blob is wanted, and we know it has not been
found, the search should abort.

Relatedly, a formal check to enforce that Around is incompatible with
MapSorted was added.

Finally, some tests to check the Around algorithm, in the case where we
don't use a sorted source, were added.

Change-Id: I94fc984cf4130badc879cdadaba718ef6361c9b7
2017-08-16 20:32:35 +02:00