Markus Koschany pushed to branch master at Debian Java Maintainers / libsejda-io-java
Commits: f11ddb02 by Markus Koschany at 2020-11-10T17:04:11+01:00 New upstream version 2.1.3 - - - - - d5572c48 by Markus Koschany at 2020-11-10T17:04:15+01:00 Update upstream source from tag 'upstream/2.1.3' Update to upstream version '2.1.3' with Debian dir be8dcced3cf3807de639e4c0077f34715121d857 - - - - - d8090d31 by Markus Koschany at 2020-11-10T17:04:42+01:00 Update changelog - - - - - 4 changed files: - debian/changelog - pom.xml - src/main/java/org/sejda/io/SeekableSources.java - src/test/java/org/sejda/io/SeekableSourcesTest.java Changes: ===================================== debian/changelog ===================================== @@ -1,3 +1,9 @@ +libsejda-io-java (2.1.3-1) unstable; urgency=medium + + * New upstream version 2.1.3. + + -- Markus Koschany <[email protected]> Tue, 10 Nov 2020 17:04:33 +0100 + libsejda-io-java (2.1.2-1) unstable; urgency=medium * New upstream version 2.1.2. ===================================== pom.xml ===================================== @@ -5,7 +5,7 @@ <artifactId>sejda-io</artifactId> <packaging>jar</packaging> <name>sejda-io</name> - <version>2.1.2</version> + <version>2.1.3</version> <description>An Input/Output layer built on top of Java standard io and nio packages</description> <url>http://www.sejda.org</url> @@ -37,7 +37,7 @@ <connection>scm:git:[email protected]:torakiki/sejda-io.git</connection> <developerConnection>scm:git:[email protected]:torakiki/sejda-io.git</developerConnection> <url>scm:git:[email protected]:torakiki/sejda-io.git</url> - <tag>v2.1.2</tag> + <tag>v2.1.3</tag> </scm> <developers> ===================================== src/main/java/org/sejda/io/SeekableSources.java ===================================== @@ -120,13 +120,18 @@ public final class SeekableSources { */ public static SeekableSource onTempFileSeekableSourceFrom(InputStream stream, String filenameHint) throws IOException { requireNonNull(stream); - Path temp = Files.createTempFile(filenameHint, null); - Files.copy(stream, temp, StandardCopyOption.REPLACE_EXISTING); - return new BufferedSeekableSource(new FileChannelSeekableSource(temp.toFile()) { + File tempDir = Files.createTempDirectory("SejdaIODir").toFile(); + File temp = new File(tempDir, filenameHint); + if(temp.exists()) { + throw new RuntimeException("Temp file collision: "+ temp.getAbsolutePath()); + } + + Files.copy(stream, temp.toPath(), StandardCopyOption.REPLACE_EXISTING); + return new BufferedSeekableSource(new FileChannelSeekableSource(temp) { @Override public void close() throws IOException { super.close(); - Files.deleteIfExists(temp); + Files.deleteIfExists(temp.toPath()); } }); } ===================================== src/test/java/org/sejda/io/SeekableSourcesTest.java ===================================== @@ -15,6 +15,8 @@ */ package org.sejda.io; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.StringEndsWith.endsWith; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -155,4 +157,11 @@ public class SeekableSourcesTest { assertNotNull(SeekableSources.onTempFileSeekableSourceFrom(new ByteArrayInputStream(new byte[] { -1 }))); } + @Test + public void onTempFileSeekableSourceFromWithFilenameHint() throws IOException { + String filenameHint = "input.pdf"; + SeekableSource result = SeekableSources.onTempFileSeekableSourceFrom(new ByteArrayInputStream(new byte[] { -1 }), filenameHint); + assertThat(result.id(), endsWith(filenameHint)); + } + } View it on GitLab: https://salsa.debian.org/java-team/libsejda-io-java/-/compare/94d05a3bb73ba88268be44b043f2727aca22e512...d8090d31287444bed6565a456533f9a25cb6d338 -- View it on GitLab: https://salsa.debian.org/java-team/libsejda-io-java/-/compare/94d05a3bb73ba88268be44b043f2727aca22e512...d8090d31287444bed6565a456533f9a25cb6d338 You're receiving this email because of your account on salsa.debian.org.
_______________________________________________ pkg-java-commits mailing list [email protected] https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/pkg-java-commits

