Markus Koschany pushed to branch upstream 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
- - - - -
3 changed files:
- pom.xml
- src/main/java/org/sejda/io/SeekableSources.java
- src/test/java/org/sejda/io/SeekableSourcesTest.java
Changes:
=====================================
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/-/commit/f11ddb022e727de967cdf40e4f8f23e636eda9c6
--
View it on GitLab:
https://salsa.debian.org/java-team/libsejda-io-java/-/commit/f11ddb022e727de967cdf40e4f8f23e636eda9c6
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