Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,7 @@ private File handleFileMessage(File sourceFile, File tempFile, File resultFile,

if (!FileExistsMode.APPEND.equals(this.fileExistsMode) && this.deleteSourceFiles) {
rename(sourceFile, resultFile);
setPermissions(resultFile);
return resultFile;
}
else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledOnOs;
import org.junit.jupiter.api.condition.OS;
import org.junit.jupiter.api.io.TempDir;

import org.springframework.beans.DirectFieldAccessor;
Expand Down Expand Up @@ -301,6 +303,23 @@ public void deleteFilesTrueWithFilePayload() throws Exception {
assertThat(sourceFile.exists()).isFalse();
}

@Test
@DisabledOnOs(OS.WINDOWS)
public void deleteFilesWithChmod() throws Exception {
QueueChannel output = new QueueChannel();
handler.setDeleteSourceFiles(true);
handler.setOutputChannel(output);
handler.setChmod(0400);
Message<?> message = MessageBuilder.withPayload(sourceFile).build();
handler.handleMessage(message);
Message<?> result = output.receive(0);
assertFileContentIsMatching(result);
File resultFile = messageToFile(result);
Set<PosixFilePermission> posixFilePermissions = Files.getPosixFilePermissions(resultFile.toPath());
assertThat(posixFilePermissions).containsOnly(PosixFilePermission.OWNER_READ);
assertThat(sourceFile.exists()).isFalse();
}

@Test
public void deleteSourceFileWithStringPayloadAndFileInstanceHeader() throws Exception {
QueueChannel output = new QueueChannel();
Expand Down