mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-16 04:39:54 +01:00
Unit tests for the reader portion of RemovableDrivePlugin.
This commit is contained in:
@@ -28,7 +28,8 @@ abstract class FilePlugin implements BatchTransportPlugin {
|
||||
protected Map<ContactId, Map<String, String>> remoteProperties = null;
|
||||
protected Map<String, String> config = null;
|
||||
protected BatchTransportCallback callback = null;
|
||||
private boolean started = false;
|
||||
|
||||
private volatile boolean started = false;
|
||||
|
||||
protected abstract File chooseOutputDirectory();
|
||||
protected abstract void writerFinished(File f);
|
||||
@@ -117,6 +118,7 @@ abstract class FilePlugin implements BatchTransportPlugin {
|
||||
}
|
||||
|
||||
protected void createReaderFromFile(File f) {
|
||||
if(!started) throw new IllegalStateException();
|
||||
if(!isPossibleConnectionFilename(f.getName())) return;
|
||||
if(f.length() < TransportConstants.MIN_CONNECTION_LENGTH) return;
|
||||
try {
|
||||
@@ -128,6 +130,11 @@ abstract class FilePlugin implements BatchTransportPlugin {
|
||||
if(read == -1) break;
|
||||
offset += read;
|
||||
}
|
||||
if(offset < iv.length) {
|
||||
// The file was truncated
|
||||
in.close();
|
||||
return;
|
||||
}
|
||||
ContactId c = recogniser.acceptConnection(iv);
|
||||
if(c == null) {
|
||||
// Nobody there
|
||||
|
||||
@@ -11,6 +11,6 @@ interface RemovableDriveMonitor {
|
||||
|
||||
interface Callback {
|
||||
|
||||
void driveInserted(File f);
|
||||
void driveInserted(File root);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user