Skip to content

Commit

Permalink
Fix #4991.
Browse files Browse the repository at this point in the history
  • Loading branch information
dkocher committed Jul 13, 2010
1 parent 40f1071 commit a07a159
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
21 changes: 15 additions & 6 deletions source/ch/cyberduck/core/cf/CFSession.java
Expand Up @@ -36,9 +36,7 @@
import java.io.IOException;
import java.net.URI;
import java.text.MessageFormat;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.*;

/**
* Rackspace Cloud Files Implementation
Expand Down Expand Up @@ -168,6 +166,12 @@ public boolean isUploadResumable() {
return false;
}

/**
* Cache distribution status result.
*/
private Map<String, Distribution> distributionStatus
= new HashMap<String, Distribution>();

/**
* @param enabled Enable content distribution for the container
* @param method
Expand Down Expand Up @@ -211,26 +215,28 @@ public void writeDistribution(boolean enabled, String container, Distribution.Me
catch(ConnectionCanceledException e) {
log.error(e.getMessage());
}
distributionStatus.clear();
}
}

@Override
public Distribution readDistribution(String container, Distribution.Method method) {
if(null != container) {
if(!distributionStatus.containsKey(container)) {
final AbstractX509TrustManager trust = this.getTrustManager();
try {
this.check();
trust.setHostname(URI.create(this.getClient().getCdnManagementURL()).getHost());
try {
final FilesCDNContainer info = this.getClient().getCDNContainerInfo(container);
return new Distribution(info.isEnabled(), info.getCdnURL(),
final Distribution distribution = new Distribution(info.isEnabled(), info.getCdnURL(),
info.isEnabled() ? Locale.localizedString("CDN Enabled", "Mosso") : Locale.localizedString("CDN Disabled", "Mosso"),
info.getRetainLogs());
distributionStatus.put(container, distribution);
}
catch(FilesException e) {
log.warn(e.getMessage());
// Not found.
return new Distribution(false, null, Locale.localizedString("CDN Disabled", "Mosso"));
distributionStatus.put(container, new Distribution(false, null, Locale.localizedString("CDN Disabled", "Mosso")));
}
}
catch(IOException e) {
Expand All @@ -245,6 +251,9 @@ public Distribution readDistribution(String container, Distribution.Method metho
}
}
}
if(distributionStatus.containsKey(container)) {
return distributionStatus.get(container);
}
return new Distribution();
}

Expand Down
6 changes: 1 addition & 5 deletions source/ch/cyberduck/ui/cocoa/InfoController.java
Expand Up @@ -1290,8 +1290,6 @@ public void setFiles(List<Path> files) {
if(files.isEmpty()) {
return;
}
// Initialized before with a different file set
boolean update = !this.files.isEmpty();
this.files = files;
this.initGeneral();
// Sum of files
Expand All @@ -1306,9 +1304,7 @@ public void setFiles(List<Path> files) {
this.initS3();
// HTTP custom headers
this.initMetadata();
if(!update) {
this.initDistribution();
}
this.initDistribution();
}

private static NSPoint cascadedWindowPoint;
Expand Down

0 comments on commit a07a159

Please sign in to comment.