cryptomator / cryptofs

Java Filesystem Provider with integrated encryption
GNU Affero General Public License v3.0
93 stars 35 forks source link

Health API: Decouple result fix from severity #149

Closed infeo closed 1 year ago

infeo commented 1 year ago

Currently, the (undocumented) convention for an implementaiton of DiagnosticResult is the following: result severity != WARN → do not override fix() method. (aka throws UnsupportedOperationException).

In the context of https://github.com/cryptomator/cryptofs/issues/128, this convention showed a lack of flexibility. The dirId backup file is an optional feature, but the result stating it's missing has a severity of WARN to be fixable. Additionally, a lib consumer is unable to reach an intact vault structure once a critical error appears. This leads to reserved file paths, undeletable resources and other permament errors.

This PR solves those problems by discarding the aforementioned convention. The ideas are

The ideas are realized by decoupling the severity and the fix() method of a DiagnosticResult and change their meaning:

Implementationwise, the javadoc of Severity is adjusted. The feature to determine if a result fix exists is moved from convention to implementation: DiagnosticResul::getFix is a new method which returns Optional<Fix>, where the latter class is just a functional interface to apply the fix. The default implementation of ::getFix returns an empty optional. To keep compatibility, method fix(...) still exists, but is deprecated. For existing results with fixes, a delegate method is implemented.

infeo commented 1 year ago

Remark: To keep the diff small, this branch merges into https://github.com/cryptomator/cryptofs/tree/feature/missing-c9rcontent-is-type. There is an open PR for that one: https://github.com/cryptomator/cryptofs/pull/148

Once merged, the merge target should be changed to develop.