Skip to content

Commit

Permalink
Skip reading attributes when cached in file properties.
Browse files Browse the repository at this point in the history
  • Loading branch information
dkocher committed Dec 12, 2018
1 parent e83d401 commit 24714ad
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
Expand Up @@ -48,7 +48,9 @@ public List<Acl.UserAndRole> run(final Session<?> session) throws BackgroundExce
if(this.isCanceled()) {
throw new ConnectionCanceledException();
}
next.attributes().setAcl(feature.getPermission(next));
if(Acl.EMPTY == next.attributes().getAcl()) {
next.attributes().setAcl(feature.getPermission(next));
}
for(Acl.UserAndRole acl : next.attributes().getAcl().asList()) {
if(updated.contains(acl)) {
continue;
Expand Down
24 changes: 10 additions & 14 deletions core/src/main/java/ch/cyberduck/core/worker/ReadMetadataWorker.java
Expand Up @@ -47,32 +47,28 @@ public ReadMetadataWorker(final List<Path> files) {
@Override
public Map<String, String> run(final Session<?> session) throws BackgroundException {
final Metadata feature = session.getFeature(Metadata.class);

// Map for File > Metadata Set
Map<Path, Map<String, String>> fullMetadata = new HashMap<>();
// Map for metadata entry key > File & Metadata Values
Map<String, Map<Path, String>> graphMetadata = new HashMap<>();

for(Path file : files) {
final Map<String, Map<Path, String>> graphMetadata = new HashMap<>();
for(Path next : files) {
// Read online metadata
final Map<String, String> metadata = feature.getMetadata(file);
file.attributes().setMetadata(metadata);
fullMetadata.put(file, new HashMap<>(metadata));
if(Collections.<String, String>emptyMap() == next.attributes().getMetadata()) {
final Map<String, String> metadata = feature.getMetadata(next);
next.attributes().setMetadata(metadata);
}
// take every entry of current metadata and store it in metaGraph
for(Map.Entry<String, String> entry : metadata.entrySet()) {
for(Map.Entry<String, String> entry : next.attributes().getMetadata().entrySet()) {
if(graphMetadata.containsKey(entry.getKey())) {
// if existing, get map, put value
graphMetadata.get(entry.getKey()).put(file, entry.getValue());
graphMetadata.get(entry.getKey()).put(next, entry.getValue());
}
else {
// if not existent create hashmap and put it back
Map<Path, String> map = new HashMap<>();
graphMetadata.put(entry.getKey(), map);
map.put(file, entry.getValue());
map.put(next, entry.getValue());
}
}
}

// Store result metadata in hashmap
Map<String, String> metadata = new HashMap<>();
for(Map.Entry<String, Map<Path, String>> entry : graphMetadata.entrySet()) {
Expand All @@ -81,7 +77,7 @@ public Map<String, String> run(final Session<?> session) throws BackgroundExcept
}
else {
// single use of streams, reason: distinct is easier in Streams than it would be writing it manually
Supplier<Stream<String>> valueSupplier = () -> entry.getValue().entrySet().stream().map(y -> y.getValue()).distinct();
Supplier<Stream<String>> valueSupplier = () -> entry.getValue().values().stream().distinct();
// Check count against 1, if it is use that value, otherwise use null
String value = valueSupplier.get().count() == 1 ? valueSupplier.get().findAny().get() : null;
// store it
Expand Down
Expand Up @@ -55,12 +55,15 @@ public PermissionOverwrite run(final Session<?> session) throws BackgroundExcept
if(this.isCanceled()) {
throw new ConnectionCanceledException();
}
permissions.add(feature.getUnixPermission(next));
if(Permission.EMPTY == next.attributes().getPermission()) {
next.attributes().setPermission(feature.getUnixPermission(next));
}
permissions.add(next.attributes().getPermission());
}

final PermissionOverwrite overwrite = new PermissionOverwrite();
final Supplier<Stream<Permission>> supplier = permissions::stream;

Supplier<Stream<Permission>> supplier = permissions::stream;
overwrite.user.read = resolveOverwrite(map(supplier, Permission::getUser, Permission.Action.read));
overwrite.user.write = resolveOverwrite(map(supplier, Permission::getUser, Permission.Action.write));
overwrite.user.execute = resolveOverwrite(map(supplier, Permission::getUser, Permission.Action.execute));
Expand Down

0 comments on commit 24714ad

Please sign in to comment.