Commit Graph

97 Commits

Author SHA1 Message Date
Jeremy Lakeman
0c5a84c305 Fallback to streaming bytes when rename() fails due to crossing filesystems 2018-05-22 16:05:27 +09:30
Andrew Bettison
faa0f392c5 Improve Rhizome DB path configuration
Change the default 'rhizome.datastore_path' to "rhizome", ie, a sub-
directory of the instance directory.

Add a new erename() operation to "os.h".

Clean up the code around the fix 39f582cca (two commits ago) for a bug
introduced in 2014: the 'rhizome.db' file was always being created in
the instance directory, regardless of the setting of the
'rhizome.datastore_path' config option.

Whenever the Rhizome database is opened (by the server or by a CLI
invocation), if the database file does not exist but there is a
'rhizome.db' file in the legacy location, then move that file (and any
accompanying "blob" and "hash" sub-directories) to the configured
location.

Update copyright notices.
2018-04-17 12:01:02 +09:30
Jeremy Lakeman
39f582ccab Auto move rhizome store when config is first set 2018-04-10 16:50:09 +09:30
Jeremy Lakeman
59b6a70374 Use config to set and remember rhizome database location 2018-04-10 10:52:44 +09:30
Jeremy Lakeman
57767e444d Keep rhizome's external blobs in subfolders, migrating each file on first use 2018-04-10 10:52:44 +09:30
Andrew Bettison
4f5567e2c1 Use rigorous quoting throughout test scripts
This makes it much easier to refactor test fixtures and utilities.
2018-03-27 17:29:21 +10:30
Jeremy Lakeman
2f60b8417f Test and fix rhizome clean verify 2017-04-19 14:46:36 +09:30
Jeremy Lakeman
77198dd163 Read earlier journal payload out of store 2017-03-08 13:37:26 +10:30
Jeremy Lakeman
30aa1c16b8 Set authorship to remote if the sender sid can be generated from the id 2016-10-20 08:51:46 -04:00
Jeremy Lakeman
ced74d0b6b Simplify BK handling using new signing key typedefs 2016-09-27 15:20:12 +09:30
Andrew Bettison
e34141a2a5 Upgrade to SQLite 3.14.2
Ignores a variety of warnings when compiling sqlite3.c.

Uses the new sqlite3_trace_v2() function for logging SQL statements, now
that sqlite3_trace() and sqlite3_profile() are deprecated.

Fixes a rhizomeops test failure caused because SQLite 3.12 increased the
default block size from 1024 to 4096, causing the fixed overhead of an
empty Rhizome db to exceed 32KB.  This caused the test to fail because
the first "file add" failed.  Now the test fixture adapts to the fixed
overhead.

Deletes the SQLite 3.10.2 source amalgamation.
2016-09-21 22:47:35 +09:30
Jeremy Lakeman
ce2131870c Fix rhizome op test that used recipient field 2016-05-31 13:05:06 +09:30
Jeremy Lakeman
16a14269af Encrypt payloads without needing a sender
- reworked keyring identity handling to reduce memory searching
2016-05-31 12:50:32 +09:30
Jeremy Lakeman
89ab832c21 Link multiple versions of a journal payload to the same file 2016-05-24 14:47:49 +09:30
Jeremy Lakeman
5636edfe20 Append manifest into zip file comment 2016-03-30 16:25:43 +10:30
Jeremy Lakeman
9feffb89c0 Add test for missing file 2016-03-08 14:59:13 +10:30
Andrew Bettison
98ed0406c5 Refactor Rhizome result handling
- Introduce the new 'struct rhizome_bundle_result' that contains a
  rhizome_bundle_status enum value and an optional, nul-terminated
  string that provides an explanation of the cause of the status; add
  functions to construct, query, and free the struct

- Replace 'enum rhizome_add_result' with 'struct rhizome_bundle_result',
  removing an unnecessary level of enum interpretation

- Make rhizome_fill_manifest() return 'struct rhizome_bundle_result' and
  add logic to check that the supplied author SID is correct (previous
  behaviour was: if an incorrect author SID was supplied but the correct
  author could be found in the keyring, then the incorrect one was
  silently ignored)

