Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
infeo committed Nov 23, 2023
1 parent 1b81537 commit 8ccf286
Showing 1 changed file with 10 additions and 15 deletions.
25 changes: 10 additions & 15 deletions src/main/java/org/cryptomator/cryptofs/CryptoPathMapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import javax.inject.Inject;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.FileAlreadyExistsException;
import java.nio.file.Files;
Expand Down Expand Up @@ -124,7 +123,7 @@ public CiphertextFilePath getCiphertextFilePath(CryptoPath cleartextPath) throws
String cleartextName = cleartextPath.getFileName().toString();
return getCiphertextFilePath(parent.path, parent.dirId, cleartextName);
}

public CiphertextFilePath getCiphertextFilePath(Path parentCiphertextDir, String parentDirId, String cleartextName) {
String ciphertextName = ciphertextNames.get(new DirIdAndName(parentDirId, cleartextName));
Path c9rPath = parentCiphertextDir.resolve(ciphertextName);
Expand Down Expand Up @@ -157,19 +156,15 @@ public CiphertextDirectory getCiphertextDir(CryptoPath cleartextPath) throws IOE
if (parentPath == null) {
return rootDirectory;
} else {
try {
var lazyEntry = new CompletableFuture<CiphertextDirectory>();
var priorEntry = ciphertextDirectories.asMap().putIfAbsent(cleartextPath, lazyEntry);
if (priorEntry != null) {
return priorEntry.join();
} else {
Path dirFile = getCiphertextFilePath(cleartextPath).getDirFilePath();
CiphertextDirectory cipherDir = resolveDirectory(dirFile);
lazyEntry.complete(cipherDir);
return cipherDir;
}
} catch (UncheckedIOException e) {
throw new IOException(e);
var lazyEntry = new CompletableFuture<CiphertextDirectory>();
var priorEntry = ciphertextDirectories.asMap().putIfAbsent(cleartextPath, lazyEntry);
if (priorEntry != null) {
return priorEntry.join();
} else {
Path dirFile = getCiphertextFilePath(cleartextPath).getDirFilePath();
CiphertextDirectory cipherDir = resolveDirectory(dirFile);
lazyEntry.complete(cipherDir);
return cipherDir;
}
}
}
Expand Down

0 comments on commit 8ccf286

Please sign in to comment.