3333import org .cryptomator .cryptolib .api .FileHeader ;
3434
3535import java .nio .ByteBuffer ;
36+ import java .nio .ByteOrder ;
3637import java .nio .charset .StandardCharsets ;
3738import java .util .EnumSet ;
3839
@@ -60,15 +61,15 @@ public CryptoDirectoryUVFProvider(final AbstractVault vault, final CryptoFilenam
6061 }
6162
6263 @ Override
63- protected byte [] toDirectoryId (final Session <?> session , final Path directory , final byte [] directoryId ) throws BackgroundException {
64+ protected byte [] toDirectoryId (final Session <?> session , final Path directory ) throws BackgroundException {
6465 if (new SimplePathPredicate (home ).test (directory )) {
6566 return vault .getRootDirId ();
6667 }
67- return super .toDirectoryId (session , directory , directoryId );
68+ return super .toDirectoryId (session , directory );
6869 }
6970
70- // interface mismatch: we need parent path to get dirId and revision from dir.uvf
71- public String toEncrypted (final Session <?> session , final Path parent , final String filename ) throws BackgroundException {
71+ @ Override
72+ public String toEncrypted (final Session <?> session , final Path parent , final String filename , final EnumSet < Path . Type > type ) throws BackgroundException {
7273 if (new SimplePathPredicate (home ).test (parent )) {
7374 final String ciphertextName = filenameCryptor .encryptFilename (BaseEncoding .base64Url (), filename , vault .getRootDirId ()) + vault .getRegularFileExtension ();
7475 log .debug ("Encrypted filename {} to {}" , filename , ciphertextName );
@@ -121,7 +122,7 @@ protected byte[] load(final Session<?> session, final Path directory) throws Bac
121122 }
122123 final Path parent = this .toEncrypted (session , directory .getParent ());
123124 final String cleartextName = directory .getName ();
124- final String ciphertextName = this .toEncrypted (session , parent , cleartextName , EnumSet .of (Path .Type .directory ));
125+ final String ciphertextName = this .toEncrypted (session , directory . getParent () , cleartextName , EnumSet .of (Path .Type .directory ));
125126 final Path metadataParent = new Path (parent , ciphertextName , EnumSet .of (Path .Type .directory ));
126127 // Read directory id from file
127128 try {
@@ -154,12 +155,9 @@ protected byte[] load(final Session<?> session, final Path directory) throws Bac
154155 }
155156
156157 protected int loadRevision (final Session <?> session , final Path directory ) throws BackgroundException {
157- //TODO
158-
159- /*
160- final Path parent = this.toEncrypted(session, directory.getParent().attributes().getDirectoryId(), directory.getParent());
158+ final Path parent = this .toEncrypted (session , directory .getParent ());
161159 final String cleartextName = directory .getName ();
162- final String ciphertextName = this.toEncrypted(session, parent.attributes().getDirectoryId (), cleartextName, EnumSet.of(Path.Type.directory));
160+ final String ciphertextName = this .toEncrypted (session , directory . getParent (), cleartextName , EnumSet .of (Path .Type .directory ));
163161 final Path metadataParent = new Path (parent , ciphertextName , EnumSet .of (Path .Type .directory ));
164162 // Read directory id from file
165163 log .debug ("Read directory ID for folder {} from {}" , directory , ciphertextName );
@@ -174,7 +172,6 @@ protected int loadRevision(final Session<?> session, final Path directory) throw
174172 ByteBuffer buffer = ByteBuffer .wrap (ciphertext );
175173 ByteBuffer headerBuf = buffer .duplicate ();
176174 headerBuf .position (4 ).limit (headerSize );
177- return headerBuf.order(ByteOrder.BIG_ENDIAN).getInt();*/
178- return 0 ;
175+ return headerBuf .order (ByteOrder .BIG_ENDIAN ).getInt ();
179176 }
180177}
0 commit comments