- Simplify the response code in rhizome_restful.cc to take advantage of
  the new 'struct rhizome_bundle_result'; in particular, the mapping
  from 'enum rhizome_bundle_status' codes to HTTP status codes is now
  expressed in a single switch statement

- Fix some minor failures in test scripts revealed by the changes
2015-12-01 00:51:15 +10:30
Andrew Bettison
0f8141af95 Test RESTful Rhizome journal append with shared payload
When an append produces a payload that is already in the store,
the append must succeed, and the returned status codes should
indicate that the payload already existed
2015-04-13 16:24:05 +09:30
Andrew Bettison
da22816784 Add 'rhizome add file --bundle=BID' option
A convenience to re-use an existing manifest, instead of having
to extract the manifest, erase some fields, then pass the result
back into the 'rhizome add file' command
2015-03-28 05:09:38 +10:30
Andrew Bettison
b17848a438 Improve 'rhizomeops' test fixtures
Use extract_stdout_manifestid() instead of extract_stdout_keyvalue()
2015-03-28 05:09:37 +10:30
Andrew Bettison
987ec00183 Improve 'rhizomeops' test speed
Only create the identities needed, not five in every test
2015-03-25 00:55:37 +10:30
Andrew Bettison
015b4a0b07 Refactor and improve "journal append"
Distinguish between fatal and user-supplied-input errors, return
error descriptive text in a strbuf to allow dynamic content, apply
user-supplied field assgnments/deletions _after_ copying existing
manifest fields, use exit status 4 (invalid manifest) when applying
journal append to a non-journal or vice versa
2015-03-23 17:38:46 +10:30
Andrew Bettison
655b94eb3c Fix failing 'rhizomeops' tests 2015-03-19 03:21:27 +10:30
Andrew Bettison
c9131f43a2 POST /restful/rhizome/append for journals 2015-03-02 18:52:12 +10:30
Andrew Bettison
d44d18280a Rhizome test: cannot use "add file" to create a journal 2015-03-02 18:49:51 +10:30
Andrew Bettison
b2919a3a5e Rhizome test: cannot use "add file" to update a journal
Journal bundles can only be modified using "journal append"
2015-03-02 18:49:51 +10:30
Andrew Bettison
e0684567e8 Add Rhizome test case: import journal bundle
Also fix a bug thus revealed
2015-03-02 18:49:51 +10:30
Andrew Bettison
e2ef96a57d Improve some Rhizome test case comments 2015-03-02 18:49:50 +10:30
Andrew Bettison
e633c0fa0a "rhizome add file" manifest field=value varargs
Now a new manifest can be formed, and an existing manifest modified, by
giving "field=value" or "!field" command-line arguments at the end of
the "rhizome add file" command (after the <bsk> argument).

