Skip to content
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

Show a dedicated message when mounting to an occupied Windows drive #2961

Merged
merged 2 commits into from Jun 20, 2023

Conversation

sschuberth
Copy link
Contributor

Fixes #2309.

@CLAassistant
Copy link

CLAassistant commented Jun 16, 2023

CLA assistant check
All committers have signed the CLA.

@@ -97,7 +97,9 @@ private Runnable prepareMountPoint() throws IOException {
}
} else {
var mpIsDriveLetter = userChosenMountPoint.toString().matches("[A-Z]:\\\\");
if (!mpIsDriveLetter && canMountToParent && !canMountToDir) {
if (mpIsDriveLetter) {
if (driveLetters.getOccupied().contains(userChosenMountPoint)) throw new IllegalMountPointException("Drive \"" + userChosenMountPoint + "\" is already occupied.");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This string probably needs to use a resource for translation. I'd appreciate any pointers how to do that properly, as Mounter does not seem to have access to the resource bundles.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure:

  1. Add a parameter ResourceBundle resourceBundle to the constructor, so you can assign it to a private final field
  2. Re-run the Maven build, so that Dagger will generate the glue code used to inject the resourceBundle
  3. Add english (and only english) strings to src/main/resources/i18n/strings.properties - all other languages will be translated later and must not be touched

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That said, this is the wrong place for translations. We don't translate exception messages but only the UI.

What I would prefer instead: Either create some specific IllegalMountPointException subclasses (we could even make this a sealed class hierarchy 🤔) or add some machine-readable cause (use an enum) to the exception, which can then be passed to the UI in org.cryptomator.ui.unlock.UnlockWorkflow.

Subclasses are probably the way to go in Java, since the catch mechanism works on exception types, not an exception's fields.

Then, we would do the translation in this place (org.cryptomator.ui.unlock.UnlockInvalidMountPointController)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. The only nuisance now is that the generic error dialog suggest to open the app preferences, although the misconfiguration should be resolved in the vault options.

Edit: Our comments overlapped, my "done" referred to only your first comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't translate exception messages but only the UI.

Isn't this a bit of an edge-case, as here, the exception message will get displayed as part of the text in the "Unable to mount vault to custom path" dialog?

Either create some specific IllegalMountPointException subclasses

Ok, done.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@overheadhunter this should be good to run the GitHub workflow again.

Copy link
Member

@overheadhunter overheadhunter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you for your contribution!
@infeo can you have a look as well? Feel free to merge if you approve.

@sschuberth
Copy link
Contributor Author

The CI build fails due to a CVE in Jackson. Shall I look into bumping the Jackson version as well?

@overheadhunter
Copy link
Member

According to FasterXML/jackson-databind#3972, this is not considered a vulnerability but rather some "security researcher" wanting to distinguish himself by committing CVEs for normal and expected behavior of broadly used libs.

Anyway, even if we consider this a vulnerability: Neither does Cryptomator pass user-defined data to the serializer, nor is it a centralized infrastructure that can be considered a target for a DOS attack.

Therefore, please just add a rule for this specific CVE and library to the suppression.xml. Feel free to add a link to this comment in the description.

There is no fix available anyway. 😅

@sschuberth
Copy link
Contributor Author

Therefore, please just add a rule for this specific CVE and library to the suppression.xml.

Done. Please approve the workflow run once more.

Copy link
Member

@infeo infeo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@infeo infeo merged commit 2c2606d into cryptomator:develop Jun 20, 2023
3 checks passed
@infeo infeo added this to the 1.10.0 milestone Jun 20, 2023
@sschuberth sschuberth deleted the win-drive-occupied branch June 20, 2023 19:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reserved DriveLetter in Unlock-Failed-Dialog not displayed
4 participants