From 8ccf2861d95a73431c71e8823e80438cd7d3ecac Mon Sep 17 00:00:00 2001 From: Armin Schrenk Date: Thu, 23 Nov 2023 11:32:05 +0100 Subject: [PATCH] clean up --- .../cryptofs/CryptoPathMapper.java | 25 ++++++++----------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/src/main/java/org/cryptomator/cryptofs/CryptoPathMapper.java b/src/main/java/org/cryptomator/cryptofs/CryptoPathMapper.java index fa8e57a5..c725611e 100644 --- a/src/main/java/org/cryptomator/cryptofs/CryptoPathMapper.java +++ b/src/main/java/org/cryptomator/cryptofs/CryptoPathMapper.java @@ -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; @@ -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); @@ -157,19 +156,15 @@ public CiphertextDirectory getCiphertextDir(CryptoPath cleartextPath) throws IOE if (parentPath == null) { return rootDirectory; } else { - try { - var lazyEntry = new CompletableFuture(); - 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(); + 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; } } }