Skip to content

Commit

Permalink
Update PipeTransferTsFileHandler.java
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveYurongSu committed Jun 19, 2024
1 parent 0abc2e0 commit 6f8b5a6
Showing 1 changed file with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.file.NoSuchFileException;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -212,12 +211,11 @@ public void onComplete(final TPipeTransferResp response) {
if (reader != null) {
reader.close();
}

// Delete current file when using tsFile as batch
if (!(events.get(0) instanceof PipeTsFileInsertionEvent)) {
if (events.stream().anyMatch(event -> !(event instanceof PipeTsFileInsertionEvent))) {
FileUtils.delete(currentFile);
}
} catch (final NoSuchFileException e) {
LOGGER.info("The file {} is not found, may already be deleted.", currentFile);
} catch (final IOException e) {
LOGGER.warn(
"Failed to close file reader or delete tsFile when successfully transferred file.", e);
Expand Down Expand Up @@ -294,12 +292,11 @@ public void onError(final Exception exception) {
if (reader != null) {
reader.close();
}

// Delete current file when using tsFile as batch
if (!(events.get(0) instanceof PipeTsFileInsertionEvent)) {
if (events.stream().anyMatch(event -> !(event instanceof PipeTsFileInsertionEvent))) {
FileUtils.delete(currentFile);
}
} catch (final NoSuchFileException e) {
LOGGER.info("The file {} is not found, may already be deleted.", currentFile);
} catch (final IOException e) {
LOGGER.warn("Failed to close file reader or delete tsFile when failed to transfer file.", e);
} finally {
Expand Down

0 comments on commit 6f8b5a6

Please sign in to comment.