Skip to content

Commit

Permalink
Change bytesCopied initialization to -1
Browse files Browse the repository at this point in the history
  • Loading branch information
sydney-munro committed Jun 2, 2023
1 parent 7f50edc commit dde6d6c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ final class DirectDownloadCallable implements Callable<DownloadResult> {
@Override
public DownloadResult call() {
Path path = TransferManagerUtils.createDestPath(parallelDownloadConfig, originalBlob);
long bytesCopied = 0L;
long bytesCopied = -1L;
try (ReadChannel rc =
storage.reader(
BlobId.of(parallelDownloadConfig.getBucketName(), originalBlob.getName()), opts)) {
Expand All @@ -61,7 +61,7 @@ public DownloadResult call() {
StandardOpenOption.TRUNCATE_EXISTING);
bytesCopied = ByteStreams.copy(rc, wc);
} catch (Exception e) {
if (bytesCopied == 0) {
if (bytesCopied == -1) {
return DownloadResult.newBuilder(originalBlob, TransferStatus.FAILED_TO_START)
.setException(e)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public UploadResult call() throws Exception {
}

private UploadResult uploadWithoutChunking() {
long bytesCopied = 0L;
long bytesCopied = -1L;
try {
Optional<BlobInfo> newBlob;
try (FileChannel r = FileChannel.open(sourceFile, StandardOpenOption.READ);
Expand All @@ -74,7 +74,7 @@ private UploadResult uploadWithoutChunking() {
.setUploadedBlob(newBlob.get())
.build();
} catch (Exception e) {
if (bytesCopied == 0) {
if (bytesCopied == -1) {
return UploadResult.newBuilder(originalBlob, TransferStatus.FAILED_TO_START)
.setException(e)
.build();
Expand Down

0 comments on commit dde6d6c

Please sign in to comment.