mirror of https://github.com/micromata/borgbackup-butler.git

Kai Reinhard
08.46.2018 5db1733cdfdac831cc10ff734c61d68079c47d1f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package de.micromata.borgbutler.cache;
 
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
 
import java.io.File;
 
public class ButlerCache {
    private static Logger log = LoggerFactory.getLogger(ButlerCache.class);
    public static final String CACHE_DIR_NAME = ".borgbutler";
    private static ButlerCache instance = new ButlerCache();
 
    private RepoInfoCache reposCache;
 
    @JsonIgnore
    private File cacheDir;
 
    public static ButlerCache getInstance() {
        return instance;
    }
 
    public static RepoInfoCache getReposCache() {
        return instance.reposCache;
    }
 
    public void save() {
        reposCache.save();
    }
 
    private ButlerCache() {
        String homeDir = System.getProperty("user.home");
        cacheDir = new File(homeDir, CACHE_DIR_NAME);
        if (!cacheDir.exists()) {
            log.info("Creating cache dir: " + cacheDir.getAbsolutePath());
            cacheDir.mkdir();
        }
        reposCache = new RepoInfoCache(cacheDir);
    }
}