8
8
*******************************************************************************/
9
9
package org .cryptomator .cryptofs ;
10
10
11
- import org .cryptomator .cryptofs .CryptoPathMapper .CiphertextDirectory ;
12
11
import org .cryptomator .cryptofs .attr .AttributeByNameProvider ;
13
12
import org .cryptomator .cryptofs .attr .AttributeProvider ;
14
13
import org .cryptomator .cryptofs .attr .AttributeViewProvider ;
@@ -142,7 +141,7 @@ public Path getCiphertextPath(Path cleartextPath) throws IOException {
142
141
var p = CryptoPath .castAndAssertAbsolute (cleartextPath );
143
142
var nodeType = cryptoPathMapper .getCiphertextFileType (p );
144
143
if (nodeType == CiphertextFileType .DIRECTORY ) {
145
- return cryptoPathMapper .getCiphertextDir (p ).path ;
144
+ return cryptoPathMapper .getCiphertextDir (p ).path () ;
146
145
}
147
146
var cipherFile = cryptoPathMapper .getCiphertextFilePath (p );
148
147
if (nodeType == CiphertextFileType .SYMLINK ) {
@@ -316,22 +315,22 @@ void createDirectory(CryptoPath cleartextDir, FileAttribute<?>... attrs) throws
316
315
if (cleartextParentDir == null ) {
317
316
return ;
318
317
}
319
- Path ciphertextParentDir = cryptoPathMapper .getCiphertextDir (cleartextParentDir ).path ;
318
+ Path ciphertextParentDir = cryptoPathMapper .getCiphertextDir (cleartextParentDir ).path () ;
320
319
if (!Files .exists (ciphertextParentDir )) {
321
320
throw new NoSuchFileException (cleartextParentDir .toString ());
322
321
}
323
322
cryptoPathMapper .assertNonExisting (cleartextDir );
324
323
CiphertextFilePath ciphertextPath = cryptoPathMapper .getCiphertextFilePath (cleartextDir );
325
324
Path ciphertextDirFile = ciphertextPath .getDirFilePath ();
326
- CiphertextDirectory ciphertextDir = cryptoPathMapper .getCiphertextDir (cleartextDir );
325
+ var ciphertextDir = cryptoPathMapper .getCiphertextDir (cleartextDir );
327
326
// atomically check for FileAlreadyExists and create otherwise:
328
327
Files .createDirectory (ciphertextPath .getRawPath ());
329
328
try (FileChannel channel = FileChannel .open (ciphertextDirFile , EnumSet .of (StandardOpenOption .CREATE_NEW , StandardOpenOption .WRITE ), attrs )) {
330
- channel .write (UTF_8 .encode (ciphertextDir .dirId ));
329
+ channel .write (UTF_8 .encode (ciphertextDir .dirId () ));
331
330
}
332
331
// create dir if and only if the dirFile has been created right now (not if it has been created before):
333
332
try {
334
- Files .createDirectories (ciphertextDir .path );
333
+ Files .createDirectories (ciphertextDir .path () );
335
334
dirIdBackup .execute (ciphertextDir );
336
335
ciphertextPath .persistLongFileName ();
337
336
} catch (IOException e ) {
@@ -432,7 +431,7 @@ private void deleteFileOrSymlink(CiphertextFilePath ciphertextPath) throws IOExc
432
431
}
433
432
434
433
private void deleteDirectory (CryptoPath cleartextPath , CiphertextFilePath ciphertextPath ) throws IOException {
435
- Path ciphertextDir = cryptoPathMapper .getCiphertextDir (cleartextPath ).path ;
434
+ Path ciphertextDir = cryptoPathMapper .getCiphertextDir (cleartextPath ).path () ;
436
435
Path ciphertextDirFile = ciphertextPath .getDirFilePath ();
437
436
try {
438
437
ciphertextDirDeleter .deleteCiphertextDirIncludingNonCiphertextFiles (ciphertextDir , cleartextPath );
@@ -505,7 +504,7 @@ private void copyDirectory(CryptoPath cleartextSource, CryptoPath cleartextTarge
505
504
ciphertextTarget .persistLongFileName ();
506
505
} else if (ArrayUtils .contains (options , StandardCopyOption .REPLACE_EXISTING )) {
507
506
// keep existing (if empty):
508
- Path ciphertextTargetDir = cryptoPathMapper .getCiphertextDir (cleartextTarget ).path ;
507
+ Path ciphertextTargetDir = cryptoPathMapper .getCiphertextDir (cleartextTarget ).path () ;
509
508
try (DirectoryStream <Path > ds = Files .newDirectoryStream (ciphertextTargetDir )) {
510
509
if (ds .iterator ().hasNext ()) {
511
510
throw new DirectoryNotEmptyException (cleartextTarget .toString ());
@@ -515,8 +514,8 @@ private void copyDirectory(CryptoPath cleartextSource, CryptoPath cleartextTarge
515
514
throw new FileAlreadyExistsException (cleartextTarget .toString (), null , "Ciphertext file already exists: " + ciphertextTarget );
516
515
}
517
516
if (ArrayUtils .contains (options , StandardCopyOption .COPY_ATTRIBUTES )) {
518
- Path ciphertextSourceDir = cryptoPathMapper .getCiphertextDir (cleartextSource ).path ;
519
- Path ciphertextTargetDir = cryptoPathMapper .getCiphertextDir (cleartextTarget ).path ;
517
+ Path ciphertextSourceDir = cryptoPathMapper .getCiphertextDir (cleartextSource ).path () ;
518
+ Path ciphertextTargetDir = cryptoPathMapper .getCiphertextDir (cleartextTarget ).path () ;
520
519
copyAttributes (ciphertextSourceDir , ciphertextTargetDir );
521
520
}
522
521
}
@@ -622,7 +621,7 @@ private void moveDirectory(CryptoPath cleartextSource, CryptoPath cleartextTarge
622
621
throw new AtomicMoveNotSupportedException (cleartextSource .toString (), cleartextTarget .toString (), "Replacing directories during move requires non-atomic status checks." );
623
622
}
624
623
// check if dir is empty:
625
- Path targetCiphertextDirContentDir = cryptoPathMapper .getCiphertextDir (cleartextTarget ).path ;
624
+ Path targetCiphertextDirContentDir = cryptoPathMapper .getCiphertextDir (cleartextTarget ).path () ;
626
625
boolean targetCiphertextDirExists = true ;
627
626
try (DirectoryStream <Path > ds = Files .newDirectoryStream (targetCiphertextDirContentDir , DirectoryStreamFilters .EXCLUDE_DIR_ID_BACKUP )) {
628
627
if (ds .iterator ().hasNext ()) {
0 commit comments