aboutsummaryrefslogtreecommitdiff
path: root/crates/tor-dirmgr/src/storage
Commit message (Collapse)AuthorAgeFilesLines
* Remove users of fslock other than fslock-guard.Nick Mathewson2026-05-061-62/+70
| | | | | | There were two that relied on the the ability to have a lock in an unlocked state. Instead, we replace those with Option<LockFileGuard> or its equivalent.
* dirmgr: port to web-time-compat.Nick Mathewson2026-03-261-10/+16
|
* dirmgr: Stub out usage of Lockfile on wasm32-unknown.Nick Mathewson2026-03-251-2/+31
| | | | | | | This is temporary while we wait on arti#2106. (This made cargo-sort have me move a section around. Not sure why it cares.)
* Fix word duplicate typosTobias Stoeckmann2026-03-151-1/+1
|
* dirmgr: Rewrite .is_some()/.unwrap() using let matchGabriela Moldovan2025-12-011-4/+6
| | | | | | | On nightly, clippy now warns against this and recommends using a `match` instead. See https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_unwrap
* Switch Cargo.toml files to edition 2024.Nick Mathewson2025-08-071-11/+17
| | | | | | | | | | | | | | First, run ``` git grep -l "^edition =" | xargs perl -i -pe 's/^edition *=.*/edition = "2024"/;' ``` Second, manually verify that all Cargo.toml files have changed, and nothing else has changed. Third, run cargo fmt again.
* dirmgr, netdir: Store protocol requirments as soon as they are validated.Nick Mathewson2025-04-161-2/+0
|
* dirmgr: Backend support for cacheing protocol status.Nick Mathewson2025-04-161-1/+118
| | | | | | | We want to store this separately from the consensus, because we want to access it very early in our load-from-cache process, without checking the consensus that contains it for timeliness.
* tor-dirmgr: remove `dbg!`Steven Engler2025-03-051-1/+0
|
* sqlite: Handle vanished blobs during consensus loadingNick Mathewson2025-03-051-16/+38
| | | | | | | | | Here we move the responsibility for removing ExtDoc entries for vanished blobs into the _caller_ of read_blob(): we want to tidy all such entries in one go. Unlike a (reverted) previous approach, this time we don't need a retry loop.
* sqlite: add a method to tidy extdocs for vanished blobsNick Mathewson2025-03-051-1/+93
|
* sqlite.rs: Let read_blob signal whether it cleaned up.Nick Mathewson2025-03-051-8/+28
| | | | We'll want to use this information to tell us whether to retry.
* sqlite: Extract body of latest_consensus into a new methodNick Mathewson2025-03-051-23/+33
| | | | I'm about to add a retry mechanism.
* sqlite: Stop ignoring any errors.Nick Mathewson2025-03-051-3/+22
| | | | | We've already stopped ignoring any DB errors, so we may as well make sure that any FS errors we encounter are also reported.
* sqlite: Add a comment about O(n) query.Nick Mathewson2025-03-051-0/+2
|
* sqlite.rs: Rustfmt.Nick Mathewson2025-03-051-86/+87
|
* sqlite.rs: Put SavedBlobHandle into its own moduleNick Mathewson2025-03-051-13/+30
| | | | | | | This will help us keep its members private from the rest of sqlite.rs, and ensure that things are kept consistent. (This violates rust formatting for clarity. I'll reindent after.)
* sqlite.rs: More comments about blob rollback.Nick Mathewson2025-03-051-1/+7
|
* sqlite.rs: Give SavedBlobHandle more methods.Nick Mathewson2025-03-051-24/+47
| | | | | This is in preparation for making it opaque from the rest of the code, so that we can more easily reason about it.
* sqlite.rs: add comments about consistencyNick Mathewson2025-03-051-2/+14
|
* sqlite.rs: Add a note on blob consistency (or lack thereof)Nick Mathewson2025-03-051-0/+77
|
* sqlite.rs: Rename dtype to digest_type to avoid further confusion.Nick Mathewson2025-03-051-6/+6
|
* dirmgr: Propagate row-conversion failure from expire_all.Nick Mathewson2025-03-051-5/+4
| | | | | This can only happen because of a bug or because of db corruption, and we probably shouldn't ignore it.
* dirmgr: When expiring a consensus, remove its blob.Nick Mathewson2025-03-051-2/+68
| | | | | | | Previously, we would leave the ExtDocs blob to expire on its own, and it would hang out for up to a week. Closes #1655.
* dirmgr: Store the correct value in ExtDocs.typeNick Mathewson2025-03-051-2/+5
| | | | | | | | | | | | | Also, document that old values will be kicking around for a little while. Fortunately: - Nothing actually looked at these values before. - All elements in this table have an expiration date, so once a new version of Arti has been running for a week or two, the old erroneous values will go away.
* Merge branch 'sqlite-race' into 'main'gabi-2502024-07-311-9/+38
|\ | | | | | | | | | | | | tor-dirmgr: Return an error if storage is readonly and DB is missing/incompatbile. Closes #1497 See merge request tpo/core/arti!2283
| * tor-dirmgr: Replace from_conn impl with a call to from_conn_internal helper.Gabriela Moldovan2024-07-301-7/+16
| |
| * tor-dirmgr: Return an error if storage is readonly and DB is ↵Gabriela Moldovan2024-07-301-14/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | missing/incompatbile. This fixes a bug in `SqliteStore`'s constructor: previously, it would unconditionally try to create the missing database, even if it didn't have write access. As a result, it was impossible to reliably start multiple concurrent arti processes configured with the same (empty or nonexistent) cache_dir, because many of them would fail with errors such as ``` attempt to write a readonly database: Error code 8: Attempt to write a readonly database ``` Returning a `LocalResourceAlreadyInUse` error kind here enables us to leverage the retry loop from `TorClientBuilder::create_unbootstrapped` (which retries on local resource errors if `local_resource_timeout` is set). Closes #1497
* | tor-dirmgr: Use Path::try_exists() instead of Path::exists().Gabriela Moldovan2024-07-301-1/+1
|/
* tor-dirmgr: Add some duplicate dead code allowsIan Jackson2024-07-081-0/+2
| | | | Sadly, rustc seems to want us to mark this allow in several places.
* sqlite: (style) Use consistent casing on "ExtDocs"Nick Mathewson2024-06-181-2/+2
| | | | SQL is case-insensitive, but it is still nice to be consistent.
* storage: Remove orphaned files from dir_blobsNick Mathewson2024-06-121-0/+117
| | | | | | | | | | This patch removes files from dir_blobs if they are not referenced from the database, or if their filenames are not valid UTF-8. (If they were not valid UTF-8, we wouldn't have put them in our database.) To ensure that there can't be any race conditions, we only do this when the file is a bit old.
* dirmgr: create temporary testing stores with correct paths.Nick Mathewson2024-06-121-3/+3
| | | | | Previously, we were putting an (optional) db.sql file and our blobs into the same path, which is not what we do outside of our tests.
* dirmgr::storage: Enable foreign keys on our sqlite connections.Nick Mathewson2024-06-121-0/+4
| | | | | | Without this, "ON DELETE CASCADE" will do nothing. Part of fixing #1466.
* dirmgr::storage: Treat a missing blob file as an absent object.Nick Mathewson2024-06-121-19/+36
| | | | | | | | | | | | | | Previously it was counted as a hard error, which would cause an absolute failure to start if a blob file had been deleted improperly -- for example, by a renegade cache-cleaner that had decided to remove the largest files it could find. Upon encountering a missing blob, we remove it from the database as well: if we did not, then unavailable consensuses could still cause us to try to fetch consensus diffs, because their rows would still be present. Fixes #1466.
* Mark tor_dirmgr::storage::Store::consensus_by_meta cfg(test)Ian Jackson2024-04-251-0/+1
| | | | This seems to be used only in tests, since at least 2022.
* tor-dirmgr: Work around an apparent regression in `time`.Nick Mathewson2023-02-171-3/+3
| | | | | | | Some code in our tests that worked fine with time 0.3.17 no longer works with 0.3.19, despite the semver. See https://github.com/time-rs/time/issues/552 for the upstream bug.
* Fix a bunch of "needless borrow" warnings on nightlyNick Mathewson2022-11-181-2/+2
| | | | | It looks like, despite a few false starts, they've got this warning right; there weren't any false positives.
* sqlite cache: Document reasoning about timestampsIan Jackson2022-11-081-2/+9
| | | | | As per https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/831#note_2851764
* bridge desc: Implement storage functions at the DB layerIan Jackson2022-11-041-8/+67
|
* bridge desc: Implement cache reuse logic and if-modified-sinceIan Jackson2022-11-041-0/+23
| | | | | | | | | | | | This introduces the new API functions to Store. But currently they are all no-ops. So all this machinery doesn't actually do anything. Also, it changes the API to the mockable downloader, to allow it to support if-modified-since. So this isn't used either. But it is more convenient to do this all at once in BridgeDescManager, since care needs to be taken about the intraction between if-modified-since and the persistent cache.
* bridge desc: Provide a Store to the bridge desc managerIan Jackson2022-11-041-2/+2
| | | | | | | | | | | | | | | | We use the one in the dirmgr. That means that our constructor now has to take a dirmgr. And, the dirmgr must have a circmgr. This is all rather odd, TBH. Add .. to the binding of the return values from setup, as future-proofing. The tests now need to provide a Store too. Make the sqlite::new_empty function pub(crate) so we can use it. We must retain the _db_tmp_dir, since when it goes away the tmp directory is deleted and the db goes readonly.
* dirmgr sqlite store: Improve schema updatesIan Jackson2022-11-041-9/+25
| | | | | | | | | * Centralise applying the schema updates, in a closure * Make the schema update SQL texts be in an array so we can loop * Make the version update statement generic, not cloned-and-hacked This will make it possible to add another schema version without error-prone conditions etc.
* fix clippy::needless_borrowtrinity-1686a2022-09-101-1/+1
|
* Merge branch 'dirmgr_error_cleanup' into 'main'Nick Mathewson2022-07-181-15/+25
|\ | | | | | | | | | | | | Clean up some errors in tor-dirmgr Closes #521 See merge request tpo/core/arti!628
| * dirmgr: Add a helper to create LockFile errors.Nick Mathewson2022-07-181-8/+3
| |
| * dirmgr: Make UnrecognizedSchema more helpfulNick Mathewson2022-07-141-1/+4
| |
| * dirmgr: Clarify disk IO errors.Nick Mathewson2022-07-141-14/+26
| |
* | Fix illegal formatting in cache filenamesfeelingnothing2022-07-141-1/+1
|/
* Work around an erroneous warning from nightly clippyNick Mathewson2022-06-151-0/+3
|