This makes it easier to script rhizome operations.
2014-11-19 13:26:50 +10:30
Andrew Bettison
ff339011b4 Refactor Rhizome manifest parsing
Now the parsing code uses the set/del functions for all supported
manifest fields, so no duplicate logic any more
2014-11-19 10:49:13 +10:30
Andrew Bettison
2f1843858d Support unrecognised manifest fields
Refactor Rhizome manifest parsing in preparation for command-line
field assignment
2014-11-19 10:47:31 +10:30
Andrew Bettison
65d6005cbf Create authored bundle from bundle secret
Improve the logic in rhizome_fill_manifest() to handle the case where
the secret and author are both supplied, by setting the BK field so the
secret can be recovered from the manifest later
2014-11-14 13:11:44 +10:30
Andrew Bettison
e743e4d7f9 Create authorless bundle from bundle secret
Until now, the bundle secret was never used to create a new bundle,
only to update a bundle whose secret was known from its creation.
2014-11-14 13:11:44 +10:30
Andrew Bettison
c3fdb12991 Fix assert_stdout_add_file() Rhizome test function
Correct 'author' and 'secret' fieldnames to '.author' and
'.secret'
2014-11-14 13:11:43 +10:30
Andrew Bettison
1cbc2a365b Improve Rhizome AddUpdateSameVersion test
If 'rhizome add file' command does not return status 1,
then cat the standard error (log) to the test log
2014-11-14 13:11:43 +10:30
Jeremy Lakeman
ca8f651b8d Cleanup the rhizome database every 30 minutes or so 2014-06-23 13:49:58 +09:30
Jeremy Lakeman
2ef73884a1 Add configurable limit to ensure a minimum amount of free space is preserved
- default to 100MB of free space
- currently disabled on android due to missing sys/statvfs.h
2014-06-23 13:06:21 +09:30
Jeremy Lakeman
7ff89afcf4 Reinstate rhizome database storage limit
- old / large payloads should be evicted to fit more payloads
- if there isn't enough space, new payloads will not be added
2014-06-19 11:09:09 +09:30
Jeremy Lakeman
80e139c2d9 Ensure orphan payloads or manifests are cleaned up 2014-06-16 15:56:31 +09:30
Jeremy Lakeman
2a572d19bf Rework rhizome store to write content more lazily and cleanup more carefully 2014-06-04 17:13:08 +09:30
Jeremy Lakeman
9f23b9bdcd Fix remove obsolete debug flags from test scripts 2014-05-26 14:16:35 +09:30
Andrew Bettison
53d5a8734b Fix Rhizome cleanup to remove temporary payloads
Fix test case to properly assert that all stale payloads are
deleted
2014-03-18 16:03:26 +10:30
Andrew Bettison
dc588e964d Fix "name=/file" bug in Rhizome add
Improved Rhizome test scripts and added new assert_manifest_fields()
function to Rhizome test defs
2014-03-12 15:48:00 +10:30
Andrew Bettison
0bef066949 Store Rhizome external blob files in "blob" subdirectory
This will make issue #50 a bit easier to tackle
2014-03-07 16:55:38 +10:30
Andrew Bettison
34188fa489 Replace config 'rhizome.external_blobs' with 'rhizome.max_blob_size' 2013-12-30 16:30:43 +10:30
Andrew Bettison
9ebef81a49 Formalise "rhizome add file" exit status
Formalise add-bundle result in "enum rhizome_bundle_status"

Rewrite rhizome_manifest_finalise(), rhizome_find_duplicate() and
rhizome_add_manifest() to return enum rhizome_bundle_status

New function rhizome_manifest_check_stored() that compares a manifest
with its stored counterpart and returns enum rhizome_bundle_status

Remove redundant rhizome_manifest_check_sanity(), consolidating all
manifest validation rules in rhizome_manifest_validate(), which now
checks the 'id' field is present, and that 'sender' and 'recipient' are
both present for MeshMS

Correct manifest finalisation logic: set the 'finalised' flag in
rhizome_manifest_validate(), not in rhizome_manifest_verify() (which
sets 'selfSigned'), and consistently clear 'finalised' flag in all
attribute setter functions

Remove manifest 'ttl' field and all references thereof (leaving unused
space in Rhizome BAR)

Rename some payload functions for clarity
2013-12-21 14:37:18 +10:30
Andrew Bettison
b53cabaae5 Unify output manifest fields from CLI rhizome commands 2013-12-13 17:24:59 +10:30
Andrew Bettison
0dd1b302b5 Rewrite Rhizome manifest parsing
Move validation checks into new function rhizome_manifest_validate()

Remove rhizome_manifest 'errors' field

Replace rhizome_manifest 'warnings' with 'malformed'

Replace rhizome_manifest 'manifest_bytes' with 'manifest_body_bytes' and
refactor to use 'manifest_all_bytes' in all manifest i/o

Refactor rhizome_manifest_verify() and reverse sense of return value to
match rhizome_manifest_validate()

New function rhizome_manifest_inspect() -- lightweight manifest parser
used when receiving Rhizome advertisements

New 'rhizomeops' test case for invalid manifest "service" field values,
now passes
2013-12-01 05:13:34 +10:30
Andrew Bettison
5e5e097d7f Accept any well formed Rhizome service field
Do not limit service field to only recognised supported values 'file',
'MeshMS1' and 'MeshMS2'

New test case checks for malformed service field, fails
2013-12-01 05:13:33 +10:30
Andrew Bettison
13634f8748 Add ROWID field to struct rhizome_manifest
New ".rowid" output field from rhizome add, import, extract, export
operations.  (Also added missing ".inserttime" and "date" fields to
some operations.)

Use new "rhizome add file" .rowid output field to check output of of
/restful/rhizome/bundlelist.json
2013-11-11 18:18:08 +10:30