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