61 lines
2.2 KiB
Java
61 lines
2.2 KiB
Java
package Visual_DVM_2021.Passes.All;
|
||
import Common.Current_;
|
||
import _VisualDVM.Current;
|
||
import _VisualDVM.Global;
|
||
import _VisualDVM.Utils;
|
||
import _VisualDVM.Repository.Server.ServerCode;
|
||
import _VisualDVM.Repository.Server.ServerExchangeUnit_2021;
|
||
import Visual_DVM_2021.Passes.Server.ComponentsRepositoryPass;
|
||
import Visual_DVM_2021.Passes.PassCode;
|
||
import org.apache.commons.io.FileUtils;
|
||
|
||
import java.io.File;
|
||
import java.nio.file.Paths;
|
||
public class DownloadAllBugReportsArchives extends ComponentsRepositoryPass<File> {
|
||
@Override
|
||
public String getIconPath() {
|
||
return "/icons/DownloadAll.png";
|
||
}
|
||
@Override
|
||
public String getButtonText() {
|
||
return "";
|
||
}
|
||
@Override
|
||
protected void performPreparation() throws Exception {
|
||
Global.mainModule.getPass(PassCode.CloseCurrentProject).Do();
|
||
Global.mainModule.set(Current.Root, null); //чтобы гарантированно не существовало корня.
|
||
Utils.CleanDirectory(Global.BugReportsDirectory);
|
||
}
|
||
@Override
|
||
protected int getTimeout() {
|
||
return 60000;
|
||
}
|
||
@Override
|
||
protected void ServerAction() throws Exception {
|
||
Command(new ServerExchangeUnit_2021(ServerCode.ReceiveAllArchives));
|
||
response.Unpack(target = Utils.getTempFileName("bugs"));
|
||
}
|
||
@Override
|
||
protected boolean validate() {
|
||
return target.exists();
|
||
}
|
||
@Override
|
||
protected void performDone() throws Exception {
|
||
File tempFolder = Utils.getTempFileName("bugsBuffer");
|
||
//-
|
||
Global.mainModule.getPass(PassCode.UnzipFolderPass).Do(
|
||
target.getAbsolutePath(),
|
||
tempFolder.getAbsolutePath()
|
||
);
|
||
//-
|
||
//теперь скопировать это в папку Bugs, с нормальными именами через zip
|
||
File t2 = Paths.get(tempFolder.getAbsolutePath(), "Bugs").toFile();
|
||
File[] archives = t2.listFiles();
|
||
if (archives != null) {
|
||
for (File file : archives) {
|
||
FileUtils.moveFile(file, Paths.get(Global.BugReportsDirectory.getAbsolutePath(), file.getName() + ".zip").toFile());
|
||
}
|
||
}
|
||
}
|
||
}
|