упразднение постоянного хранения тестовых архивов

This commit is contained in:
2025-03-07 17:26:13 +03:00
parent d66fdc5e77
commit dec4835187
7 changed files with 23 additions and 47 deletions

View File

@@ -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;
}
//-
}

View File

@@ -178,7 +178,6 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
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<TestsDatabase> {
//--
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<TestsDatabase> {
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<TestsDatabase> {
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<TestsDatabase> {
}
}
}
ZipFolderPass zip = new ZipFolderPass();
//создание тестов.
ServerSapfor serverSapfor = db.serverSapfors.getLastDoneVersion();
Vector<Test> tests = new Vector<>();
@@ -699,7 +700,7 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
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<TestsDatabase> {
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);
}

View File

@@ -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);
}
//---