Commit Graph

381 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
Eng Zer Jun 2977046a4c all: use `T.TempDir` to create temporary directory
The directory created by `T.TempDir()` and is automatically removed when
the test and all its subtests complete.

Reference: https://pkg.go.dev/testing#T.TempDir
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2022-03-04 08:18:24 -08:00
Tamás Gulácsi c986ee3c62
Use modernc.org/sqlite (#1581)
* Use modernc.org/sqlite

This way it can be enabled by default, as it is a cgo-free, Go-only package.
No need for build tags, conditional compilation (whether libsqlite3-dev is installed).

* make.go: Remove unused -sqlite flag

* Remove use of -sqlite flag
2021-12-27 12:18:08 -08:00
Brad Fitzpatrick 4fa9c80be0 index: when reindexing fails due to missing blob, show some examples 2021-10-24 19:36:16 -07:00
Tamás Gulácsi 1c400bd5b3 Remove unused code
as `staticcheck -checks=U1000` suggested.
2021-08-09 17:34:14 +02:00
Ian Denhardt d8fa9eb29c
Remove pkg/index/sqlindex (#1268)
This is not used anywhere else in the codebase, and duplicates the
functionality of pkg/sorted/sqlkv.
2021-08-01 22:26:37 -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
aviau 4b0d788149 index: small docs improvements
- Document that we use an '|indexed' suffix in the 'have:' key to mark
  indexed blobs.

- Don't refer to GetOwnerClaims. This method no longer exists and was
  replaced by AppendClaims. Don't bother naming the exact Index
  interface method this key serves but instead focus on explaining what
  information we store in that key.
2021-01-16 23:14:35 -05:00
aviau 127297ff99 go fmt ./... + add CI test
Some code was merged without being fmt-compliant. This
PR runs `go fmt ./...` and adds a test to github workflows
to verify that pull requests are fmt-compliant.
2021-01-16 23:12:12 -05:00
aviau aa0ef5a550 index: based on sorted.KeyValue 2021-01-11 15:07:20 -08:00
mpl c243487bdb pkg/index/sqlite: fix tests
Long broken since the sha224 switch.

Updates #1085

Change-Id: I2dda3dac6bd3c8006be0974bdc9be402e25b7429
2018-08-29 03:39:05 +02:00
Euan Kemp d456c989b1 pkg/index: correct test for unindexed attribute
Fixes #1199

Change-Id: I294bd6f09aef1ea50dda7e20038aee7993ffd181
2018-07-26 12:25:41 -07:00
Euan Kemp 13a8e94895 pkg/client: return error for unindexed attr search
Calling 'GetPermanodesWithAttr', as currently written, will return an
empty list for any unindexed parameters.

Rather than always returning an empty list if the user asks for a
unindexed attribute, error out.

Also add documentation of this potential foot-gun for users of the
client.

Change-Id: Iadc1b5a00aa709584affb89a1397e82aaffb692f
2018-07-25 12:56:40 -07:00
Stephen Searles a462466f37 perkeepd: added --keep-going flag to start after index/recovery errors
In order to facilitate manual recovery in severe scenarios, the
--keep-going flag will make the server come back online even when there
are index or recovery errors. This will allow further querying on the
unhealthy server to identify missing data or to extract data for
migration to a new/healthy instance.

Fixes #1166

Change-Id: I4153905757d9e7d8014780dd5660a862cb8ba1ab
2018-05-18 22:29:12 -04:00
Brad Fitzpatrick 8e71a705db pkg/serverinit: remove reindex parameter to InstallHandlers
Push it down into the index.

Change-Id: I327bfcbc314b652d5f24a457e1b62b138a187db5
2018-05-14 23:13:32 -04: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 6b88e2a73f internal/images: broaden pattern that matches HEIC images
A bunch of mine had a larger initial ftyp box, which broke the second
part of the pattern. But the second part of the pattern doesn't matter
anyway.  This only needs to casually recognize them. A later full
parse will determine what they really are.

This also adds some new debugging when CAMLI_DEBUG is true.

Change-Id: Ib4adc9b5447a64ba4682624e42b55f1d65779ef7
2018-04-27 12:29:00 -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 1aeadf4a8a pkg/index: on slurping bogus gps coordinate, log instead of panicking
If a GPS coordinate is bogus, we should have caught it when receiving
the blob, and not write it out as an index row.
If we did not, we end up catching it when trying to slurp it to the
corpus. At this point there's no reason to penalize the user by
panicking, we can instead skip it and log about the error.

Change-Id: Ie40479befca78d8b5da343ef1a8420f703f07cb7
2018-04-24 17:53:33 -07:00
Brad Fitzpatrick a062b701c9 all: more log spam & logging consistency cleanup
Change-Id: Ibc38c2eed86e75afb064ba25ba586494c813f56c
2018-04-22 11:30:02 -07:00
Brad Fitzpatrick 38d0075c3a all: make log lines a bit more consistent
Change-Id: I06c5bbe072c9857ca3afbf97d14146b9cd96a49e
2018-04-22 08:51:43 -07:00
Brad Fitzpatrick ca76a40bbc Rename camlistored to perkeepd.
Updates #981

Change-Id: I8fe43c240c149074c23128a89ab426af9cbf94b4
2018-04-21 11:06:09 -07:00
Brad Fitzpatrick a13abdeb8c cmd/camput: add flag to specify hash function for raw blobs
Also a bit more logging around indexing in debug mode.

Change-Id: I2eb67cfec12cff102ba64b17de0369bde38e416a
2018-04-20 21:02:43 -07:00
Brad Fitzpatrick 61de9881da pkg/index: redo indexing of a blob when CAMLI_REDO_INDEX_ON_RECEIVE is set
So an upcoming HEIC reindexing tool.

Updates #969

Change-Id: If194904d770bb670fa581c4e5e09c303806bc784
2018-04-20 19:40:11 -07:00
mpl 3014bd7413 pkg/index: read EXIF bytes when HEIC file
Updates #969

Change-Id: I11cc1668b853fe5bc2d076addda1a60c08be1dc5
2018-04-18 17:39:38 +02:00
mpl 149212b828 internal/images: reset err to nil on no EXIF found
the changes to DecodeConfig in ce955adf48
moved the call to image.DecodeConfig to before the call to exif.Decode,
because we need to do that for the HEIF case.

After the call to exif.Decode, if err is nil and is not a short read
error, we ignore the error and the code goes on. To mark that intent,
we should have explicitly set the err to nil at this point. However,
that omission did not matter before
ce955adf48 because image.DecodeConfig
was the last setter of the error.

Now that it has moved up, we do have to explicitly reset the err to nil.
While we were at it, we rewrote the whole logic to be easier to read.

This seems to fix all the tests in pkg/index and pkg/search.

Change-Id: Id0b711179ccb1365b851d3e86ecb70d47ac358b4
2018-04-18 03:41:14 +02:00
mpl 139cd8bd01 vendor: add go4.org/media/heif
At rev 7b81d6948d11710f710d0c4ef52daac1dc7c936b

Updates issue #969

Change-Id: I6f21de58c0865d3cbc8186b3a6834444b6d1206e
2018-04-13 00:10:11 +02: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
mpl db2604f981 pkg/schema: break static-sets in subsets for large directories
The current maximum size for a schema blob is 1MB. For a large enough
directory (~20000 children), the resulting static-set JSON schema is
over that maximum size.

We could increase that maximum, but we would eventually hit the maximum
blob size (16MB), which would only allow for ~300000 children. Even if
that is an uncommon size, it is technically possible to have such large
directories, so I don't think it would be reasonable to restrict users
to such a limit. So it does not seems like enough of a solution.

The solution proposed in this CL is to spread the children of a
directory (when they are more numerous than a given maximum, here set to
10000) onto several static-sets, recursively if needed. These
static-sets (subsets of the whole lot of children) are stored in the new
"mergeSets" field of their parent static-set schema. The actual fileRefs
or dirRefs, are still stored in the "members" field of the subset they were
spread in. The "mergeSets" and "members" field of a static-set are therefore
mutually exclusive.

Fixes #924

Change-Id: Ibe47b50795d5288fe904d3cce0cc7f780d313408
2018-02-09 01:36:38 +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
Brad Fitzpatrick 66353d17bf pkg/index: pull a []byte literal out into a global
Change-Id: Ibf36b7ddde01aa1e444981e8d9c1af103cc48501
2018-01-30 16:49:43 -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
mpl c1d6bd06b0 pkg/index: fix corpus AppendClaims use of signerFilter
Follow-up of ec66bcc871

This change should be the last of its kind, in the corpus at least, and
should make most searches and the web UI usable again, with both kinds
of hashes (sha1 and sha224).

Updates #537

Change-Id: Icfe9e8aaab031313612c555b7601895aeba16a7c
2018-01-24 18:41:41 +01:00
mpl 0c1b99b4c5 pkg/index: fix location in corpus to use signer ID instead of blobRef
Follow-up of ec66bcc871

Updates #537

Change-Id: Ib4dc62ae6be91c061dc6de4bfdd617785abdaab6
2018-01-23 19:11:52 +01:00
Brad Fitzpatrick 87694c3ba8 Merge "all: simpify constructs by running gofmt -s on all code" 2018-01-21 19:14:54 +00: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
mpl 22734c9d29 pkg/index: fix corpus tests
Follow-up of ec66bcc871

I had run the pkg/search tests to see if no high-level search was
broken, for forgot about pkg/index itself, whoops.

Change-Id: Iec3aa28aca82ac6773983ea9df9ade26a48fc4a7
2018-01-19 20:53:41 +01:00
Mathieu Lonjaret 4ed9175f01 Merge "pkg/index: use the gpg ID (and not its blobRef) in corpus" 2018-01-19 16:56:38 +00:00
mpl ec66bcc871 pkg/index: use the gpg ID (and not its blobRef) in corpus
Otherwise claims that are actually from the same signer, end up being
treated as from different signers, because some of the claims were
signed by the sha1 version and others by the sha224 one.

TODO in follow-up CLs: similar fixes in rest of the corpus, such as with
claimPtrsAttrValue. See if non-corpus index functions/methods suffer
from the same problem.

Change-Id: Icbc70e97edc569f46e575d79aaf4359b33996053
2018-01-19 17:26:48 +01: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
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 0e8980b54b blobserver: change BlobStatter interface, simplify proxycache
This addresses a long-standing TODO in the BlobStatter interface to
clean it up. Just like all new Go programmers, I misused channels in
APIs. I should've cleaned this up years ago.

While here, I also added a context.

The rest should get contexts later.

This also cleans up a few things here & there.

The pkg/client statting no longer does batching, which added a lot of
complexity. There was a comment saying something like "once we have
SPDY, we can delete this". Well, we have HTTP/2 now, so seems
deletable.

All tests pass.

Change-Id: I034ce07d9b70e5cc9e5482213368993e638d4bc8
2018-01-08 16:54:52 -08:00
Brad Fitzpatrick 9265c980de all: change github.com/camlistore/camlistore to github.com/perkeep/perkeep
Change-Id: I0d612bf450e9e8d9ce0767c5a0cb0c44c0d8704f
2018-01-05 19:49:59 -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