diff --git a/options-home.json b/options-home.json
index 8a0d98f..8a9ddc5 100644
--- a/options-home.json
+++ b/options-home.json
@@ -5,5 +5,6 @@
"downloadPath" : "C:\\Users\\Strannik\\Documents\\esoe\\code\\sourceListener\\out\\zip",
"zipPath" : "C:\\Users\\Strannik\\Documents\\esoe\\code\\sourceListener\\out\\zip\\molokoin-client-master.zip",
"unzipPath" : "C:\\Users\\Strannik\\Documents\\esoe\\code\\sourceListener\\out\\unzip\\molokoin",
+ "sourcePath" : "C:\\Users\\Strannik\\Documents\\esoe\\code\\sourceListener\\out\\unzip\\molokoin\\molokoin-client",
"destinationPath" : "C:\\Users\\Strannik\\Documents\\esoe\\code\\sourceListener\\out\\var\\www\\html"
}
\ No newline at end of file
diff --git a/out/repos b/out/repos
index ab1d9fe..cd6a2c2 160000
--- a/out/repos
+++ b/out/repos
@@ -1 +1 @@
-Subproject commit ab1d9fe840340945098569399bb6ec50d5daccc0
+Subproject commit cd6a2c2e64ec4093db8a428c3e26c5aa09df1b79
diff --git a/out/var/www/html/index.html b/out/var/www/html/index.html
index e59d56b..17faf28 100644
--- a/out/var/www/html/index.html
+++ b/out/var/www/html/index.html
@@ -9,11 +9,13 @@
diff --git a/out/zip/molokoin-client-master.zip b/out/zip/molokoin-client-master.zip
index adefef5..7ef9d9f 100644
Binary files a/out/zip/molokoin-client-master.zip and b/out/zip/molokoin-client-master.zip differ
diff --git a/src/main/java/ru/molokoin/sourceListener/GitListener.java b/src/main/java/ru/molokoin/sourceListener/GitListener.java
index 0933cd3..343e9bd 100644
--- a/src/main/java/ru/molokoin/sourceListener/GitListener.java
+++ b/src/main/java/ru/molokoin/sourceListener/GitListener.java
@@ -4,10 +4,14 @@ import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.nio.file.DirectoryNotEmptyException;
+import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
+import java.util.Comparator;
import java.util.Enumeration;
+import java.util.Objects;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
@@ -72,13 +76,13 @@ public class GitListener {
try {
NetService.download(opt.getZipLink(), opt.getDownloadPath());
extract();
- move();
+ move(opt.getSourcePath(), opt.getDestinationPath());
} catch (IOException e) {
System.out.println(e.getMessage());
}
}
try {
- Thread.sleep(2000);
+ Thread.sleep(10000);
} catch (InterruptedException e) {
System.out.println("Проспал!!! Ошибка!!!");
e.printStackTrace();
@@ -132,13 +136,41 @@ public class GitListener {
}
/**
- *
+ * перемещаем файлы из директории source в target
*/
- 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");
+ public void move(String sourceString, String targetString) {
+ Path source = Path.of(sourceString);
+ Path target = Path.of(targetString);
System.out.println("Перемещение контента ... ");
- Files.move(source, target, StandardCopyOption.REPLACE_EXISTING);
+ System.out.println("sourceString: " + sourceString);
+ System.out.println("targetString: " + targetString);
+ try {
+ //просмотр содержимого папки target
+ try (DirectoryStream files = Files.newDirectoryStream(target)) {
+ for (Path path : files){
+ System.out.println("Очистка пути: " + path);//вывод содержимого в консоль
+ //очистка папки
+ if(Files.isDirectory(path)){
+ deleteDirectory(path);
+ }else{
+ Files.delete(path);
+ }
+ }
+ }
+ Files.move(source, target, StandardCopyOption.REPLACE_EXISTING);
+ System.out.println("Метод move() успешно выполнен!!!!");
+ } catch (IOException e) {
+ System.err.println("Ошибка в методе move():" + e.getMessage());
+ System.err.println("out >>>>>>>>>>>" + e.getLocalizedMessage());
+ e.printStackTrace();
+ }
+ }
+
+ public static void deleteDirectory(Path directory) throws IOException {
+ Files.walk(directory)
+ .sorted(Comparator.reverseOrder())
+ .map(Path::toFile)
+ .forEach(File::delete);
}
public static void main(String[] args) throws InvalidRemoteException, TransportException, GitAPIException, IOException {
diff --git a/src/main/java/ru/molokoin/sourceListener/apache2/ApacheService.java b/src/main/java/ru/molokoin/sourceListener/fs/ApacheService.java
similarity index 96%
rename from src/main/java/ru/molokoin/sourceListener/apache2/ApacheService.java
rename to src/main/java/ru/molokoin/sourceListener/fs/ApacheService.java
index 7a6b11c..1681226 100644
--- a/src/main/java/ru/molokoin/sourceListener/apache2/ApacheService.java
+++ b/src/main/java/ru/molokoin/sourceListener/fs/ApacheService.java
@@ -1,4 +1,4 @@
-package ru.molokoin.sourceListener.apache2;
+package ru.molokoin.sourceListener.fs;
import java.io.IOException;
import java.nio.file.DirectoryIteratorException;
diff --git a/src/main/java/ru/molokoin/sourceListener/opt/Options.java b/src/main/java/ru/molokoin/sourceListener/opt/Options.java
index cf48226..b70f843 100644
--- a/src/main/java/ru/molokoin/sourceListener/opt/Options.java
+++ b/src/main/java/ru/molokoin/sourceListener/opt/Options.java
@@ -7,6 +7,7 @@ public class Options {
private String downloadPath;
private String zipPath;
private String unzipPath;
+ private String sourcePath;
private String destinationPath;
public Options(){}
@@ -46,6 +47,12 @@ public class Options {
public String getZipPath() {
return zipPath;
}
+ public void setSourcePath(String sourcePath) {
+ this.sourcePath = sourcePath;
+ }
+ public String getSourcePath() {
+ return sourcePath;
+ }
public void setDestinationPath(String destinationPath) {
this.destinationPath = destinationPath;
}
@@ -60,6 +67,7 @@ public class Options {
s = s + "downloadPath : " + getDownloadPath() + "\n";
s = s + "zipPath : " + getZipPath() + "\n";
s = s + "unzipPath : " + getUnzipPath() + "\n";
+ s = s + "sourcePath : " + getSourcePath() + "\n";
s = s + "destinationPath : " + getDestinationPath() + "\n";
return s;
}
diff --git a/target/classes/ru/molokoin/sourceListener/GitListener.class b/target/classes/ru/molokoin/sourceListener/GitListener.class
index 4a17399..8bf212e 100644
Binary files a/target/classes/ru/molokoin/sourceListener/GitListener.class and b/target/classes/ru/molokoin/sourceListener/GitListener.class differ
diff --git a/target/classes/ru/molokoin/sourceListener/apache2/ApacheService.class b/target/classes/ru/molokoin/sourceListener/fs/ApacheService.class
similarity index 93%
rename from target/classes/ru/molokoin/sourceListener/apache2/ApacheService.class
rename to target/classes/ru/molokoin/sourceListener/fs/ApacheService.class
index 83886f6..34a82f8 100644
Binary files a/target/classes/ru/molokoin/sourceListener/apache2/ApacheService.class and b/target/classes/ru/molokoin/sourceListener/fs/ApacheService.class differ
diff --git a/target/classes/ru/molokoin/sourceListener/opt/Options.class b/target/classes/ru/molokoin/sourceListener/opt/Options.class
index 5b292d6..e2d4035 100644
Binary files a/target/classes/ru/molokoin/sourceListener/opt/Options.class and b/target/classes/ru/molokoin/sourceListener/opt/Options.class differ