From dec48351876953c7323e88e18deb15118af51e7c Mon Sep 17 00:00:00 2001 From: 02090095 Date: Fri, 7 Mar 2025 17:26:13 +0300 Subject: [PATCH] =?UTF-8?q?=D1=83=D0=BF=D1=80=D0=B0=D0=B7=D0=B4=D0=BD?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BF=D0=BE=D1=81=D1=82=D0=BE=D1=8F?= =?UTF-8?q?=D0=BD=D0=BD=D0=BE=D0=B3=D0=BE=20=D1=85=D1=80=D0=B0=D0=BD=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D1=8F=20=D1=82=D0=B5=D1=81=D1=82=D0=BE=D0=B2=D1=8B?= =?UTF-8?q?=D1=85=20=D0=B0=D1=80=D1=85=D0=B8=D0=B2=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/workspace.xml | 9 ++------ src/_VisualDVM/Constants.java | 2 +- src/_VisualDVM/Passes/All/DownloadTest.java | 12 +++++++---- .../Repository/Server/ServerCode.java | 2 ++ .../TestingSystem/Common/Test/Test.java | 17 +++------------ .../TestingSystem/Common/TestingServer.java | 21 +++++++------------ .../TestingSystem/Common/TestsDatabase.java | 7 ------- 7 files changed, 23 insertions(+), 47 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 544ba325..5515acc4 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -8,14 +8,9 @@ - - - - - - - + + diff --git a/src/_VisualDVM/Constants.java b/src/_VisualDVM/Constants.java index 9547c9d5..a5054078 100644 --- a/src/_VisualDVM/Constants.java +++ b/src/_VisualDVM/Constants.java @@ -49,7 +49,7 @@ public class Constants { // //7998 отладочный порт. теперь. public static final int ComponentsServerPort = 7995; //7795 - public static final int TestingServerPort = 7996; //7996 + public static final int TestingServerPort = 7998; //7996 public static final int SocketTimeout = 0; //- public static final String ServerAddress = "alex-freenas.ddns.net"; diff --git a/src/_VisualDVM/Passes/All/DownloadTest.java b/src/_VisualDVM/Passes/All/DownloadTest.java index 7c4e5e9b..ad6a1459 100644 --- a/src/_VisualDVM/Passes/All/DownloadTest.java +++ b/src/_VisualDVM/Passes/All/DownloadTest.java @@ -7,13 +7,17 @@ import _VisualDVM.Passes.PassCode; import _VisualDVM.Passes.Server.TestingServerPass; import _VisualDVM.Repository.Server.ServerCode; import _VisualDVM.TestingSystem.Common.Test.Test; + +import java.io.File; public class DownloadTest extends TestingServerPass { + File testArchive; @Override public String getIconPath() { return "/icons/DownloadBugReport.png"; } @Override protected boolean canStart(Object... args) throws Exception { + testArchive= null; if (Global.mainModule.getAccount().CheckRegistered(Log) && Global.testingServer.db.tests.getUI().CheckCurrent(Log) ) { @@ -26,22 +30,22 @@ public class DownloadTest extends TestingServerPass { protected void performPreparation() throws Exception { Global.mainModule.getPass(PassCode.CloseCurrentProject).Do(); Global.mainModule.set(Current.Root, null); //чтобы гарантированно не существовало корня. - Utils_.forceDeleteWithCheck(target.getArchive()); Utils_.forceDeleteWithCheck(target.getHomePath()); } @Override protected void body() throws Exception { - request.server_response.Unpack(target.getArchive()); + testArchive= new File(Global.TempDirectory, Utils_.getDateName(String.valueOf(target.id))); + request.server_response.Unpack(testArchive); } @Override protected boolean validate() { - return target.getArchive().exists(); + return testArchive.exists(); } @Override protected void performDone() throws Exception { super.performDone(); if (Global.mainModule.getPass(PassCode.UnzipFolderPass).Do( - target.getArchive().getAbsolutePath(), + testArchive.getAbsolutePath(), Global.visualiser.getDownloadsDirectory().getAbsolutePath(), false )) if (UI.Question("Тестовый проект успешно загружен под именем\n" + diff --git a/src/_VisualDVM/Repository/Server/ServerCode.java b/src/_VisualDVM/Repository/Server/ServerCode.java index a3f0d476..104db01c 100644 --- a/src/_VisualDVM/Repository/Server/ServerCode.java +++ b/src/_VisualDVM/Repository/Server/ServerCode.java @@ -131,6 +131,8 @@ public enum ServerCode { return "Дублирование объекта на сервере"; case UpdateActiveDVMPackages: return "Актуализация активных DVM пакетов на сервере"; + case RefreshDVMTests: + return "Синхронизация стандартных DVM тестов"; default: return this.toString(); } diff --git a/src/_VisualDVM/TestingSystem/Common/Test/Test.java b/src/_VisualDVM/TestingSystem/Common/Test/Test.java index a5492e14..1ab6c82e 100644 --- a/src/_VisualDVM/TestingSystem/Common/Test/Test.java +++ b/src/_VisualDVM/TestingSystem/Common/Test/Test.java @@ -29,8 +29,6 @@ public class Test extends riDBObject { public String args = ""; //аргументы командной строки. на всякий случай поле зарезервирую. пусть будут. @Description("DEFAULT -1") public int group_id = CommonConstants.Nan; - //@Description("DEFAULT ''") - //public String files = ""; //файлы теста @Description("DEFAULT ''") public String extended_description=""; @Description("DEFAULT ''") @@ -64,10 +62,6 @@ public class Test extends riDBObject { Global.mainModule.getUI().getMainWindow().ShowCheckedTestsCount(); } //- - public File getArchive() { - return new File(Global.TestsDirectory, id + ".zip"); - } - //- public File getServerPath() { return new File(Global.TestsDirectory, String.valueOf(id)); } @@ -85,7 +79,6 @@ public class Test extends riDBObject { File tmpArchive = new File(Global.TempDirectory, temp_project_name + ".zip"); File tmpProject = new File(Global.TempDirectory, temp_project_name); File testProject = new File(Global.TestsDirectory, String.valueOf(id)); - File testArchive = new File(Global.TestsDirectory, id + ".zip"); //-- if (tmpArchive.exists()) FileUtils.forceDelete(tmpArchive); @@ -93,11 +86,9 @@ public class Test extends riDBObject { FileUtils.forceDelete(tmpProject); if (testProject.exists()) FileUtils.forceDelete(testProject); - if (testArchive.exists()) - FileUtils.forceDelete(testArchive); //-- Utils_.bytesToFile(project_archive_bytes, tmpArchive); // распаковка байтов. - //-- + //-- делается через другое имя, потому что на момент публикации теста архив не мог знать ид теста. UnzipFolderPass unzipFolderPass = new UnzipFolderPass(); if (!unzipFolderPass.Do( tmpArchive.getAbsolutePath(), @@ -106,10 +97,9 @@ public class Test extends riDBObject { } //-- FileUtils.moveDirectory(tmpProject, testProject); + if (tmpArchive.exists()) + FileUtils.forceDelete(tmpArchive); //-- - ZipFolderPass zip = new ZipFolderPass(); - if (!zip.Do(testProject.getAbsolutePath(), testArchive.getAbsolutePath())) - throw new RepositoryRefuseException("Не удалось переписать архив проекта"); return true; } //todo проджект файлы тут не нужны. сделать с учетом джсона @@ -129,5 +119,4 @@ public class Test extends riDBObject { } return res; } - //- } diff --git a/src/_VisualDVM/TestingSystem/Common/TestingServer.java b/src/_VisualDVM/TestingSystem/Common/TestingServer.java index 3e90e33a..98e37a62 100644 --- a/src/_VisualDVM/TestingSystem/Common/TestingServer.java +++ b/src/_VisualDVM/TestingSystem/Common/TestingServer.java @@ -178,7 +178,6 @@ public class TestingServer extends RepositoryServer { protected void afterDeleteAction(DBObject object) throws Exception { if (object instanceof Test) { Test test = (Test) object; - Utils_.forceDeleteWithCheck(test.getArchive()); Utils_.forceDeleteWithCheck(test.getServerPath()); //-- for (DVMConfiguration dvmConfiguration : db.dvmConfigurations.Data.values()) { @@ -211,7 +210,6 @@ public class TestingServer extends RepositoryServer { //-- for (Test group_test : groupTests.values()) { db.Delete(group_test); - Utils_.forceDeleteWithCheck(group_test.getArchive()); Utils_.forceDeleteWithCheck(group_test.getServerPath()); } //-- @@ -291,7 +289,6 @@ public class TestingServer extends RepositoryServer { protected void startAdditionalThreads() { testingThread.start(); } - void PerformAutoSapforTesting() throws Exception { TextLog Log = new TextLog(); SapforPackage autoPackage = tryAutoSapforTesting(Log); @@ -311,7 +308,12 @@ public class TestingServer extends RepositoryServer { int test_id = Integer.parseInt(request.arg); if (db.tests.containsKey(test_id)) { Test test = db.tests.get(test_id); - response = new ServerExchangeUnit_2021(ServerCode.OK, "", Utils_.fileToBytes(test.getArchive())); + File archive = new File(Global.TempDirectory, Utils_.getDateName(String.valueOf(test.id))); + ZipFolderPass zipFolderPass = new ZipFolderPass(); + if (!zipFolderPass.Do(test.getServerPath().getAbsolutePath(), archive.getAbsolutePath())) + throw new RepositoryRefuseException("Не удалось заархивировать тест"); + response = new ServerExchangeUnit_2021(ServerCode.OK, "", Utils_.fileToBytes(archive)); + FileUtils.forceDelete(archive); } else throw new RepositoryRefuseException("Теста с именем " + request.arg + " не существует"); } @@ -690,7 +692,6 @@ public class TestingServer extends RepositoryServer { } } } - ZipFolderPass zip = new ZipFolderPass(); //создание тестов. ServerSapfor serverSapfor = db.serverSapfors.getLastDoneVersion(); Vector tests = new Vector<>(); @@ -699,7 +700,7 @@ public class TestingServer extends RepositoryServer { File[] files = src.listFiles(pathname -> !pathname.isDirectory()); if (files != null && files.length > 0) { //-- - TestFilesJson filesJson= new TestFilesJson(); + TestFilesJson filesJson = new TestFilesJson(); for (File file : files) { filesJson.values.add(new TestFileJson(new ProjectFile(file))); } @@ -714,19 +715,11 @@ public class TestingServer extends RepositoryServer { db.Insert(test); //--- File testProject = new File(Global.TestsDirectory, String.valueOf(test.id)); - File testArchive = new File(Global.TestsDirectory, test.id + ".zip"); //--- if (testProject.exists()) FileUtils.forceDelete(testProject); - if (testArchive.exists()) - FileUtils.forceDelete(testArchive); - //--- FileUtils.copyDirectory(src, testProject); //--- - if (!zip.Do(testProject.getAbsolutePath(), testArchive.getAbsolutePath())) { - db.Delete(test); - throw new RepositoryRefuseException("Не удалось переписать архив проекта"); - } tests.add(test); db.DetectTestMinMaxDim(serverSapfor, group, test); } diff --git a/src/_VisualDVM/TestingSystem/Common/TestsDatabase.java b/src/_VisualDVM/TestingSystem/Common/TestsDatabase.java index 8bc9269e..ece357a3 100644 --- a/src/_VisualDVM/TestingSystem/Common/TestsDatabase.java +++ b/src/_VisualDVM/TestingSystem/Common/TestsDatabase.java @@ -194,13 +194,6 @@ public class TestsDatabase extends SQLiteDatabase { File testFile = Paths.get(testDirectory.getAbsolutePath(), file.getName()).toFile(); FileUtils.copyFile(file, testFile); //---- - //архивация. - File archive = test.getArchive(); - if (archive.exists()) - FileUtils.forceDelete(archive); - //----------->> - ZipFolderPass zip = new ZipFolderPass(); - zip.Do(testDirectory.getAbsolutePath(), archive.getAbsolutePath()); DetectTestMinMaxDim(sapfor, group, test); } //---