From 44ea7455e1f440a8df4070604213b390c21e7a3d Mon Sep 17 00:00:00 2001 From: axtloss Date: Wed, 24 May 2023 23:43:57 +0200 Subject: Add command line options --- src/main/java/io/github/jshipit/OCIDataStore.java | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'src/main/java/io/github/jshipit/OCIDataStore.java') diff --git a/src/main/java/io/github/jshipit/OCIDataStore.java b/src/main/java/io/github/jshipit/OCIDataStore.java index 92db6c2..6991af4 100755 --- a/src/main/java/io/github/jshipit/OCIDataStore.java +++ b/src/main/java/io/github/jshipit/OCIDataStore.java @@ -20,13 +20,16 @@ public class OCIDataStore { public OCIDataStore(String path) { this.path = path; this.databasePath = path + "/datastore.db"; - createStore(); - try { - createStoreDatabase(); - } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) { - throw new RuntimeException(e); + if (!Files.isDirectory(Path.of(path))) { + createStore(); + } + if (!Files.exists(Path.of(this.databasePath))) { + try { + createStoreDatabase(); + } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) { + throw new RuntimeException(e); + } } - } private void createStore() { @@ -162,16 +165,12 @@ public class OCIDataStore { DockerAPIHelper api = new DockerAPIHelper(apiRepo, repo, image, tag); - System.out.println("API Token: " + api.getApiToken()); - JsonNode manifest = null; try { manifest = api.fetchManifestJson(); } catch (IOException ignored) {} // Proper error handling is bloat - System.out.println("Manifest: " + manifest); - Path path = Path.of(this.path+"/"+api.getImage()+"/"+api.getTag()); try { Files.createDirectory(path); @@ -197,8 +196,6 @@ public class OCIDataStore { } List layerDigests = new ArrayList<>(); for (JsonNode layer : layers) { - System.out.println("Layer: " + layer); - try { if (!isBlobInDatabase(layer.get("digest").asText())) { api.fetchBlob(layer.get("digest").asText(), layerpath, true, null); -- cgit v1.2.3