mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-04-20 01:26:52 -04:00
same InterruptedIOException in all cases
This commit is contained in:
@@ -1,14 +0,0 @@
|
||||
package org.cryptomator.common;
|
||||
|
||||
public class UncheckedInterruptedException extends RuntimeException {
|
||||
|
||||
public UncheckedInterruptedException(InterruptedException e) {
|
||||
super(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InterruptedException getCause() {
|
||||
return (InterruptedException) super.getCause();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.cryptomator.filesystem.crypto;
|
||||
|
||||
import java.io.InterruptedIOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
@@ -22,7 +23,7 @@ class CiphertextReader implements Callable<Void> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void call() {
|
||||
public Void call() throws InterruptedIOException {
|
||||
file.position(startpos);
|
||||
int bytesRead = -1;
|
||||
try {
|
||||
@@ -37,7 +38,7 @@ class CiphertextReader implements Callable<Void> {
|
||||
} while (bytesRead > 0);
|
||||
decryptor.append(FileContentCryptor.EOF);
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
throw new InterruptedIOException("Task interrupted while waiting for ciphertext");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package org.cryptomator.filesystem.crypto;
|
||||
|
||||
import java.io.InterruptedIOException;
|
||||
import java.io.UncheckedIOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
@@ -20,14 +19,14 @@ class CiphertextWriter implements Callable<Void> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void call() {
|
||||
public Void call() throws InterruptedIOException {
|
||||
try {
|
||||
ByteBuffer ciphertext;
|
||||
while ((ciphertext = encryptor.ciphertext()) != FileContentCryptor.EOF) {
|
||||
file.write(ciphertext);
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
throw new UncheckedIOException(new InterruptedIOException("Task interrupted while waiting for ciphertext"));
|
||||
throw new InterruptedIOException("Task interrupted while waiting for ciphertext");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -8,13 +8,13 @@
|
||||
*******************************************************************************/
|
||||
package org.cryptomator.filesystem.crypto;
|
||||
|
||||
import java.io.InterruptedIOException;
|
||||
import java.io.UncheckedIOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import org.cryptomator.common.UncheckedInterruptedException;
|
||||
import org.cryptomator.crypto.engine.FileContentCryptor;
|
||||
import org.cryptomator.crypto.engine.FileContentDecryptor;
|
||||
import org.cryptomator.filesystem.ReadableFile;
|
||||
@@ -56,8 +56,7 @@ class CryptoReadableFile implements ReadableFile {
|
||||
}
|
||||
return bytesRead;
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
throw new UncheckedInterruptedException(e);
|
||||
throw new UncheckedIOException(new InterruptedIOException("Task interrupted while waiting for cleartext"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
package org.cryptomator.filesystem.crypto;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InterruptedIOException;
|
||||
import java.io.UncheckedIOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.time.Instant;
|
||||
@@ -18,18 +19,13 @@ import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import org.cryptomator.common.UncheckedInterruptedException;
|
||||
import org.cryptomator.crypto.engine.FileContentCryptor;
|
||||
import org.cryptomator.crypto.engine.FileContentEncryptor;
|
||||
import org.cryptomator.filesystem.WritableFile;
|
||||
import org.cryptomator.io.ByteBuffers;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
class CryptoWritableFile implements WritableFile {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(CryptoWritableFile.class);
|
||||
|
||||
final WritableFile file;
|
||||
private final ExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
|
||||
private final FileContentEncryptor encryptor;
|
||||
@@ -59,8 +55,7 @@ class CryptoWritableFile implements WritableFile {
|
||||
encryptor.append(cleartextCopy);
|
||||
return size;
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
throw new UncheckedInterruptedException(e);
|
||||
throw new UncheckedIOException(new InterruptedIOException("Task interrupted while waiting for encryptor capacity"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user