Bugfix with 'posix:permissions' for Windows systems
This commit is contained in:
parent
368313fe75
commit
f7e8bee7cd
@ -18,6 +18,8 @@ import java.util.Set;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
import org.apache.commons.lang3.SystemUtils;
|
||||
|
||||
@Slf4j
|
||||
public class FileSystemBackedArchiver implements AutoCloseable {
|
||||
|
||||
@ -25,20 +27,18 @@ public class FileSystemBackedArchiver implements AutoCloseable {
|
||||
private final File tempFile;
|
||||
private final ZipOutputStream zipOutputStream;
|
||||
|
||||
private static final boolean isPosix = FileSystems.getDefault().supportedFileAttributeViews().contains("posix");
|
||||
|
||||
@SneakyThrows
|
||||
public FileSystemBackedArchiver() {
|
||||
// TODO this is just a workaround for testing
|
||||
if (isPosix) {
|
||||
if(SystemUtils.IS_OS_UNIX) {
|
||||
FileAttribute<Set<PosixFilePermission>> attr = PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString("rwx------"));
|
||||
tempFile = Files.createTempFile("archive", ".zip", attr).toFile();
|
||||
} else {
|
||||
tempFile = Files.createTempFile("archive", ".zip").toFile();
|
||||
tempFile.setReadable(true);
|
||||
tempFile.setWritable(true);
|
||||
tempFile.setExecutable(true);
|
||||
tempFile.setReadable(true, true);
|
||||
tempFile.setWritable(true, true);
|
||||
tempFile.setExecutable(true, true);
|
||||
}
|
||||
|
||||
zipOutputStream = new ZipOutputStream(new FileOutputStream(tempFile));
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user