промежуточный. улучшение удаления баг репортов, в процессе отображения диалогового окна

This commit is contained in:
2024-08-18 01:08:56 +03:00
parent de1d81ac33
commit 39e9c634a2
12 changed files with 244 additions and 18 deletions

View File

@@ -9,6 +9,7 @@ import com.jcraft.jsch.ChannelSftp;
import java.io.File;
import java.nio.file.Paths;
import java.util.Comparator;
import java.util.Vector;
public class ArchivesBackupPass extends ConnectionPass<File> {
File src;
@@ -37,7 +38,13 @@ public class ArchivesBackupPass extends ConnectionPass<File> {
}
}
//сортируем по времени обновления. по убыванию.
files.sort((o1, o2) -> (int) (o2.updateTime - o1.updateTime));
files.sort(new Comparator<RemoteFile>() {
@Override
public int compare(RemoteFile o1, RemoteFile o2) {
return Long.compare(o1.updateTime, o2.updateTime);
}
}.reversed()
);
for (int i = 2; i < files.size(); ++i) {
user.connection.sftpChannel.rm(files.get(i).full_name);
}

View File

@@ -2,13 +2,19 @@ package Visual_DVM_2021.Passes.All;
import Common.Current;
import Common.Global;
import Common.UI.UI;
import Common.UI.Windows.Dialog.Dialog;
import Common.Utils.Utils;
import GlobalData.FileObject.FileObject;
import GlobalData.FileObject.FileObjectsDataSet;
import GlobalData.FileObject.FileObjectsFields;
import Visual_DVM_2021.Passes.PassCode_2021;
import Visual_DVM_2021.Passes.Pass_2021;
import Visual_DVM_2021.Passes.UI.CopyProjectFields;
import javax.swing.*;
import java.io.File;
import java.util.Arrays;
import java.util.Vector;
import java.nio.file.Paths;
import java.util.*;
public class DeleteDownloadedBugReports extends Pass_2021<Vector<File>> {
@Override
protected boolean needsAnimation() {
@@ -21,26 +27,73 @@ public class DeleteDownloadedBugReports extends Pass_2021<Vector<File>> {
@Override
protected boolean canStart(Object... args) throws Exception {
target = null;
if (passes.get(PassCode_2021.GetOldBugReports).Do()){
target = (Vector<File>) passes.get(PassCode_2021.GetOldBugReports).target;
FileObjectsDataSet set = new FileObjectsDataSet();
for (File file: target){
set.put(file.getName(),new FileObject(file));
}
//-
Dialog<Object, FileObjectsFields> dialog = new Dialog<Object, FileObjectsFields>(FileObjectsFields.class) {
@Override
public int getDefaultHeight() {
return 230;
}
@Override
public void Init(Object... params) {
set.mountUI((JPanel) content);
set.ShowUI();
}
@Override
public void validateFields() {
}
};
if (dialog.ShowDialog("Найдено "+target.size()+" загруженных баг-репортов, не использовавшихся 2 месяца и более. Удалить их?")) {
return true;
}
}
/*
else return false;
File workspace = Global.visualiser.getWorkspace();
File[] files = workspace.listFiles(pathname -> pathname.isDirectory() && pathname.getName().toLowerCase().startsWith("bugreport_"));
if (files != null) {
target = new Vector<>(Arrays.asList(files));
return UI.Warning("Будет удалено " + target.size() + " скачанных отчётов об ошибках." +
(Current.HasProject() ? "(Текущий проект будет закрыт)" : "")
);
//---
Calendar c = new GregorianCalendar();
c.setTimeInMillis(System.currentTimeMillis());
c.add(Calendar.MONTH, -2);
Date date = c.getTime();
System.out.println(date);
//---
return false;
//---
// return UI.Warning("Будет удалено " + target.size() + " скачанных отчётов об ошибках." +
// (Current.HasProject() ? "(Текущий проект будет закрыт)" : "")
// );
}
*/
return false;
}
@Override
protected void performPreparation() throws Exception {
/*
if (Current.HasProject())
passes.get(PassCode_2021.CloseCurrentProject).Do();
*/
}
@Override
protected void body() throws Exception {
/*
for (File file : target) {
ShowMessage1(file.getAbsolutePath());
Utils.forceDeleteWithCheck(file);
}
*/
UI.Info("+");
}
}

View File

@@ -0,0 +1,41 @@
package Visual_DVM_2021.Passes.All;
import Common.Global;
import Common.Utils.Utils;
import Visual_DVM_2021.Passes.Pass_2021;
import java.io.File;
import java.util.*;
public class GetOldBugReports extends Pass_2021<Vector<File>> {
@Override
protected boolean canStart(Object... args) throws Exception {
target = new Vector<>();
return true;
}
@Override
protected boolean needsAnimation() {
return true;
}
@Override
protected void body() throws Exception {
File workspace = Global.visualiser.getWorkspace();
File[] files = workspace.listFiles(pathname -> pathname.isDirectory() && pathname.getName().toLowerCase().startsWith("bugreport_"));
if (files != null) {
//---
Calendar c = new GregorianCalendar();
c.setTimeInMillis(System.currentTimeMillis());
c.add(Calendar.MONTH, -2);
Date date = c.getTime();
System.out.println(date);
long border = date.getTime();
//--
for (File file: files){
ShowMessage2(file.getName());
long mdate = Utils.getNewestFileDate(file);
if (mdate<=border){
target.add(file);
}
}
}
}
}

View File

@@ -1,10 +1,13 @@
package Visual_DVM_2021.Passes.All;
import Repository.Server.ServerCode;
import Repository.Server.ServerExchangeUnit_2021;
import Visual_DVM_2021.Passes.Server.TestingSystemPass;
public class TestPass extends TestingSystemPass {
import Common.Utils.Utils;
import Visual_DVM_2021.Passes.Pass_2021;
import java.io.File;
public class TestPass extends Pass_2021<File> {
@Override
protected void ServerAction() throws Exception {
// Command(new ServerExchangeUnit_2021(ServerCode.GetSapforActualVersion));
protected void body() throws Exception {
//определить дату изменения проекта.
target = new File("E:\\Tests\\bugreport_1712090719\\SP");
Utils.getNewestFileDate(target);
}
}

View File

@@ -340,12 +340,15 @@ public enum PassCode_2021 {
ShowTestingServerFile,
//--
ShowSapforCompilationOut,
ShowSapforCompilationErr;
ShowSapforCompilationErr,
GetOldBugReports;
//--
public String getDescription() {
switch (this) {
case Undefined:
return "?";
case GetOldBugReports:
return "Получить неиспользуемые баг репорты";
case SPF_RenameIncludes:
return "Переименование заголовочных файлов";
case ShowSapforCompilationOut: