add starting cache module and fix it
This commit is contained in:
parent
6eb2a56fbf
commit
aa17276aba
@ -1,5 +1,6 @@
|
||||
package dev.mateuszkowalczyk.ffm.app;
|
||||
|
||||
import dev.mateuszkowalczyk.ffm.app.cache.CacheService;
|
||||
import dev.mateuszkowalczyk.ffm.data.Chooser;
|
||||
import dev.mateuszkowalczyk.ffm.data.DatabaseService;
|
||||
import dev.mateuszkowalczyk.ffm.utils.PropertiesLoader;
|
||||
@ -14,6 +15,7 @@ public class WorkspaceService {
|
||||
private static final WorkspaceService instance = new WorkspaceService();
|
||||
private PropertiesLoader propertiesLoader = PropertiesLoader.getInstance();
|
||||
private DatabaseService databaseService = DatabaseService.getInstance();
|
||||
private CacheService cacheService = CacheService.getInstance();
|
||||
private MainPageController mainPageController;
|
||||
|
||||
private WorkspaceService() {
|
||||
@ -36,6 +38,7 @@ public class WorkspaceService {
|
||||
String path = chooser.chooseDirectory();
|
||||
|
||||
this.propertiesLoader.set(Property.PATH_TO_DIRECTORY, path);
|
||||
this.cacheService.check();
|
||||
try {
|
||||
StageController.getInstance().setScene(SceneEnum.MainPage);
|
||||
} catch (IOException e) {
|
||||
|
@ -4,11 +4,15 @@ public class CacheService {
|
||||
private static final CacheService instance = new CacheService();
|
||||
|
||||
private CacheService () {
|
||||
CacheStructureChecker cacheStructureChecker = new CacheStructureChecker();
|
||||
cacheStructureChecker.check();
|
||||
this.check();
|
||||
}
|
||||
|
||||
public static CacheService getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public void check() {
|
||||
CacheStructureChecker cacheStructureChecker = new CacheStructureChecker();
|
||||
cacheStructureChecker.check();
|
||||
}
|
||||
}
|
||||
|
@ -9,13 +9,17 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CacheStructureChecker {
|
||||
private String path = PropertiesLoader.getInstance().get(Property.PATH_TO_DIRECTORY) + "/.cache";
|
||||
private String path;
|
||||
private List<String> listToCheck = new ArrayList<String>();
|
||||
|
||||
public void check() {
|
||||
this.setupPathsToCheck();
|
||||
this.path = PropertiesLoader.getInstance().get(Property.PATH_TO_DIRECTORY);
|
||||
|
||||
this.listToCheck.forEach(s -> this.checkDirectory(s));
|
||||
if (this.path != null) {
|
||||
this.path += "/.cache";
|
||||
this.setupPathsToCheck();
|
||||
this.listToCheck.forEach(s -> this.checkDirectory(s));
|
||||
}
|
||||
}
|
||||
|
||||
private void setupPathsToCheck() {
|
||||
|
Loading…
Reference in New Issue
Block a user