упорядочил папки с кодом.
This commit is contained in:
48
src/Common/Passes/All/PublishTestProject.java
Normal file
48
src/Common/Passes/All/PublishTestProject.java
Normal file
@@ -0,0 +1,48 @@
|
||||
package Common.Passes.All;
|
||||
import Common.Constants;
|
||||
import Common.Global;
|
||||
import Common.Utils.Utils;
|
||||
import ProjectData.Project.db_project_info;
|
||||
import Repository.ServerCode;
|
||||
import Repository.ServerExchangeUnit_2021;
|
||||
import Common.Passes.PassCode_2021;
|
||||
import Common.Passes.PassException;
|
||||
import Common.Passes.Server.TestingSystemPass;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Paths;
|
||||
public class PublishTestProject extends TestingSystemPass<db_project_info> {
|
||||
Object test_id;
|
||||
byte[] bytes = null;
|
||||
@Override
|
||||
protected boolean canStart(Object... args) throws Exception {
|
||||
target = (db_project_info) args[0];
|
||||
test_id = args[1];
|
||||
bytes = null;
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
protected void performPreparation() throws Exception {
|
||||
File src = new File(Global.TempDirectory, String.valueOf(test_id));
|
||||
Utils.CheckAndCleanDirectory(src);
|
||||
target.Clone(src, false);
|
||||
FileUtils.copyFile(target.db.getFile(),
|
||||
Paths.get(src.getAbsolutePath(), Constants.data, target.db.getFile().getName()).toFile());
|
||||
//архивация.
|
||||
File archive = Utils.getTempFileName(String.valueOf(test_id));
|
||||
//---
|
||||
if (passes.get(PassCode_2021.ZipFolderPass).Do(src.getAbsolutePath(), archive.getAbsolutePath())) {
|
||||
bytes = Utils.packFile(archive);
|
||||
} else throw new PassException("Не удалось создать архив проекта");
|
||||
}
|
||||
@Override
|
||||
protected void ServerAction() throws Exception {
|
||||
Command(new ServerExchangeUnit_2021(ServerCode.PublishTestProject, String.valueOf(test_id), bytes));
|
||||
}
|
||||
@Override
|
||||
protected void performFail() throws Exception {
|
||||
super.performFail();
|
||||
passes.get(PassCode_2021.SynchronizeTests).Do();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user