Skip to content

Commit b13f0b6

Browse files
ylangiscdkocher
authored andcommitted
Simplify caching.
1 parent 9e3adf5 commit b13f0b6

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

cryptomator/src/main/java/ch/cyberduck/core/cryptomator/impl/CryptoDirectoryV6Provider.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
import org.apache.logging.log4j.Logger;
3838

3939
import java.nio.charset.StandardCharsets;
40-
import java.util.Arrays;
4140
import java.util.EnumSet;
4241
import java.util.concurrent.locks.ReadWriteLock;
4342
import java.util.concurrent.locks.ReentrantReadWriteLock;
@@ -104,18 +103,14 @@ public Path toEncrypted(final Session<?> session, final Path directory) throws B
104103
throw new NotfoundException(directory.getAbsolute());
105104
}
106105

107-
protected byte[] toDirectoryId(final Session<?> session, final Path directory, final byte[] directoryId) throws BackgroundException {
106+
protected byte[] toDirectoryId(final Session<?> session, final Path directory) throws BackgroundException {
108107
if(new SimplePathPredicate(home).test(directory)) {
109108
return ROOT_DIR_ID;
110109
}
111110
try {
112111
lock.readLock().lock();
113112
if(cache.contains(new SimplePathPredicate(directory))) {
114-
final byte[] existing = cache.get(new SimplePathPredicate(directory));
115-
if(!Arrays.equals(existing, directoryId)) {
116-
log.warn("Do not override already cached id {} with {}", existing, directoryId);
117-
}
118-
return existing;
113+
return cache.get(new SimplePathPredicate(directory));
119114
}
120115
}
121116
finally {
@@ -124,7 +119,7 @@ protected byte[] toDirectoryId(final Session<?> session, final Path directory, f
124119
try {
125120
log.debug("Acquire lock for {}", directory);
126121
lock.writeLock().lock();
127-
final byte[] id = null != directoryId ? this.load(session, directory) : directoryId;
122+
final byte[] id = this.load(session, directory);
128123
cache.put(new SimplePathPredicate(directory), id);
129124
return id;
130125
}
@@ -176,7 +171,7 @@ public byte[] getOrCreateDirectoryId(final Session<?> session, final Path file)
176171
return file.attributes().getDirectoryId();
177172
}
178173
final Path decrypted = file.getType().contains(AbstractPath.Type.encrypted) ? file.attributes().getDecrypted() : file;
179-
return this.toDirectoryId(session, decrypted.getType().contains(AbstractPath.Type.file) ? decrypted.getParent() : decrypted, null);
174+
return this.toDirectoryId(session, decrypted.getType().contains(AbstractPath.Type.file) ? decrypted.getParent() : decrypted);
180175
}
181176

182177
@Override

0 commit comments

Comments
 (0)