-
Notifications
You must be signed in to change notification settings - Fork 36
Feature: Notification API for Filesystem events #277
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 11 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
3695e62
impl draft based on FileSystemProperties
infeo d6ebcf4
Merge branch 'develop' into feature/fs-notify
infeo e44c2e4
simplified API
infeo fecb0a2
use records
infeo 1689c58
add conflictResolved event
infeo 7a564fb
add conflict failed event
infeo c942596
clean up
infeo e94ebc2
use sealed interface instead of type enum
infeo 5e552d1
doc doc doc
infeo 311b86c
clean up
infeo 53d5cd9
remove unused parameter in decryption failed event
infeo ea091f0
ensure eventConsumer is never null
infeo 19117bc
ensure, that on any RuntimeException during event consumption the fil…
infeo 2cd07fa
standardize parameter naming for conflict resolution events
infeo 60a0fc8
fix wrong path resolution
infeo 30ee882
adjust doc
infeo 3691c6b
rename eventConsumer variables in CryptoFileSystemProperties
infeo fb5b302
rename method
infeo 1ff1f1d
Merge branch 'develop' into feature/fs-notify
infeo 3df3c4e
increase test coverage
infeo 9fddb8b
align key name for event consumer entry in properties to public build…
infeo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/main/java/org/cryptomator/cryptofs/event/ConflictResolutionFailedEvent.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| package org.cryptomator.cryptofs.event; | ||
|
|
||
| import java.nio.file.Path; | ||
|
|
||
| /** | ||
| * Emitted, if the conflict resolution inside an encrypted directory failed | ||
| * | ||
| * @param cleartextPath path within the cryptographic filesystem | ||
| * @param ciphertextPath path to the encrypted resource with the broken filename | ||
| * @param reason exception, why the resolution failed | ||
| */ | ||
| public record ConflictResolutionFailedEvent(Path cleartextPath, Path ciphertextPath, Exception reason) implements FilesystemEvent { | ||
|
|
||
| } |
15 changes: 15 additions & 0 deletions
15
src/main/java/org/cryptomator/cryptofs/event/ConflictResolvedEvent.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| package org.cryptomator.cryptofs.event; | ||
|
|
||
| import java.nio.file.Path; | ||
|
|
||
| /** | ||
| * Emitted, if a conflict inside an encrypted directory was resolved | ||
| * | ||
| * @param cleartextPath path within the cryptographic filesystem | ||
| * @param ciphertextPath path to the encrypted resource | ||
| * @param oldVersionCleartextPath path within the cryptographic filesystem of the renamed resource | ||
| * @param oldVersionCiphertextPath path to the renamed, encrypted resource | ||
| */ | ||
| public record ConflictResolvedEvent(Path cleartextPath, Path ciphertextPath, Path oldVersionCleartextPath, Path oldVersionCiphertextPath) implements FilesystemEvent { | ||
|
overheadhunter marked this conversation as resolved.
Outdated
|
||
|
|
||
| } | ||
15 changes: 15 additions & 0 deletions
15
src/main/java/org/cryptomator/cryptofs/event/DecryptionFailedEvent.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| package org.cryptomator.cryptofs.event; | ||
|
|
||
| import org.cryptomator.cryptolib.api.AuthenticationFailedException; | ||
|
|
||
| import java.nio.file.Path; | ||
|
|
||
| /** | ||
| * Emitted, if a decryption operation fails. | ||
| * | ||
| * @param ciphertextPath path to the encrypted resource | ||
| * @param e thrown exception | ||
| */ | ||
| public record DecryptionFailedEvent(Path ciphertextPath, AuthenticationFailedException e) implements FilesystemEvent { | ||
|
overheadhunter marked this conversation as resolved.
|
||
|
|
||
| } | ||
27 changes: 27 additions & 0 deletions
27
src/main/java/org/cryptomator/cryptofs/event/FilesystemEvent.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| package org.cryptomator.cryptofs.event; | ||
|
|
||
| import java.util.function.Consumer; | ||
|
|
||
| /** | ||
| * Common interface for all filesystem events. | ||
| * <p> | ||
| * Events are emitted via the notification method set in the properties during filesystem creation, see {@link org.cryptomator.cryptofs.CryptoFileSystemProperties.Builder#withFilesystemEventConsumer(Consumer)}. | ||
| * <p> | ||
| * To get a specific event type, use the enhanced switch pattern or typecasting in if-instance of, e.g. | ||
| * {@code | ||
| * FilesystemEvent fse; | ||
| * switch (fse) { | ||
| * case DecryptionFailedEvent dfe -> //do stuff | ||
| * case ConflictResolvedEvent cre -> //do other stuff | ||
|
infeo marked this conversation as resolved.
Outdated
|
||
| * //other cases | ||
| * } | ||
| * if( fse instanceof DecryptionFailedEvent dfe) { | ||
| * //do more stuff | ||
| * } | ||
| * }. | ||
| * | ||
| * @apiNote Events might have occured a long time ago in a galaxy far, far away... therefore, any feedback method is non-blocking and might fail due to changes in the filesystem. | ||
| */ | ||
| public sealed interface FilesystemEvent permits ConflictResolutionFailedEvent, ConflictResolvedEvent, DecryptionFailedEvent { | ||
|
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.