Skip to content
This repository has been archived by the owner on Jul 26, 2022. It is now read-only.

Commit

Permalink
Implement cache size parameter configurability
Browse files Browse the repository at this point in the history
  • Loading branch information
binwiederhier committed Aug 11, 2014
1 parent 65f1deb commit 81bb916
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
8 changes: 6 additions & 2 deletions syncany-lib/src/main/java/org/syncany/config/Config.java
Expand Up @@ -94,7 +94,7 @@ public Config(File aLocalDir, ConfigTO configTO, RepoTO repoTO) throws ConfigExc
initNames(configTO);
initMasterKey(configTO);
initDirectories(aLocalDir);
initCache();
initCache(configTO);
initIgnoredFile();
initRepo(repoTO);
initConnection(configTO);
Expand All @@ -117,8 +117,12 @@ private void initDirectories(File aLocalDir) throws ConfigException {
logDir = FileUtil.getCanonicalFile(new File(appDir, DIR_LOG));
}

private void initCache() {
private void initCache(ConfigTO configTO) {
cache = new Cache(cacheDir);

if (configTO.getCacheKeepBytes() != null && configTO.getCacheKeepBytes() >= 0) {
cache.setKeepBytes(configTO.getCacheKeepBytes());
}
}

private void initIgnoredFile() throws ConfigException {
Expand Down
11 changes: 11 additions & 0 deletions syncany-lib/src/main/java/org/syncany/config/to/ConfigTO.java
Expand Up @@ -60,6 +60,9 @@ public class ConfigTO {

@Element(name="connection", required=true)
private ConnectionTO connectionTO;

@Element(name="cacheKeepBytes", required=false)
private Long cacheKeepBytes;

public static ConfigTO load(File file) throws ConfigException {
try {
Expand Down Expand Up @@ -100,6 +103,14 @@ public SaltedSecretKey getMasterKey() {

public void setMasterKey(SaltedSecretKey masterKey) {
this.masterKey = masterKey;
}

public Long getCacheKeepBytes() {
return cacheKeepBytes;
}

public void setCacheKeepBytes(Long cacheKeepBytes) {
this.cacheKeepBytes = cacheKeepBytes;
}

@Persist
Expand Down

0 comments on commit 81bb916

Please sign in to comment.