From 3bc818556a12aab396218e95f5ebdcda25f54a40 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 26 Sep 2024 20:35:31 +0000 Subject: [PATCH] reformat --- .../BundleTransportActivity.java | 2 ++ .../bundletransport/ServerUploadFragment.java | 3 ++- .../TransportToBundleServerManager.java | 25 ++++++++++--------- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/BundleTransport/app/src/main/java/net/discdd/bundletransport/BundleTransportActivity.java b/BundleTransport/app/src/main/java/net/discdd/bundletransport/BundleTransportActivity.java index b198443421..d3542fb897 100644 --- a/BundleTransport/app/src/main/java/net/discdd/bundletransport/BundleTransportActivity.java +++ b/BundleTransport/app/src/main/java/net/discdd/bundletransport/BundleTransportActivity.java @@ -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 connectivityEventPublisher = new SubmissionPublisher<>(); private ViewPager2 viewPager2; private FragmentStateAdapter viewPager2Adapter; diff --git a/BundleTransport/app/src/main/java/net/discdd/bundletransport/ServerUploadFragment.java b/BundleTransport/app/src/main/java/net/discdd/bundletransport/ServerUploadFragment.java index a721ece673..6cfe6b51fc 100644 --- a/BundleTransport/app/src/main/java/net/discdd/bundletransport/ServerUploadFragment.java +++ b/BundleTransport/app/src/main/java/net/discdd/bundletransport/ServerUploadFragment.java @@ -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(); diff --git a/BundleTransport/app/src/main/java/net/discdd/bundletransport/TransportToBundleServerManager.java b/BundleTransport/app/src/main/java/net/discdd/bundletransport/TransportToBundleServerManager.java index 85d53b59d3..5268009feb 100644 --- a/BundleTransport/app/src/main/java/net/discdd/bundletransport/TransportToBundleServerManager.java +++ b/BundleTransport/app/src/main/java/net/discdd/bundletransport/TransportToBundleServerManager.java @@ -82,8 +82,8 @@ 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)) { @@ -91,7 +91,7 @@ public void run() { 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()) { @@ -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()); @@ -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); @@ -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, @@ -186,7 +187,8 @@ 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); @@ -194,8 +196,7 @@ public void onCompleted() { } 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); }