v++
рефакторинг. Исправлен баг. если прервать локальную задачу, не удалялся файл interrupt.
This commit is contained in:
@@ -4,7 +4,7 @@ import Common.Utils.Utils;
|
||||
import GlobalData.Machine.Machine;
|
||||
import GlobalData.RemoteFile.RemoteFile;
|
||||
import GlobalData.User.User;
|
||||
import files.ConnectionPass;
|
||||
import Visual_DVM_2021.Passes.SSH.ConnectionPass;
|
||||
import com.jcraft.jsch.ChannelSftp;
|
||||
|
||||
import java.io.File;
|
||||
@@ -20,18 +20,14 @@ public class ArchivesBackupPass extends ConnectionPass<File> {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
protected boolean needsInitialize() {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
protected void ServerAction() throws Exception {
|
||||
String workspace_path = Utils.toU(Paths.get(sftpChannel.getHome(),Global.properties.BackupWorkspace).toString());
|
||||
String workspace_path = Utils.toU(Paths.get(user.connection.sftpChannel.getHome(), Global.properties.BackupWorkspace).toString());
|
||||
RemoteFile workspace = new RemoteFile(workspace_path, true);
|
||||
tryMKDir(workspace);
|
||||
user.connection.MKDIR(workspace);
|
||||
RemoteFile dst = new RemoteFile(workspace.full_name, src.getName());
|
||||
putSingleFile(src, dst);
|
||||
user.connection.putSingleFile(src, dst);
|
||||
//-теперь, удалить старые файлы.
|
||||
Vector<ChannelSftp.LsEntry> raw_files = sftpChannel.ls(workspace.full_name);
|
||||
Vector<ChannelSftp.LsEntry> raw_files = user.connection.sftpChannel.ls(workspace.full_name);
|
||||
Vector<RemoteFile> files = new Vector<>();
|
||||
for (ChannelSftp.LsEntry file : raw_files) {
|
||||
if (!file.getAttrs().isDir()) {
|
||||
@@ -44,7 +40,7 @@ public class ArchivesBackupPass extends ConnectionPass<File> {
|
||||
files.sort((o1, o2) -> (int) (o2.updateTime - o1.updateTime));
|
||||
for (int i = 2; i < files.size(); ++i) {
|
||||
System.out.println(files.get(i).full_name + ":" + files.get(i).updateTime);
|
||||
sftpChannel.rm(files.get(i).full_name);
|
||||
user.connection.sftpChannel.rm(files.get(i).full_name);
|
||||
}
|
||||
//--------------
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user