Skip to content

Commit f9dbccb

Browse files
committed
move ensure updated into kernel
1 parent 7cd1fcd commit f9dbccb

File tree

2 files changed

+32
-6
lines changed

2 files changed

+32
-6
lines changed

src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,28 @@ public class BowlerKernel {
7777
// private static final String CSG = null;
7878
private static File historyFile = new File(ScriptingEngine.getWorkspace().getAbsolutePath() + "/bowler.history");
7979
private static boolean kernelMode = true;
80-
80+
public static void ensureUpdated(boolean check,String ... urls) {
81+
for(String s:urls) {
82+
83+
if(s==null)
84+
continue;
85+
try {
86+
File wd = ScriptingEngine.getRepositoryCloneDirectory(s);
87+
if(check && wd.exists()) {
88+
Log.error("Skipping update, clone exists "+s);
89+
continue;
90+
}
91+
Log.debug("Pulling "+s);
92+
ScriptingEngine.cloneRepo(s, null);
93+
ScriptingEngine.pull(s);
94+
} catch (Throwable e) {
95+
// Auto-generated catch block
96+
e.printStackTrace();
97+
//ScriptingEngine.deleteRepo(s);
98+
//ScriptingEngine.cloneRepo(s, null);
99+
}
100+
}
101+
}
81102
private static void loadHistoryLocal() {
82103
historyFile = new File(ScriptingEngine.getWorkspace().getAbsolutePath() + "/bowler.history");
83104
ArrayList<String> history = new ArrayList<>();

src/main/java/com/neuronrobotics/bowlerstudio/assets/AssetFactory.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public static javafx.scene.image.ImageView loadIcon(String file) {
151151
}
152152
}
153153

154-
public static String getGitSource() throws Exception {
154+
public static String getGitSource() {
155155
return gitSource;
156156
}
157157

@@ -165,17 +165,22 @@ public static void setGitSource(String gitSource, String assetRepoBranch) throws
165165
}
166166

167167
public static void loadAllAssets() throws Exception {
168+
List<String> files = cloneAllRepos();
169+
for (String file : files) {
170+
//com.neuronrobotics.sdk.common.Log.error("Loading asset file: " + file);
171+
loadAsset(file);
172+
}
173+
}
174+
175+
public static List<String> cloneAllRepos() throws Exception {
168176
com.neuronrobotics.sdk.common.Log.info("Loading assets");
169177
List<String> files;
170178
try {
171179
files = ScriptingEngine.filesInGit(gitSource, null, null);
172180
} catch (Exception ex) {
173181
files = ScriptingEngine.filesInGit(getGitSource());
174182
}
175-
for (String file : files) {
176-
//com.neuronrobotics.sdk.common.Log.error("Loading asset file: " + file);
177-
loadAsset(file);
178-
}
183+
return files;
179184
}
180185

181186
public static String getAssetRepoBranch() {

0 commit comments

Comments
 (0)