Skip to content

Commit

Permalink
reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Sep 26, 2024
1 parent bc2df4d commit 3bc8185
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ public class BundleTransportActivity extends AppCompatActivity {
private TitledFragment serverUploadFragment;
private TitledFragment transportWifiFragment;
private TitledFragment storageFragment;

record ConnectivityEvent(boolean internetAvailable) {}

private final SubmissionPublisher<ConnectivityEvent> connectivityEventPublisher = new SubmissionPublisher<>();
private ViewPager2 viewPager2;
private FragmentStateAdapter viewPager2Adapter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ private void connectToServer() {
TransportToBundleServerManager transportToBundleServerManager =
new TransportToBundleServerManager(requireActivity().getExternalFilesDir(null).toPath(),
serverDomain, serverPort, transportID,
this::connectToServerComplete, this::connectToServerError, getContext());
this::connectToServerComplete, this::connectToServerError,
getContext());
executor.execute(transportToBundleServerManager);
} else {
Toast.makeText(getContext(), "Enter the domain and port", Toast.LENGTH_SHORT).show();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,16 @@ public void run() {

var inventoryResponse = bsStub.withDeadlineAfter(Constants.GRPC_SHORT_TIMEOUT_MS, TimeUnit.MILLISECONDS)
.bundleInventory(BundleInventoryRequest.newBuilder().setSender(transportSenderId)
.addAllBundlesFromClientsOnTransport(bundlesFromClients)
.addAllBundlesFromServerOnTransport(bundlesFromServer).build());
.addAllBundlesFromClientsOnTransport(bundlesFromClients)
.addAllBundlesFromServerOnTransport(bundlesFromServer).build());

try {
if (!Files.exists(fromServerPath) || !Files.isDirectory(fromClientPath)) {
Files.createDirectories(fromServerPath);
Files.createDirectories(fromClientPath);
}
} catch (Exception e) {
logger.log(SEVERE, "Failed to get inventory", e);
logger.log(SEVERE, "Failed to get inventory", e);
}

for (var toDelete : inventoryResponse.getBundlesToDeleteList()) {
Expand All @@ -100,8 +100,8 @@ public void run() {
Files.delete(delPath);
} catch (IOException e) {
logger.log(SEVERE, "Failed to delete file: " + delPath, e);
}
}
}

for (var toSend : inventoryResponse.getBundlesToUploadList()) {
var path = fromClientPath.resolve(toSend.getEncryptedId());
Expand All @@ -120,9 +120,9 @@ public void run() {
var uploadRequest = BundleUploadRequest.newBuilder()
.setChunk(BundleChunk.newBuilder().setChunk(ByteString.copyFrom(data, 0, rc)).build())
.build();
uploadRequestStreamObserver.onNext(uploadRequest);
}
uploadRequestStreamObserver.onCompleted();
uploadRequestStreamObserver.onNext(uploadRequest);
}
uploadRequestStreamObserver.onCompleted();
if (responseObserver != null) {
responseObserver.onCompleted();
Files.delete(path);
Expand Down Expand Up @@ -171,8 +171,9 @@ public void onCompleted() {

var recencyBlobReq = GetRecencyBlobRequest.newBuilder().setSender(transportSenderId).build();

var recencyBlob = blockingExchangeStub.withDeadlineAfter(Constants.GRPC_SHORT_TIMEOUT_MS, TimeUnit.MILLISECONDS)
.getRecencyBlob(recencyBlobReq);
var recencyBlob =
blockingExchangeStub.withDeadlineAfter(Constants.GRPC_SHORT_TIMEOUT_MS, TimeUnit.MILLISECONDS)
.getRecencyBlob(recencyBlobReq);

Path blobPath = fromServerPath.resolve(RECENCY_BLOB_BIN);
try (var os = Files.newOutputStream(blobPath, StandardOpenOption.CREATE,
Expand All @@ -186,16 +187,16 @@ public void onCompleted() {
try {
channel.shutdown().awaitTermination(5, TimeUnit.SECONDS);
} catch (InterruptedException e) {
logger.log(SEVERE, "could not shutdown channel, error: " + e.getMessage() + ", cause: " + e.getCause());
logger.log(SEVERE,
"could not shutdown channel, error: " + e.getMessage() + ", cause: " + e.getCause());
}
logger.log(INFO, "Connect server completed");
connectComplete.apply(null);
}
} catch (IllegalArgumentException | StatusRuntimeException e) {
logger.log(SEVERE, "Failed to connect to server", e);
new Handler(Looper.getMainLooper()).post(() -> {
Toast.makeText(applicationContext,
"Invalid hostname: " + transportTarget, Toast.LENGTH_SHORT).show();
Toast.makeText(applicationContext, "Invalid hostname: " + transportTarget, Toast.LENGTH_SHORT).show();
});
connectError.apply(e);
}
Expand Down

0 comments on commit 3bc8185

Please sign in to comment.