cryptomator / cryptofs

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

Allow creation of FileAttributeView for non-existing files #40

Closed overheadhunter closed 5 years ago

overheadhunter commented 5 years ago

Currently, CryptoFS throws an NoSuchFileException (wrapped in an UncheckedIOException) when attempting to get a FileAttributeView. However this violates the contract.

We must not check if the file exists until any operations on the view get invoked. Therefore we need to refactor our CryptoFileAttributeViewProvider.

Test (should not throw any exception):

Path file = cryptoFileSystem.getPath("nonExistingFile.txt");
BasicFileAttributeView attrView = Files.getFileAttributeView(file, BasicFileAttributeView.class);
Files.createFile(file);
BasicFileAttributes attrs = attrView.readAttributes();