Files
VisualSapfor/src/_VisualDVM/Passes/All/DownloadAllBugReportsArchives.java
2025-02-15 23:30:48 +03:00

54 lines
2.0 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package _VisualDVM.Passes.All;
import _VisualDVM.Current;
import _VisualDVM.Global;
import _VisualDVM.Passes.PassCode;
import _VisualDVM.Passes.Server.ComponentsServerPass;
import _VisualDVM.Repository.Server.ServerCode;
import _VisualDVM.Utils;
import org.apache.commons.io.FileUtils;
import java.io.File;
import java.nio.file.Paths;
public class DownloadAllBugReportsArchives extends ComponentsServerPass<File> {
@Override
public String getIconPath() {
return "/icons/DownloadAll.png";
}
@Override
protected void performPreparation() throws Exception {
Global.mainModule.getPass(PassCode.CloseCurrentProject).Do();
Global.mainModule.set(Current.Root, null); //чтобы гарантированно не существовало корня.
Utils.CleanDirectory(Global.BugReportsDirectory);
}
@Override
protected boolean canStart(Object... args) throws Exception {
return SendRequest(ServerCode.ReceiveAllArchives, "", null);
}
@Override
protected void body() throws Exception {
request.server_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());
}
}
}
}