mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-09-19 22:44:32 +00:00
Removed SharedFileChannel transferTo and corresponding methods
* Removed from SharedFileChannel and Test * Refactored Copier#copy(File,File) to sequence of truncated, followed by looping read and write till EOF * Changed tests accordingly * Implemented CryptoWritableFile#truncate to make things work
This commit is contained in:
-9
@@ -14,7 +14,6 @@ import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.cryptomator.filesystem.ReadableFile;
|
||||
import org.cryptomator.filesystem.WritableFile;
|
||||
import org.cryptomator.io.ByteBuffers;
|
||||
|
||||
class InMemoryReadableFile implements ReadableFile {
|
||||
@@ -34,14 +33,6 @@ class InMemoryReadableFile implements ReadableFile {
|
||||
return open;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyTo(WritableFile other) throws UncheckedIOException {
|
||||
ByteBuffer source = contentGetter.get().asReadOnlyBuffer();
|
||||
source.position(0);
|
||||
other.truncate();
|
||||
this.position += other.write(source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read(ByteBuffer destination) throws UncheckedIOException {
|
||||
ByteBuffer source = contentGetter.get().asReadOnlyBuffer();
|
||||
|
||||
+1
-5
@@ -110,11 +110,7 @@ public class InMemoryFileSystemTest {
|
||||
|
||||
// copy foo to bar
|
||||
File barFile = fs.file("bar.txt");
|
||||
try (WritableFile writable = barFile.openWritable()) {
|
||||
try (ReadableFile readable = fooFile.openReadable()) {
|
||||
readable.copyTo(writable);
|
||||
}
|
||||
}
|
||||
fooFile.copyTo(barFile);
|
||||
Assert.assertTrue(fooFile.exists());
|
||||
Assert.assertTrue(barFile.exists());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user