mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-24 23:18:17 +01:00
fixes for Windows compatability, test added
This commit is contained in:
parent
9334cffc89
commit
3ea1543882
2 changed files with 15 additions and 1 deletions
|
@ -49,7 +49,7 @@ public class FileTransferSender extends FileTransferSession {
|
|||
try {
|
||||
Map<String, String> env = new HashMap<>();
|
||||
env.put("create", "true");
|
||||
FileSystem zipfs = FileSystems.newFileSystem(URI.create("jar:file:" + zipFilePath), env);
|
||||
FileSystem zipfs = FileSystems.newFileSystem(URI.create("jar:file:///" + (zipFilePath.replace('\\', '/'))), env);
|
||||
Files.createDirectory(zipfs.getPath(zipId)); // store logfiles in a usefully-named subdir
|
||||
Stream<Path> paths = Files.walk(Paths.get(Config.appDataDir().toString()), 1);
|
||||
paths.filter(Files::isRegularFile).forEach(externalTxtFile -> {
|
||||
|
@ -79,6 +79,7 @@ public class FileTransferSender extends FileTransferSession {
|
|||
networkNode.addMessageListener(this);
|
||||
RandomAccessFile file = new RandomAccessFile(zipFilePath, "r");
|
||||
expectedFileLength = file.length();
|
||||
file.close();
|
||||
// an empty block is sent as request to initiate file transfer, peer must ACK for transfer to continue
|
||||
dataAwaitingAck = Optional.of(new FileTransferPart(networkNode.getNodeAddress(), fullTradeId, traderId, UUID.randomUUID().toString(), expectedFileLength, ByteString.EMPTY));
|
||||
uploadData();
|
||||
|
@ -93,6 +94,7 @@ public class FileTransferSender extends FileTransferSession {
|
|||
file.seek(fileOffsetBytes);
|
||||
byte[] buff = new byte[FILE_BLOCK_SIZE];
|
||||
int nBytesRead = file.read(buff, 0, FILE_BLOCK_SIZE);
|
||||
file.close();
|
||||
if (nBytesRead < 0) {
|
||||
log.info("Success! We have reached the EOF, {} bytes sent. Removing zip file {}", fileOffsetBytes, zipFilePath);
|
||||
Files.delete(Paths.get(zipFilePath));
|
||||
|
|
|
@ -6,6 +6,7 @@ import bisq.network.p2p.network.NetworkNode;
|
|||
|
||||
import bisq.common.config.Config;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -41,6 +42,17 @@ public class FileTransferSessionTest implements FileTransferSession.FtpCallback
|
|||
Assert.assertEquals(1, progressInvocations);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateZip() {
|
||||
FileTransferSender sender = new FileTransferSender(networkNode, counterpartyNodeAddress, testTradeId, testTraderId, testClientId, this);
|
||||
Assert.assertEquals(0.0, notedProgressPct, 0.0);
|
||||
Assert.assertEquals(1, progressInvocations);
|
||||
sender.createZipFileToSend();
|
||||
File file = new File(sender.zipFilePath);
|
||||
Assert.assertTrue(file.exists());
|
||||
Assert.assertTrue(file.length() > 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSendInitialize() {
|
||||
// checks that the initial send request packet contains correct information
|
||||
|
|
Loading…
Add table
Reference in a new issue