lim-exporter http://jira.mfd.msk:8088/browse/CLS-262 sFTP улучшил надёжность удаления временных файлов
This commit is contained in:
parent
522f4f955d
commit
fc5d14db85
1 changed files with 8 additions and 2 deletions
|
|
@ -12,6 +12,7 @@ import ru.spcex.clearing.lim.exporter.config.SFTPConfig;
|
|||
import ru.spcex.clearing.platform.messaging.domain.cud.utilities.LimExportedRequest;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
import ru.spcex.platform.utils.log.ExceptionUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
|
@ -52,13 +53,18 @@ public abstract class AbstractExporterService {
|
|||
|
||||
Path limFilePath = limFile.toPath();
|
||||
try {
|
||||
// todo возможная оптимизация: посмотреть размеры файлов, возможно обойтись без временного файла
|
||||
Files.write(limFilePath, getLimFileRows());
|
||||
gateway.sendToSftp(limFile);
|
||||
|
||||
Files.deleteIfExists(limFilePath);
|
||||
} catch (IOException e) {
|
||||
log.error("Failed export {} file", fileName);
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
try {
|
||||
Files.deleteIfExists(limFilePath);
|
||||
} catch (IOException e) {
|
||||
log.warn("Can not delete temp file \"{}\": {}", limFilePath, ExceptionUtils.getStackTrace(e));
|
||||
}
|
||||
}
|
||||
log.debug("Successfully exported {} file", fileName);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue