diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..c5f3f6b --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "java.configuration.updateBuildConfiguration": "interactive" +} \ No newline at end of file diff --git a/options-main.json b/options-main.json index 3dcb972..96fb58b 100644 --- a/options-main.json +++ b/options-main.json @@ -4,5 +4,6 @@ "gitLocalPath" : "/home/esoe/Documents/repos-listen/molokoin/repo", "downloadPath" : "/home/esoe/Documents/repos-listen/molokoin/downloads", "zipPath" : "/home/esoe/Documents/repos-listen/molokoin/downloads/molokoin-client-master.zip", - "unzipPath" : "/var/www/html" + "unzipPath" : "/home/esoe/Documents/repos-listen/molokoin/unzip/", + "destinationPath" : "/home/esoe/Documents/repos-listen/molokoin/var/www/html" } \ No newline at end of file diff --git a/pom.xml b/pom.xml index af9dec9..bbc9bd4 100644 --- a/pom.xml +++ b/pom.xml @@ -34,6 +34,11 @@ org.eclipse.jgit 6.3.0.202209071007-r + + commons-io + commons-io + 2.11.0 + \ No newline at end of file diff --git a/src/main/java/ru/molokoin/sourceListener/GitListener.java b/src/main/java/ru/molokoin/sourceListener/GitListener.java index d27e9d9..12be418 100644 --- a/src/main/java/ru/molokoin/sourceListener/GitListener.java +++ b/src/main/java/ru/molokoin/sourceListener/GitListener.java @@ -20,6 +20,7 @@ import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.api.errors.InvalidRemoteException; import org.eclipse.jgit.api.errors.NoHeadException; import org.eclipse.jgit.api.errors.TransportException; +import org.eclipse.jgit.util.FileUtils; import com.fasterxml.jackson.core.exc.StreamReadException; import com.fasterxml.jackson.databind.DatabindException; @@ -31,7 +32,7 @@ import ru.molokoin.sourceListener.opt.Options; public class GitListener { public Options opt; - public String optionsPath = "options-home.json"; + public String optionsPath = "options-main.json"; public GitListener(){ try { @@ -76,11 +77,11 @@ public class GitListener { extract(); move(); } catch (IOException e) { - System.out.println(e.getMessage()); + System.out.println("Ошибка move(): " + e.getMessage()); } } try { - Thread.sleep(2000); + Thread.sleep(10000); } catch (InterruptedException e) { System.out.println("Проспал!!! Ошибка!!!"); e.printStackTrace(); @@ -137,10 +138,16 @@ public class GitListener { * */ public void move() throws IOException { - Path source = Path.of("C:\\Users\\Strannik\\Documents\\esoe\\code\\sourceListener\\out\\unzip\\molokoin\\molokoin-client"); - Path target = Path.of("C:\\Users\\Strannik\\Documents\\esoe\\code\\sourceListener\\out\\war\\www\\html"); + Path source = Path.of("/home/esoe/Documents/repos-listen/molokoin/unzip/molokoin-client"); + Path target = Path.of(opt.getDestinationPath()); + //освобождение target + System.out.println("освобождение target ..."); + FileUtils.delete(target.toFile()); + //перемещение контента System.out.println("Перемещение контента ... "); - Files.move(source, target, StandardCopyOption.REPLACE_EXISTING); + Files.move(source, target, StandardCopyOption.ATOMIC_MOVE); + System.out.println("Перемещение контента завершено. "); + } public static void main(String[] args) throws InvalidRemoteException, TransportException, GitAPIException, IOException { diff --git a/target/classes/ru/molokoin/sourceListener/GitListener.class b/target/classes/ru/molokoin/sourceListener/GitListener.class index a493e9d..b673c51 100644 Binary files a/target/classes/ru/molokoin/sourceListener/GitListener.class and b/target/classes/ru/molokoin/sourceListener/GitListener.class differ