cryptomator / cryptofs

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

Exclusively create encrypted file system root at vault initialization #98

Closed infeo closed 3 years ago

infeo commented 3 years ago

Description

Currently, everytime a vault is opened/ a cryptofilesystem is created via the CryptoFileSystemProvider, the encrypted root directory is created in the constructor of the CryptoFileSystemImpl:

    public CryptoFileSystemImpl(CryptoFileSystemProvider provider, CryptoFileSystems cryptoFileSystems /*, ... more arguments */ ) {
        /* a lot assingments */

        rootDirectoryInitializer.initialize(rootPath);
    }

The class RootDirectoryInitializer does nothing else except this.

This design decison is bad, because the file system root directory is as the main entry point an inherent part of vault and not subject of change. As such, if it is not present, an error should be thrown. Just recreating the root is not a fix, beause the stored data is already lost and additionally it suggests that there is no error at all.

Suggested Solution

Only create the encrypted vault root at initialization, i.e. i the CryptoFileSystemProvider.initiatlize(...) method. Remove the RootDirectoryInitializer class.