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.
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:
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 theRootDirectoryInitializer
class.