Files
VisualSapfor/src/Visual_DVM_2021/Passes/All/DownloadAllBugReportsArchives.java
2023-11-19 02:12:44 +03:00

60 lines
2.1 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 Visual_DVM_2021.Passes.All;
import Common.Current;
import Common.Global;
import Common.Utils.Utils;
import Repository.Server.ServerCode;
import Repository.Server.ServerExchangeUnit_2021;
import Visual_DVM_2021.Passes.Server.ComponentsRepositoryPass;
import Visual_DVM_2021.Passes.PassCode_2021;
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 {
passes.get(PassCode_2021.CloseCurrentProject).Do();
Current.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");
//-
passes.get(PassCode_2021.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());
}
}
}
}