aboutsummaryrefslogtreecommitdiff
path: root/crates/tor-config/src/file_watcher.rs
Commit message (Collapse)AuthorAgeFilesLines
* tor-config: Make FileWatcher must_use.Nick Mathewson13 days1-0/+1
| | | | | (If you drop a FileWatcher, the thread that makes it works will exit.)
* maint: Run maint/add_warning to deny string slicesClara Engler2026-06-091-0/+1
| | | | | | | | | | | | This commit executes maint/add_warning with the just added change to deny string slices except in tests. I recommend auditing this by checking out the previous commit followed by running the script yourself and then verifying that the diff is identical to this commit. This commit makes cargo clippy fail. We will add exceptions in the next commit.
* Fix name of clippy lint to unchecked_time_subtraction (2)Ian Jackson2025-11-061-1/+1
| | | | Run maint/add_warning
* Switch Cargo.toml files to edition 2024.Nick Mathewson2025-08-071-1/+1
| | | | | | | | | | | | | | 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.
* file_watcher: Remove some now-unused thingsIan Jackson2025-02-061-8/+10
|
* file_watcher: Use .borrow_mut and sync MutexIan Jackson2025-02-061-10/+4
|
* file_watcher: Add some commentary about Event semanticsIan Jackson2025-02-061-0/+10
|
* tor-config: Test that uninteresting events get ignored.Gabriela Moldovan2025-01-091-3/+21
|
* tor-config: Rewrite match for readability.Gabriela Moldovan2025-01-091-3/+5
| | | | Prompted by https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/2696#note_3145971
* tor-config: Avoid using EventKind::Any in the tests.Gabriela Moldovan2025-01-091-3/+4
| | | | Events of type `Any` now get discarded by the event handler.
* tor-config: Handle rescan events before filtering.Gabriela Moldovan2025-01-091-3/+2
| | | | | This enables us to catch "rescan" events, regardless of their underlying `EventKind`.
* tor-config: Make the `FileWatcher` ignore non-mutating file events.Gabriela Moldovan2025-01-091-1/+13
| | | | | | | | Without this, setting `watch_configuration = true` results in endless config reloading due to arti accessing the config (which triggers an access event, which in turn, triggers a config reload, and so on). Closes #1794
* tor-config: Document the limitations of the FileWatcher.Gabriela Moldovan2024-10-161-0/+9
|
* tor-config: Compare the file contents when testing.Gabriela Moldovan2024-10-161-0/+7
| | | | | | | When testing, compare the contents of the files too, not just their mtime Otherwise, because the polling backend detects changes based on mtime, if the test creates/writes files too fast, it will fail to notice changes (this can happen, for example, on a tmpfs).
* tor-config: Configure the polling interval.Gabriela Moldovan2024-10-161-2/+17
| | | | | | | | | The default is 30s, which feels a bit too long. Also, when testing, we use a much shorter interval. This is meant to be a temporary solution, so we hard-code the interval rather than make it configurable.
* tor-config: Use a polling watcher on non-windows platforms that don't have ↵Gabriela Moldovan2024-10-161-2/+9
| | | | | | | | | | | | | | | inotify. On windows and platforms that support inotify (i.e. linux and android), we continue using the recommended watcher. On platforms that use kqueue, we switch to a polling watcher to work around a [notify bug] that manifests when using a non-recursive watcher to watch a directory. This commit is best reviewed with `git diff --ignore-all-space`. Closes #1644 [notify bug]: https://github.com/notify-rs/notify/issues/644
* tor-config: Add a type alias for the underlying watcher (fmt).Gabriela Moldovan2024-10-161-2/+2
|
* tor-config: Add a type alias for the underlying watcher.Gabriela Moldovan2024-10-161-3/+6
| | | | | This type will soon become platform-dependent, so I am preemptively adding a type alias.
* tor-config: Improve FileWatcher documentation.Gabriela Moldovan2024-08-281-1/+12
|
* tor-config: Add tests for FileWatcher::watch_path.Gabriela Moldovan2024-08-281-0/+73
|
* tor-config: Make a test helper take a reference to TempTestDir.Gabriela Moldovan2024-08-281-2/+2
|
* tor-config: Rename watch_file to watch_path.Gabriela Moldovan2024-08-271-3/+3
| | | | `FileWatcher::watch_file` can be used with arbitrary paths.
* tor-config: Write tests for FileWatcher.Gabriela Moldovan2024-08-211-3/+142
|
* tor-config: Add a TODO about relocating file_watcher.Gabriela Moldovan2024-08-211-0/+3
|
* tor-config: Add getters for FileWatcher.Gabriela Moldovan2024-08-211-1/+9
| | | | | | | Sometimes it's useful to know what files/directories are being watched. For example, the descriptor publisher needs to know in order to figure out if it needs to update the watcher in response to changes in the config.
* tor-config: Support watching dirs for files with a given extension (fmt).Gabriela Moldovan2024-08-211-2/+9
|
* tor-config: Support watching dirs for files with a given extension.Gabriela Moldovan2024-08-211-19/+72
| | | | | | | | | | | | | | This also fixes a couple of issues with the previous implementation: * it enables you to watch for more than just one file/extension per directory (each directory now has a list of filters. If any of the filters apply to the path contained in the notify::Event, the `FilterWatcher` notifies the listeners * it removes the list watched files from `FileWatcher`. This makes things a lot simpler to grok: essentially, the file watcher only ever watches directories, notifying if an "interesting" file was changed (in our case, the interesting files are files that have a relevant extension, such as `.auth`, or specific configuration files, as specified by `ConfigurationSources`).
* tor-config: Move event handling to a separate function.Gabriela Moldovan2024-08-211-20/+30
| | | | | This will soon grow more complex, so I am preemptively moving it out of `start_watching`.
* tor-config: Remove unused Event::SigHup variant.Gabriela Moldovan2024-08-211-3/+0
| | | | | We don't need this variant anymore, because sighup is now handled separately from `FileWatcher` events.
* tor-config: Make FileWatcher use an opaque channel type.Gabriela Moldovan2024-08-211-5/+68
| | | | The `FileWatcher` now uses a `postage::watch` channel under the hood.
* tor-config: Give FileWatcherBuilder a handle to the runtime.Gabriela Moldovan2024-08-211-11/+10
| | | | | The event handler will soon be made async, so we need a handle to the runtime.
* tor-config: Move FileWatcher to tor-config.Gabriela Moldovan2024-08-211-0/+195
For the most part, this is just code motion. The only change here is that `prepare` is no longer a method on `FileWatcher`. This decouples `FileWatcher` from `ConfigurationSources`, enabling us to use it to watch files and directories that aren't configuration.