|
18 | 18 | */ |
19 | 19 | package com.cloud.hypervisor.kvm.storage; |
20 | 20 |
|
| 21 | +import static com.cloud.utils.S3Utils.mputFile; |
21 | 22 | import static com.cloud.utils.S3Utils.putFile; |
22 | 23 |
|
23 | 24 | import java.io.BufferedOutputStream; |
@@ -547,11 +548,16 @@ public Answer createTemplateFromSnapshot(CopyCommand cmd) { |
547 | 548 | return null; //To change body of implemented methods use File | Settings | File Templates. |
548 | 549 | } |
549 | 550 |
|
550 | | - protected String copyToS3(File srcFile, S3TO destStore, String destPath) { |
| 551 | + protected String copyToS3(File srcFile, S3TO destStore, String destPath) throws InterruptedException { |
551 | 552 | final String bucket = destStore.getBucketName(); |
552 | 553 |
|
| 554 | + long srcSize = srcFile.length(); |
553 | 555 | String key = destPath + S3Utils.SEPARATOR + srcFile.getName(); |
554 | | - putFile(destStore, srcFile, bucket, key); |
| 556 | + if (!destStore.getSingleUpload(srcSize)) { |
| 557 | + mputFile(destStore, srcFile, bucket, key); |
| 558 | + } else { |
| 559 | + putFile(destStore, srcFile, bucket, key); |
| 560 | + } |
555 | 561 | return key; |
556 | 562 | } |
557 | 563 |
|
@@ -584,6 +590,9 @@ protected Answer copyToObjectStore(CopyCommand cmd) { |
584 | 590 | SnapshotObjectTO newSnapshot = new SnapshotObjectTO(); |
585 | 591 | newSnapshot.setPath(destPath); |
586 | 592 | return new CopyCmdAnswer(newSnapshot); |
| 593 | + } catch (Exception e) { |
| 594 | + s_logger.error("failed to upload" + srcPath, e); |
| 595 | + return new CopyCmdAnswer("failed to upload" + srcPath + e.toString()); |
587 | 596 | } finally { |
588 | 597 | try { |
589 | 598 | if (srcFile != null) { |
|
0 commit comments