Обощение массовой загрузки пакетов с сервера.
This commit is contained in:
@@ -2,73 +2,30 @@ package Visual_DVM_2021.Passes.All;
|
||||
import Common.Constants;
|
||||
import Common.Current;
|
||||
import Common.Global;
|
||||
import Common.Utils.Utils;
|
||||
import Repository.Server.ServerCode;
|
||||
import Repository.Server.ServerExchangeUnit_2021;
|
||||
import TestingSystem.Common.TasksPackageState;
|
||||
import TestingSystem.DVM.DVMPackage.DVMPackage;
|
||||
import TestingSystem.DVM.TasksPackage.TasksPackageState;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
import Visual_DVM_2021.Passes.Server.TestingSystemPass;
|
||||
import javafx.util.Pair;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Date;
|
||||
public class DownloadDVMPackage extends TestingSystemPass<DVMPackage> {
|
||||
@Override
|
||||
public String getIconPath() {
|
||||
return "/icons/DownloadBugReport.png";
|
||||
}
|
||||
@Override
|
||||
public String getButtonText() {
|
||||
return "";
|
||||
}
|
||||
File workspace;
|
||||
File results_zip;
|
||||
File results;
|
||||
File loaded;
|
||||
@Override
|
||||
import java.util.Vector;
|
||||
public class DownloadDVMPackage extends DownloadDVMPackages {
|
||||
protected boolean canStart(Object... args) throws Exception {
|
||||
if (Current.Check(Log, Current.DVMPackage)){
|
||||
if (Current.Check(Log, Current.DVMPackage)) {
|
||||
//--
|
||||
target = Current.getDVMPackage();
|
||||
workspace = target.getLocalWorkspace();
|
||||
results_zip = new File(workspace, "results.zip");
|
||||
results = new File(workspace, "results");
|
||||
loaded = new File(workspace, Constants.LOADED);
|
||||
DVMPackage dvmPackage = Current.getDVMPackage();
|
||||
//--
|
||||
if (!target.state.equals(TasksPackageState.Done)){
|
||||
if (!dvmPackage.state.equals(TasksPackageState.Done)) {
|
||||
Log.Writeln_("Возможно скачать и отобразить задачи только завершённого пакета!");
|
||||
return false;
|
||||
}
|
||||
if (loaded.exists()){
|
||||
/// Log.Writeln_("Пакет уже загружен");
|
||||
Global.testingServer.db.dvmRunTasks.ShowDVMPackage(target);
|
||||
if (new File(dvmPackage.getLocalWorkspace(), Constants.LOADED).exists()) {
|
||||
/// Log.Writeln_("Пакет уже загружен");
|
||||
Global.testingServer.db.dvmRunTasks.ShowDVMPackage(dvmPackage);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
Vector<Integer> packages = new Vector<>();
|
||||
packages.add(dvmPackage.id);
|
||||
return super.canStart(packages);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
protected void performPreparation() throws Exception {
|
||||
Utils.CheckAndCleanDirectory(target.getLocalWorkspace());
|
||||
}
|
||||
@Override
|
||||
protected void ServerAction() throws Exception {
|
||||
Command(new ServerExchangeUnit_2021(ServerCode.DownloadDVMPackage,"", target.id));
|
||||
}
|
||||
@Override
|
||||
protected void performDone() throws Exception {
|
||||
super.performDone();
|
||||
Pair<byte[], byte[]> packed = (Pair<byte[], byte[]>) response.object;
|
||||
Utils.unpackFile(packed.getKey(), results_zip);
|
||||
Utils.unpackFile(packed.getValue(), target.getJsonFile());
|
||||
passes.get(PassCode_2021.UnzipFolderPass).Do(results_zip.getAbsolutePath(), workspace.getAbsolutePath());
|
||||
FileUtils.writeStringToFile(loaded, new Date().toString());
|
||||
}
|
||||
@Override
|
||||
protected void showDone() throws Exception {
|
||||
Global.testingServer.db.dvmRunTasks.ShowDVMPackage(target);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user