diff --git a/azure/src/main/java/ch/cyberduck/core/azure/AzureUploadFeature.java b/azure/src/main/java/ch/cyberduck/core/azure/AzureUploadFeature.java index b787d8e0f3d..a653ecd8870 100644 --- a/azure/src/main/java/ch/cyberduck/core/azure/AzureUploadFeature.java +++ b/azure/src/main/java/ch/cyberduck/core/azure/AzureUploadFeature.java @@ -29,7 +29,6 @@ public class AzureUploadFeature extends DefaultUploadFeature { private final AzureSession session; public AzureUploadFeature(final AzureSession session) { - super(session); this.session = session; } diff --git a/backblaze/src/main/java/ch/cyberduck/core/b2/B2LargeUploadService.java b/backblaze/src/main/java/ch/cyberduck/core/b2/B2LargeUploadService.java index c69873f8da9..3bfcd6dc1d8 100644 --- a/backblaze/src/main/java/ch/cyberduck/core/b2/B2LargeUploadService.java +++ b/backblaze/src/main/java/ch/cyberduck/core/b2/B2LargeUploadService.java @@ -43,7 +43,6 @@ import org.apache.logging.log4j.Logger; import java.io.IOException; -import java.security.MessageDigest; import java.text.MessageFormat; import java.util.ArrayList; import java.util.Comparator; @@ -61,7 +60,7 @@ import static ch.cyberduck.core.b2.B2MetadataFeature.X_BZ_INFO_SRC_CREATION_DATE_MILLIS; import static ch.cyberduck.core.b2.B2MetadataFeature.X_BZ_INFO_SRC_LAST_MODIFIED_MILLIS; -public class B2LargeUploadService extends HttpUploadFeature { +public class B2LargeUploadService extends HttpUploadFeature { private static final Logger log = LogManager.getLogger(B2LargeUploadService.class); /** @@ -229,7 +228,7 @@ public B2UploadPartResponse call() throws BackgroundException { status.setChecksum(write.checksum(file, status).compute(local.getInputStream(), status)); status.setSegment(true); status.setPart(partNumber); - return (B2UploadPartResponse) B2LargeUploadService.this.upload(write, file, local, throttle, counter, status, overall, status, callback); + return (B2UploadPartResponse) B2LargeUploadService.this.transfer(write, file, local, throttle, counter, status, overall, status, callback); } }, overall, counter)); } diff --git a/backblaze/src/main/java/ch/cyberduck/core/b2/B2SingleUploadService.java b/backblaze/src/main/java/ch/cyberduck/core/b2/B2SingleUploadService.java index 7129e48ccfb..97872fbdc7c 100644 --- a/backblaze/src/main/java/ch/cyberduck/core/b2/B2SingleUploadService.java +++ b/backblaze/src/main/java/ch/cyberduck/core/b2/B2SingleUploadService.java @@ -15,57 +15,10 @@ * GNU General Public License for more details. */ -import ch.cyberduck.core.Path; -import ch.cyberduck.core.exception.BackgroundException; import ch.cyberduck.core.http.HttpUploadFeature; -import ch.cyberduck.core.io.Checksum; -import ch.cyberduck.core.preferences.HostPreferencesFactory; -import org.apache.commons.lang3.StringUtils; - -import java.io.IOException; -import java.io.InputStream; -import java.security.DigestInputStream; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; - -import synapticloop.b2.response.B2FileResponse; import synapticloop.b2.response.BaseB2Response; -public class B2SingleUploadService extends HttpUploadFeature { - - private final B2Session session; - - public B2SingleUploadService(final B2Session session) { - this.session = session; - } - - @Override - protected InputStream decorate(final InputStream in, final MessageDigest digest) throws IOException { - if(null == digest) { - return super.decorate(in, null); - } - else { - return new DigestInputStream(in, digest); - } - } - - @Override - protected MessageDigest digest() throws IOException { - MessageDigest digest = null; - if(HostPreferencesFactory.get(session.getHost()).getBoolean("b2.upload.checksum.verify")) { - try { - digest = MessageDigest.getInstance("SHA1"); - } - catch(NoSuchAlgorithmException e) { - throw new IOException(e.getMessage(), e); - } - } - return digest; - } +public class B2SingleUploadService extends HttpUploadFeature { - @Override - protected void post(final Path file, final MessageDigest digest, final BaseB2Response response) throws BackgroundException { - this.verify(file, digest, Checksum.parse(StringUtils.removeStart(((B2FileResponse) response).getContentSha1(), "unverified:"))); - } } diff --git a/backblaze/src/main/java/ch/cyberduck/core/b2/B2ThresholdUploadService.java b/backblaze/src/main/java/ch/cyberduck/core/b2/B2ThresholdUploadService.java index b7bfdcaf68f..7a782c89f50 100644 --- a/backblaze/src/main/java/ch/cyberduck/core/b2/B2ThresholdUploadService.java +++ b/backblaze/src/main/java/ch/cyberduck/core/b2/B2ThresholdUploadService.java @@ -64,7 +64,7 @@ public BaseB2Response upload(final Write write, final Path file, return new B2LargeUploadService(session, fileid).upload(write, file, local, throttle, progress, streamListener, status, callback); } else { - return new B2SingleUploadService(session).upload(write, file, local, throttle, progress, streamListener, status, callback); + return new B2SingleUploadService().upload(write, file, local, throttle, progress, streamListener, status, callback); } } diff --git a/backblaze/src/test/java/ch/cyberduck/core/b2/B2LargeUploadServiceTest.java b/backblaze/src/test/java/ch/cyberduck/core/b2/B2LargeUploadServiceTest.java index 1019eb0d757..054ec8cc8ac 100644 --- a/backblaze/src/test/java/ch/cyberduck/core/b2/B2LargeUploadServiceTest.java +++ b/backblaze/src/test/java/ch/cyberduck/core/b2/B2LargeUploadServiceTest.java @@ -118,11 +118,11 @@ public void testAppendNoPartCompleted() throws Exception { final B2VersionIdProvider fileid = new B2VersionIdProvider(session); final B2LargeUploadService service = new B2LargeUploadService(session, fileid, 5 * 1000L * 1000L, 1) { @Override - public BaseB2Response upload(final Write write, final Path file, final Local local, final BandwidthThrottle throttle, final StreamListener listener, final TransferStatus status, final StreamCancelation cancel, final StreamProgress progress, final ConnectionCallback callback) throws BackgroundException { + public BaseB2Response transfer(final Write write, final Path file, final Local local, final BandwidthThrottle throttle, final StreamListener listener, final TransferStatus status, final StreamCancelation cancel, final StreamProgress progress, final ConnectionCallback callback) throws BackgroundException { if(!interrupt.get()) { throw new ConnectionTimeoutException("Test"); } - return super.upload(write, file, local, throttle, listener, status, cancel, progress, callback); + return super.transfer(write, file, local, throttle, listener, status, cancel, progress, callback); } }; try { @@ -171,13 +171,13 @@ public void testAppendSecondPart() throws Exception { final B2VersionIdProvider fileid = new B2VersionIdProvider(session); final B2LargeUploadService feature = new B2LargeUploadService(session, fileid, 5 * 1000L * 1000L, 1) { @Override - public BaseB2Response upload(final Write write, final Path file, final Local local, final BandwidthThrottle throttle, final StreamListener listener, final TransferStatus status, final StreamCancelation cancel, final StreamProgress progress, final ConnectionCallback callback) throws BackgroundException { + public BaseB2Response transfer(final Write write, final Path file, final Local local, final BandwidthThrottle throttle, final StreamListener listener, final TransferStatus status, final StreamCancelation cancel, final StreamProgress progress, final ConnectionCallback callback) throws BackgroundException { if(!interrupt.get()) { if(status.getOffset() >= 5L * 1000L * 1000L) { throw new ConnectionTimeoutException("Test"); } } - return super.upload(write, file, local, throttle, listener, status, cancel, progress, callback); + return super.transfer(write, file, local, throttle, listener, status, cancel, progress, callback); } }; final BytecountStreamListener count = new BytecountStreamListener(); diff --git a/backblaze/src/test/java/ch/cyberduck/core/b2/B2ReadFeatureTest.java b/backblaze/src/test/java/ch/cyberduck/core/b2/B2ReadFeatureTest.java index f95eb2da400..cef2a623fda 100644 --- a/backblaze/src/test/java/ch/cyberduck/core/b2/B2ReadFeatureTest.java +++ b/backblaze/src/test/java/ch/cyberduck/core/b2/B2ReadFeatureTest.java @@ -128,7 +128,7 @@ public void testReadRange() throws Exception { assertNotNull(out); IOUtils.write(content, out); out.close(); - final BaseB2Response reply = new B2SingleUploadService(session).upload( + final BaseB2Response reply = new B2SingleUploadService().upload( new B2WriteFeature(session, fileid), test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledProgressListener(), new DisabledStreamListener(), new TransferStatus().setLength(content.length), new DisabledConnectionCallback()); @@ -160,7 +160,7 @@ public void testReadRangeUnknownLength() throws Exception { assertNotNull(out); IOUtils.write(content, out); out.close(); - new B2SingleUploadService(session).upload( + new B2SingleUploadService().upload( new B2WriteFeature(session, fileid), test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledProgressListener(), new DisabledStreamListener(), new TransferStatus().setLength(content.length), new DisabledConnectionCallback()); diff --git a/backblaze/src/test/java/ch/cyberduck/core/b2/B2SingleUploadServiceTest.java b/backblaze/src/test/java/ch/cyberduck/core/b2/B2SingleUploadServiceTest.java index f25c4864690..4b8808fb89c 100644 --- a/backblaze/src/test/java/ch/cyberduck/core/b2/B2SingleUploadServiceTest.java +++ b/backblaze/src/test/java/ch/cyberduck/core/b2/B2SingleUploadServiceTest.java @@ -61,7 +61,7 @@ public void testUpload() throws Exception { final Checksum checksum = new SHA1ChecksumCompute().compute(new ByteArrayInputStream(content), new TransferStatus()); status.setChecksum(checksum); final B2VersionIdProvider fileid = new B2VersionIdProvider(session); - final B2SingleUploadService upload = new B2SingleUploadService(session); + final B2SingleUploadService upload = new B2SingleUploadService(); upload.upload(new B2WriteFeature(session, fileid), test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledProgressListener(), new DisabledStreamListener(), status, new DisabledConnectionCallback()); assertEquals(checksum, new B2AttributesFinderFeature(session, fileid).find(test).getChecksum()); diff --git a/backblaze/src/test/java/ch/cyberduck/core/worker/B2ConcurrentTransferWorkerTest.java b/backblaze/src/test/java/ch/cyberduck/core/worker/B2ConcurrentTransferWorkerTest.java index 43086803608..e124cc23326 100644 --- a/backblaze/src/test/java/ch/cyberduck/core/worker/B2ConcurrentTransferWorkerTest.java +++ b/backblaze/src/test/java/ch/cyberduck/core/worker/B2ConcurrentTransferWorkerTest.java @@ -56,7 +56,6 @@ import java.io.InputStream; import java.io.OutputStream; import java.net.SocketTimeoutException; -import java.security.MessageDigest; import java.util.Collections; import java.util.EnumSet; import java.util.Random; @@ -113,7 +112,7 @@ public Session create() { final B2LargeUploadService upload = new B2LargeUploadService(this, new B2VersionIdProvider(this) ) { @Override - protected InputStream decorate(final InputStream in, final MessageDigest digest) { + protected InputStream decorate(final InputStream in, final TransferStatus status) { if(failed.get()) { // Second attempt successful return in; diff --git a/backblaze/src/test/java/ch/cyberduck/core/worker/B2SingleTransferWorkerTest.java b/backblaze/src/test/java/ch/cyberduck/core/worker/B2SingleTransferWorkerTest.java index 78865392ad9..4bba34ac891 100644 --- a/backblaze/src/test/java/ch/cyberduck/core/worker/B2SingleTransferWorkerTest.java +++ b/backblaze/src/test/java/ch/cyberduck/core/worker/B2SingleTransferWorkerTest.java @@ -48,6 +48,7 @@ import ch.cyberduck.core.transfer.TransferItem; import ch.cyberduck.core.transfer.TransferOptions; import ch.cyberduck.core.transfer.TransferSpeedometer; +import ch.cyberduck.core.transfer.TransferStatus; import ch.cyberduck.core.transfer.UploadTransfer; import ch.cyberduck.test.IntegrationTest; import ch.cyberduck.test.VaultTest; @@ -61,7 +62,6 @@ import java.io.InputStream; import java.io.OutputStream; import java.net.SocketTimeoutException; -import java.security.MessageDigest; import java.util.Collections; import java.util.EnumSet; import java.util.Random; @@ -110,7 +110,7 @@ public String getProperty(final String key) { final B2LargeUploadService upload = new B2LargeUploadService(this, new B2VersionIdProvider(this) ) { @Override - protected InputStream decorate(final InputStream in, final MessageDigest digest) { + protected InputStream decorate(final InputStream in, final TransferStatus status) { if(failed.get()) { // Second attempt successful return in; diff --git a/box/src/main/java/ch/cyberduck/core/box/BoxLargeUploadService.java b/box/src/main/java/ch/cyberduck/core/box/BoxLargeUploadService.java index 9dd7f0d7cfa..ea8f18ae8dd 100644 --- a/box/src/main/java/ch/cyberduck/core/box/BoxLargeUploadService.java +++ b/box/src/main/java/ch/cyberduck/core/box/BoxLargeUploadService.java @@ -44,7 +44,6 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import java.security.MessageDigest; import java.text.MessageFormat; import java.util.ArrayList; import java.util.HashMap; @@ -54,7 +53,7 @@ import java.util.concurrent.Future; import java.util.stream.Collectors; -public class BoxLargeUploadService extends HttpUploadFeature { +public class BoxLargeUploadService extends HttpUploadFeature { private static final Logger log = LogManager.getLogger(BoxLargeUploadService.class); public static final String UPLOAD_SESSION_ID = "uploadSessionId"; @@ -137,7 +136,7 @@ public Part call() throws BackgroundException { parameters.put(UPLOAD_SESSION_ID, uploadSessionId); parameters.put(OVERALL_LENGTH, String.valueOf(overall.getLength())); status.setParameters(parameters); - final File response = BoxLargeUploadService.this.upload( + final File response = BoxLargeUploadService.this.transfer( write, file, local, throttle, listener, status, overall, status, callback); log.info("Received response {} for part {}", response, partNumber); return new Part(response, status); diff --git a/box/src/main/java/ch/cyberduck/core/box/BoxSmallUploadService.java b/box/src/main/java/ch/cyberduck/core/box/BoxSmallUploadService.java index 9fc312d39bc..89e56cd5ddf 100644 --- a/box/src/main/java/ch/cyberduck/core/box/BoxSmallUploadService.java +++ b/box/src/main/java/ch/cyberduck/core/box/BoxSmallUploadService.java @@ -18,7 +18,5 @@ import ch.cyberduck.core.box.io.swagger.client.model.File; import ch.cyberduck.core.http.HttpUploadFeature; -import java.security.MessageDigest; - -public class BoxSmallUploadService extends HttpUploadFeature { +public class BoxSmallUploadService extends HttpUploadFeature { } diff --git a/brick/src/main/java/ch/cyberduck/core/brick/BrickUploadFeature.java b/brick/src/main/java/ch/cyberduck/core/brick/BrickUploadFeature.java index 6b38abf6525..28bebc09377 100644 --- a/brick/src/main/java/ch/cyberduck/core/brick/BrickUploadFeature.java +++ b/brick/src/main/java/ch/cyberduck/core/brick/BrickUploadFeature.java @@ -47,14 +47,13 @@ import org.apache.logging.log4j.Logger; import org.joda.time.DateTime; -import java.security.MessageDigest; import java.util.ArrayList; import java.util.List; import java.util.Optional; import java.util.concurrent.Future; import java.util.stream.Collectors; -public class BrickUploadFeature extends HttpUploadFeature { +public class BrickUploadFeature extends HttpUploadFeature { private static final Logger log = LogManager.getLogger(BrickUploadFeature.class); /** @@ -168,7 +167,7 @@ public TransferStatus call() throws BackgroundException { status.setUrl(url); status.setPart(partNumber); status.setHeader(overall.getHeader()); - BrickUploadFeature.super.upload( + BrickUploadFeature.super.transfer( write, file, local, throttle, listener, status, overall, status, callback); log.info("Received response for part number {}", partNumber); return status; diff --git a/brick/src/main/java/ch/cyberduck/core/brick/BrickWriteFeature.java b/brick/src/main/java/ch/cyberduck/core/brick/BrickWriteFeature.java index 878b983ddd3..36992b064c0 100644 --- a/brick/src/main/java/ch/cyberduck/core/brick/BrickWriteFeature.java +++ b/brick/src/main/java/ch/cyberduck/core/brick/BrickWriteFeature.java @@ -88,24 +88,6 @@ public FileEntity call(final HttpEntity entity) throws BackgroundException { case HttpStatus.SC_OK: log.info("Received response {} for part number {}", response, status.getPart()); // Upload complete - if(response.containsHeader("ETag")) { - if(file.getType().contains(Path.Type.encrypted)) { - log.warn("Skip checksum verification for {} with client side encryption enabled", file); - } - else { - if(HashAlgorithm.md5.equals(status.getChecksum().algorithm)) { - final Checksum etag = Checksum.parse(StringUtils.remove(response.getFirstHeader("ETag").getValue(), '"')); - if(!status.getChecksum().equals(etag)) { - throw new ChecksumException(MessageFormat.format(LocaleFactory.localizedString("Upload {0} failed", "Error"), file.getName()), - MessageFormat.format("Mismatch between {0} hash {1} of uploaded data and ETag {2} returned by the server", - etag.algorithm.toString(), status.getChecksum().hash, etag.hash)); - } - } - } - } - else { - log.debug("No ETag header in response available"); - } return null; default: EntityUtils.updateEntity(response, new BufferedHttpEntity(response.getEntity())); diff --git a/brick/src/test/java/ch/cyberduck/core/brick/BrickReadFeatureTest.java b/brick/src/test/java/ch/cyberduck/core/brick/BrickReadFeatureTest.java index ac0201acfd6..52f26fe9196 100644 --- a/brick/src/test/java/ch/cyberduck/core/brick/BrickReadFeatureTest.java +++ b/brick/src/test/java/ch/cyberduck/core/brick/BrickReadFeatureTest.java @@ -106,7 +106,7 @@ public void testReadRange() throws Exception { upload.setExists(true); new BrickUploadFeature(session).upload( new BrickWriteFeature(session), test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledProgressListener(), new DisabledStreamListener(), upload, - new DisabledConnectionCallback()); + new DisabledConnectionCallback()); final TransferStatus status = new TransferStatus(); status.setLength(content.length); status.setAppend(true); @@ -138,7 +138,7 @@ public void testReadRangeUnknownLength() throws Exception { upload.setExists(true); new BrickUploadFeature(session).upload( new BrickWriteFeature(session), test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledProgressListener(), new DisabledStreamListener(), upload, - new DisabledConnectionCallback()); + new DisabledConnectionCallback()); final TransferStatus status = new TransferStatus(); status.setLength(-1L); status.setAppend(true); diff --git a/core/src/main/java/ch/cyberduck/core/Session.java b/core/src/main/java/ch/cyberduck/core/Session.java index b0068fefa45..6086904454e 100644 --- a/core/src/main/java/ch/cyberduck/core/Session.java +++ b/core/src/main/java/ch/cyberduck/core/Session.java @@ -291,7 +291,7 @@ public T getFeature(final Class type, final T feature) { @SuppressWarnings("unchecked") public T _getFeature(final Class type) { if(type == Upload.class) { - return (T) new DefaultUploadFeature<>(this); + return (T) new DefaultUploadFeature<>(); } if(type == Download.class) { return (T) new DefaultDownloadFeature(this); diff --git a/core/src/main/java/ch/cyberduck/core/http/HttpUploadFeature.java b/core/src/main/java/ch/cyberduck/core/http/HttpUploadFeature.java index a29579acb27..df42fe72717 100644 --- a/core/src/main/java/ch/cyberduck/core/http/HttpUploadFeature.java +++ b/core/src/main/java/ch/cyberduck/core/http/HttpUploadFeature.java @@ -17,112 +17,7 @@ * Bug fixes, suggestions and comments should be sent to feedback@cyberduck.ch */ -import ch.cyberduck.core.ConnectionCallback; -import ch.cyberduck.core.Local; -import ch.cyberduck.core.LocaleFactory; -import ch.cyberduck.core.Path; -import ch.cyberduck.core.ProgressListener; -import ch.cyberduck.core.exception.BackgroundException; -import ch.cyberduck.core.exception.ChecksumException; -import ch.cyberduck.core.features.Upload; -import ch.cyberduck.core.features.Write; -import ch.cyberduck.core.io.BandwidthThrottle; -import ch.cyberduck.core.io.Checksum; -import ch.cyberduck.core.io.StatusOutputStream; -import ch.cyberduck.core.io.StreamCancelation; -import ch.cyberduck.core.io.StreamCopier; -import ch.cyberduck.core.io.StreamListener; -import ch.cyberduck.core.io.StreamProgress; -import ch.cyberduck.core.io.ThrottledOutputStream; -import ch.cyberduck.core.transfer.TransferStatus; +import ch.cyberduck.core.shared.DefaultUploadFeature; -import org.apache.commons.codec.binary.Hex; -import org.apache.commons.lang3.ObjectUtils; -import org.apache.http.client.HttpResponseException; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import java.io.IOException; -import java.io.InputStream; -import java.security.MessageDigest; -import java.text.MessageFormat; - -public class HttpUploadFeature implements Upload { - private static final Logger log = LogManager.getLogger(HttpUploadFeature.class); - - @Override - public Reply upload(final Write write, final Path file, final Local local, final BandwidthThrottle throttle, - final ProgressListener progress, final StreamListener streamListener, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { - final Reply response = this.upload(write, file, local, throttle, streamListener, status, status, status, callback); - log.debug("Received response {}", response); - return response; - } - - public Reply upload(final Write write, final Path file, final Local local, final BandwidthThrottle throttle, - final StreamListener listener, final TransferStatus status, - final StreamCancelation cancel, final StreamProgress progress, final ConnectionCallback callback) throws BackgroundException { - try { - final Digest digest = this.digest(); - final Reply response = this.transfer(write, file, local, throttle, listener, status, cancel, progress, callback, digest); - this.post(file, digest, response); - return response; - } - catch(HttpResponseException e) { - throw new DefaultHttpResponseExceptionMappingService().map("Upload {0} failed", e, file); - } - catch(IOException e) { - throw new HttpExceptionMappingService().map("Upload {0} failed", e, file); - } - } - - protected Reply transfer(final Write write, final Path file, final Local local, final BandwidthThrottle throttle, final StreamListener listener, - final TransferStatus status, final StreamCancelation cancel, final StreamProgress progress, - final ConnectionCallback callback, final Digest digest) throws IOException, BackgroundException { - // Wrap with digest stream if available - final InputStream in = this.decorate(local.getInputStream(), digest); - final StatusOutputStream out = write.write(file, status, callback); - new StreamCopier(cancel, progress) - .withOffset(status.getOffset()) - .withLimit(status.getLength()) - .withListener(listener) - .transfer(in, new ThrottledOutputStream(out, throttle)); - return out.getStatus(); - } - - protected InputStream decorate(final InputStream in, final Digest digest) throws IOException { - return in; - } - - protected Digest digest() throws IOException { - return null; - } - - protected void post(final Path file, final Digest digest, final Reply response) throws BackgroundException { - // No-op with no checksum verification by default - log.debug("Missing checksum verification for {}", file); - } - - protected void verify(final Path file, final MessageDigest digest, final Checksum checksum) throws ChecksumException { - if(file.getType().contains(Path.Type.encrypted)) { - log.warn("Skip checksum verification for {} with client side encryption enabled", file); - return; - } - if(null == digest) { - log.debug("Digest disabled for file {}", file); - return; - } - // Obtain locally-calculated MD5 hash. - final Checksum expected = Checksum.parse(Hex.encodeHexString(digest.digest())); - if(ObjectUtils.notEqual(expected.algorithm, checksum.algorithm)) { - log.warn("ETag {} returned by server is {} but expected {}", checksum.hash, checksum.algorithm, expected.algorithm); - } - else { - // Compare our locally-calculated hash with the ETag returned by S3. - if(!checksum.equals(expected)) { - throw new ChecksumException(MessageFormat.format(LocaleFactory.localizedString("Upload {0} failed", "Error"), file.getName()), - MessageFormat.format("Mismatch between MD5 hash {0} of uploaded data and ETag {1} returned by the server", - expected, checksum.hash)); - } - } - } +public class HttpUploadFeature extends DefaultUploadFeature { } diff --git a/core/src/main/java/ch/cyberduck/core/shared/DefaultUploadFeature.java b/core/src/main/java/ch/cyberduck/core/shared/DefaultUploadFeature.java index 7cc67bec120..24a14aac8b5 100644 --- a/core/src/main/java/ch/cyberduck/core/shared/DefaultUploadFeature.java +++ b/core/src/main/java/ch/cyberduck/core/shared/DefaultUploadFeature.java @@ -22,39 +22,56 @@ import ch.cyberduck.core.Local; import ch.cyberduck.core.Path; import ch.cyberduck.core.ProgressListener; -import ch.cyberduck.core.Session; import ch.cyberduck.core.exception.BackgroundException; import ch.cyberduck.core.features.Upload; import ch.cyberduck.core.features.Write; import ch.cyberduck.core.io.BandwidthThrottle; import ch.cyberduck.core.io.StatusOutputStream; +import ch.cyberduck.core.io.StreamCancelation; import ch.cyberduck.core.io.StreamCopier; import ch.cyberduck.core.io.StreamListener; +import ch.cyberduck.core.io.StreamProgress; import ch.cyberduck.core.io.ThrottledOutputStream; import ch.cyberduck.core.transfer.TransferStatus; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import java.io.InputStream; public class DefaultUploadFeature implements Upload { - - private final Session session; - - public DefaultUploadFeature(final Session session) { - this.session = session; - } + private static final Logger log = LogManager.getLogger(DefaultUploadFeature.class); @Override public Reply upload(final Write write, final Path file, final Local local, final BandwidthThrottle throttle, final ProgressListener progress, final StreamListener streamListener, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { - final InputStream in = local.getInputStream(); + final Reply response = this.transfer(write, file, local, throttle, streamListener, status, status, status, callback); + log.debug("Received response {}", response); + return response; + } + + protected Reply transfer(final Write write, final Path file, final Local local, final BandwidthThrottle throttle, final StreamListener listener, + final TransferStatus status, final StreamCancelation cancel, final StreamProgress progress, + final ConnectionCallback callback) throws BackgroundException { + final InputStream in = this.decorate(local.getInputStream(), status); final StatusOutputStream out = write.write(file, status, callback); - new StreamCopier(status, status) - .withOffset(status.getOffset()) - .withLimit(status.getLength()) - .withListener(streamListener) - .transfer(in, new ThrottledOutputStream(out, throttle)); + new StreamCopier(cancel, progress) + .withOffset(status.getOffset()) + .withLimit(status.getLength()) + .withListener(listener) + .transfer(in, new ThrottledOutputStream(out, throttle)); return out.getStatus(); } + /** + * Wrap input stream if checksum calculation is enabled. + * + * @param in File input stream + * @param status + * @return Wrapped or same stream + */ + protected InputStream decorate(final InputStream in, final TransferStatus status) throws BackgroundException { + return in; + } } diff --git a/core/src/main/java/ch/cyberduck/core/transfer/download/AbstractDownloadFilter.java b/core/src/main/java/ch/cyberduck/core/transfer/download/AbstractDownloadFilter.java index bdcb78d8af4..270931ee9ad 100644 --- a/core/src/main/java/ch/cyberduck/core/transfer/download/AbstractDownloadFilter.java +++ b/core/src/main/java/ch/cyberduck/core/transfer/download/AbstractDownloadFilter.java @@ -354,8 +354,8 @@ public void complete(final Path file, final Local local, if(!checksum.equals(download)) { throw new ChecksumException( MessageFormat.format(LocaleFactory.localizedString("Download {0} failed", "Error"), file.getName()), - MessageFormat.format(LocaleFactory.localizedString("Mismatch between {0} hash {1} of downloaded data and checksum {2} returned by the server", "Error"), - download.algorithm.toString(), download.hash, checksum.hash)); + MessageFormat.format(LocaleFactory.localizedString("Mismatch between {2} checksum {0} of transferred data and {1} returned by the server", "Error"), + download.algorithm.toString(), download.hash, checksum.hash, checksum.algorithm)); } } } diff --git a/core/src/main/java/ch/cyberduck/core/transfer/upload/AbstractUploadFilter.java b/core/src/main/java/ch/cyberduck/core/transfer/upload/AbstractUploadFilter.java index 775a74fddbb..63e3cebb7ee 100644 --- a/core/src/main/java/ch/cyberduck/core/transfer/upload/AbstractUploadFilter.java +++ b/core/src/main/java/ch/cyberduck/core/transfer/upload/AbstractUploadFilter.java @@ -32,6 +32,7 @@ import ch.cyberduck.core.UserDateFormatterFactory; import ch.cyberduck.core.exception.AccessDeniedException; import ch.cyberduck.core.exception.BackgroundException; +import ch.cyberduck.core.exception.ChecksumException; import ch.cyberduck.core.exception.InteroperabilityException; import ch.cyberduck.core.exception.LocalAccessDeniedException; import ch.cyberduck.core.exception.LocalNotfoundException; @@ -48,6 +49,7 @@ import ch.cyberduck.core.features.UnixPermission; import ch.cyberduck.core.features.Versioning; import ch.cyberduck.core.features.Write; +import ch.cyberduck.core.io.Checksum; import ch.cyberduck.core.io.ChecksumCompute; import ch.cyberduck.core.preferences.HostPreferencesFactory; import ch.cyberduck.core.preferences.PreferencesReader; @@ -375,6 +377,22 @@ public void complete(final Path file, final Local local, } } } + if(file.isFile()) { + if(options.checksum) { + final Checksum checksum = status.getChecksum(); + if(Checksum.NONE != checksum) { + final Checksum response = status.getResponse().getChecksum(); + if(Checksum.NONE != response) { + if(!checksum.equals(response)) { + throw new ChecksumException( + MessageFormat.format(LocaleFactory.localizedString("Upload {0} failed", "Error"), file.getName()), + MessageFormat.format(LocaleFactory.localizedString("Mismatch between {2} checksum {0} of transferred data and {1} returned by the server", "Error"), + response.hash, checksum.hash, response.algorithm.toString())); + } + } + } + } + } if(file.isFile()) { if(status.getDisplayname().remote != null) { final Move move = session.getFeature(Move.class); diff --git a/core/src/main/java/ch/cyberduck/core/vault/registry/VaultRegistryUploadFeature.java b/core/src/main/java/ch/cyberduck/core/vault/registry/VaultRegistryUploadFeature.java index eb5a5e99dee..e1e63cf1d9c 100644 --- a/core/src/main/java/ch/cyberduck/core/vault/registry/VaultRegistryUploadFeature.java +++ b/core/src/main/java/ch/cyberduck/core/vault/registry/VaultRegistryUploadFeature.java @@ -43,8 +43,7 @@ public VaultRegistryUploadFeature(final Session session, final Upload @Override @SuppressWarnings("unchecked") public Output upload(final Write write, final Path file, final Local local, final BandwidthThrottle throttle, final ProgressListener progress, final StreamListener streamListener, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { - return (Output) registry.find(session, file).getFeature(session, Upload.class, proxy).upload( - write, file, local, throttle, progress, streamListener, status, callback); + return (Output) registry.find(session, file).getFeature(session, Upload.class, proxy).upload(write, file, local, throttle, progress, streamListener, status, callback); } @Override diff --git a/core/src/test/java/ch/cyberduck/core/transfer/upload/ResumeFilterTest.java b/core/src/test/java/ch/cyberduck/core/transfer/upload/ResumeFilterTest.java index 96a8a5ad782..22abd2d3a3d 100644 --- a/core/src/test/java/ch/cyberduck/core/transfer/upload/ResumeFilterTest.java +++ b/core/src/test/java/ch/cyberduck/core/transfer/upload/ResumeFilterTest.java @@ -241,7 +241,7 @@ public AttributedList list(final Path folder, final ListProgressListener l } }; final ResumeFilter f = new ResumeFilter(new DisabledUploadSymlinkResolver(), session, - new DefaultUploadFeature<>(session), new UploadFilterOptions(host).withTemporary(true)); + new DefaultUploadFeature<>(), new UploadFilterOptions(host).withTemporary(true)); final long size = 3L; final Path t = new Path("t", EnumSet.of(Path.Type.file)); final NullLocal l = new NullLocal("t") { diff --git a/ctera/src/test/java/ch/cyberduck/core/ctera/CteraConcurrentTransferWorkerTest.java b/ctera/src/test/java/ch/cyberduck/core/ctera/CteraConcurrentTransferWorkerTest.java index 1b68a14520e..34093f5f8ea 100644 --- a/ctera/src/test/java/ch/cyberduck/core/ctera/CteraConcurrentTransferWorkerTest.java +++ b/ctera/src/test/java/ch/cyberduck/core/ctera/CteraConcurrentTransferWorkerTest.java @@ -69,7 +69,7 @@ public void testBelowSegmentSizeUpAndDownload() throws Exception { assertNotNull(out); IOUtils.write(content, out); out.close(); - new DAVUploadFeature(session).upload(new CteraWriteFeature(session), test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledProgressListener(), new DisabledStreamListener(), new TransferStatus().setLength(content.length), new DisabledConnectionCallback()); + new DAVUploadFeature().upload(new CteraWriteFeature(session), test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledProgressListener(), new DisabledStreamListener(), new TransferStatus().setLength(content.length), new DisabledConnectionCallback()); assertEquals(content.length, new DAVAttributesFinderFeature(session).find(test).getSize()); final Local localFile = new DefaultTemporaryFileService().create(test.getName()); final Transfer download = new DownloadTransfer(new Host(new TestProtocol()), Collections.singletonList(new TransferItem(test, localFile)), new NullFilter<>()); @@ -97,7 +97,7 @@ public void testLargeUpAndDownload() throws Exception { assertNotNull(out); IOUtils.write(content, out); out.close(); - new DAVUploadFeature(session).upload(new CteraWriteFeature(session), test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledProgressListener(), new DisabledStreamListener(), new TransferStatus().setLength(content.length), new DisabledConnectionCallback()); + new DAVUploadFeature().upload(new CteraWriteFeature(session), test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledProgressListener(), new DisabledStreamListener(), new TransferStatus().setLength(content.length), new DisabledConnectionCallback()); assertEquals(content.length, new DAVAttributesFinderFeature(session).find(test).getSize()); final Local localFile = new DefaultTemporaryFileService().create(test.getName()); final Transfer download = new DownloadTransfer(new Host(new TestProtocol()), Collections.singletonList(new TransferItem(test, localFile)), new NullFilter<>()); diff --git a/ctera/src/test/java/ch/cyberduck/core/ctera/CteraDirectIOReadFeatureTest.java b/ctera/src/test/java/ch/cyberduck/core/ctera/CteraDirectIOReadFeatureTest.java index 54fe13f55dc..69f207c8ed2 100644 --- a/ctera/src/test/java/ch/cyberduck/core/ctera/CteraDirectIOReadFeatureTest.java +++ b/ctera/src/test/java/ch/cyberduck/core/ctera/CteraDirectIOReadFeatureTest.java @@ -59,7 +59,7 @@ public void testReadChunk() throws Exception { assertNotNull(out); IOUtils.write(content, out); out.close(); - new DAVUploadFeature(session).upload( + new DAVUploadFeature().upload( new CteraWriteFeature(session), test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledProgressListener(), new DisabledStreamListener(), new TransferStatus().setLength(content.length), new DisabledConnectionCallback()); diff --git a/ctera/src/test/java/ch/cyberduck/core/ctera/CteraReadFeatureTest.java b/ctera/src/test/java/ch/cyberduck/core/ctera/CteraReadFeatureTest.java index 3265ae51a2e..971908cbedb 100644 --- a/ctera/src/test/java/ch/cyberduck/core/ctera/CteraReadFeatureTest.java +++ b/ctera/src/test/java/ch/cyberduck/core/ctera/CteraReadFeatureTest.java @@ -75,7 +75,7 @@ public void testReadChunkedTransfer() throws Exception { assertNotNull(out); IOUtils.write(content, out); out.close(); - new DAVUploadFeature(session).upload( + new DAVUploadFeature().upload( new CteraWriteFeature(session), test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledProgressListener(), new DisabledStreamListener(), new TransferStatus().setLength(content.length), new DisabledConnectionCallback()); @@ -123,7 +123,7 @@ public void testReadRange() throws Exception { assertNotNull(out); IOUtils.write(content, out); out.close(); - new DAVUploadFeature(session).upload( + new DAVUploadFeature().upload( new CteraWriteFeature(session), test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledProgressListener(), new DisabledStreamListener(), new TransferStatus().setLength(content.length), new DisabledConnectionCallback()); @@ -151,7 +151,7 @@ public void testReadRangeUnknownLength() throws Exception { assertNotNull(out); IOUtils.write(content, out); out.close(); - new DAVUploadFeature(session).upload( + new DAVUploadFeature().upload( new CteraWriteFeature(session), test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledProgressListener(), new DisabledStreamListener(), new TransferStatus().setLength(content.length), new DisabledConnectionCallback()); diff --git a/ctera/src/test/java/ch/cyberduck/core/ctera/CteraWriteFeatureTest.java b/ctera/src/test/java/ch/cyberduck/core/ctera/CteraWriteFeatureTest.java index 91def1b10b2..a027bd751fa 100644 --- a/ctera/src/test/java/ch/cyberduck/core/ctera/CteraWriteFeatureTest.java +++ b/ctera/src/test/java/ch/cyberduck/core/ctera/CteraWriteFeatureTest.java @@ -57,7 +57,7 @@ public void testReadWrite() throws Exception { out.close(); status.setLength(content.length); final Path test = new Path(folder, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)); - final HttpUploadFeature upload = new DAVUploadFeature(session); + final HttpUploadFeature upload = new DAVUploadFeature(); upload.upload(new CteraWriteFeature(session), test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledProgressListener(), new DisabledStreamListener(), status, new DisabledConnectionCallback()); assertTrue(session.getFeature(Find.class).find(test)); @@ -90,7 +90,7 @@ public void testReplaceContent() throws Exception { new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)), new TransferStatus()); final Local local = new Local(System.getProperty("java.io.tmpdir"), new AlphanumericRandomStringService().random()); final Path test = new Path(folder, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)); - final HttpUploadFeature upload = new DAVUploadFeature(session); + final HttpUploadFeature upload = new DAVUploadFeature(); { final byte[] content = RandomUtils.nextBytes(100); final OutputStream out = local.getOutputStream(false); diff --git a/defaults/src/main/resources/default.properties b/defaults/src/main/resources/default.properties index f1ef70f9a72..db024531986 100644 --- a/defaults/src/main/resources/default.properties +++ b/defaults/src/main/resources/default.properties @@ -447,7 +447,6 @@ googledrive.delete.multiple.partition=50 b2.bucket.acl.default=allPrivate b2.listing.chunksize=1000 b2.listing.versioning.enable=true -b2.upload.checksum.verify=true b2.upload.largeobject.auto=true b2.upload.largeobject=true b2.upload.largeobject.concurrency=5 diff --git a/dracoon/src/main/java/ch/cyberduck/core/sds/SDSDirectS3UploadFeature.java b/dracoon/src/main/java/ch/cyberduck/core/sds/SDSDirectS3UploadFeature.java index 31ac56f7911..c37dc8a6664 100644 --- a/dracoon/src/main/java/ch/cyberduck/core/sds/SDSDirectS3UploadFeature.java +++ b/dracoon/src/main/java/ch/cyberduck/core/sds/SDSDirectS3UploadFeature.java @@ -64,7 +64,6 @@ import java.io.IOException; import java.io.InputStream; -import java.security.MessageDigest; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -79,7 +78,7 @@ import com.dracoon.sdk.crypto.model.EncryptedFileKey; import com.fasterxml.jackson.databind.ObjectReader; -public class SDSDirectS3UploadFeature extends HttpUploadFeature { +public class SDSDirectS3UploadFeature extends HttpUploadFeature { private static final Logger log = LogManager.getLogger(SDSDirectS3UploadFeature.class); /** @@ -253,7 +252,7 @@ public TransferStatus call() throws BackgroundException { status.setPart(partNumber); status.setHeader(overall.getHeader()); status.setFilekey(overall.getFilekey()); - final Node node = SDSDirectS3UploadFeature.super.upload( + final Node node = SDSDirectS3UploadFeature.super.transfer( write, file, local, throttle, counter, status, overall, status, callback); log.info("Received response for part number {}", partNumber); // Delete temporary file if any diff --git a/dracoon/src/main/java/ch/cyberduck/core/sds/SDSSession.java b/dracoon/src/main/java/ch/cyberduck/core/sds/SDSSession.java index 24f09a81f57..3d55f514837 100644 --- a/dracoon/src/main/java/ch/cyberduck/core/sds/SDSSession.java +++ b/dracoon/src/main/java/ch/cyberduck/core/sds/SDSSession.java @@ -606,7 +606,7 @@ public T _getFeature(final Class type) { if(HostPreferencesFactory.get(host).getBoolean("sds.upload.s3.enable")) { return (T) new SDSDirectS3UploadFeature(this, nodeid); } - return (T) new DefaultUploadFeature(this); + return (T) new DefaultUploadFeature(); } if(type == MultipartWrite.class) { if(HostPreferencesFactory.get(host).getBoolean("sds.upload.s3.enable")) { diff --git a/dracoon/src/main/java/ch/cyberduck/core/sds/SDSUploadService.java b/dracoon/src/main/java/ch/cyberduck/core/sds/SDSUploadService.java index ebac6d5cc10..d6d1d433b4a 100644 --- a/dracoon/src/main/java/ch/cyberduck/core/sds/SDSUploadService.java +++ b/dracoon/src/main/java/ch/cyberduck/core/sds/SDSUploadService.java @@ -147,20 +147,8 @@ public Node complete(final Path file, final String uploadToken, final TransferSt } log.debug("Complete file upload for {} with token {}", file, uploadToken); final Node upload = new UploadsApi(session.getClient()).completeFileUploadByToken(uploadToken, body, StringUtils.EMPTY); - if(!upload.isIsEncrypted()) { - final Checksum checksum = status.getChecksum(); - if(Checksum.NONE != checksum) { - final Checksum server = Checksum.parse(upload.getHash()); - if(Checksum.NONE != server) { - if(checksum.algorithm.equals(server.algorithm)) { - if(!server.equals(checksum)) { - throw new ChecksumException(MessageFormat.format(LocaleFactory.localizedString("Upload {0} failed", "Error"), file.getName()), - MessageFormat.format("Mismatch between MD5 hash {0} of uploaded data and ETag {1} returned by the server", - checksum.hash, server.hash)); - } - } - } - } + if(upload.isIsEncrypted()) { + status.setChecksum(Checksum.NONE); } nodeid.cache(file, String.valueOf(upload.getId())); return upload; diff --git a/dracoon/src/test/java/ch/cyberduck/core/sds/SDSReadFeatureTest.java b/dracoon/src/test/java/ch/cyberduck/core/sds/SDSReadFeatureTest.java index a6a8028f2f5..5a63332ac5b 100644 --- a/dracoon/src/test/java/ch/cyberduck/core/sds/SDSReadFeatureTest.java +++ b/dracoon/src/test/java/ch/cyberduck/core/sds/SDSReadFeatureTest.java @@ -109,7 +109,7 @@ public void testReadRange() throws Exception { out.close(); final TransferStatus upload = new TransferStatus().setLength(content.length); upload.setExists(true); - new DefaultUploadFeature(session).upload( + new DefaultUploadFeature().upload( new SDSDirectS3MultipartWriteFeature(session, nodeid), test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledProgressListener(), new DisabledStreamListener(), upload, new DisabledConnectionCallback()); final TransferStatus status = new TransferStatus(); @@ -142,7 +142,7 @@ public void testReadRangeUnknownLength() throws Exception { out.close(); final TransferStatus upload = new TransferStatus().setLength(content.length); upload.setExists(true); - new DefaultUploadFeature(session).upload( + new DefaultUploadFeature().upload( new SDSDirectS3MultipartWriteFeature(session, nodeid), test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledProgressListener(), new DisabledStreamListener(), upload, new DisabledConnectionCallback()); final TransferStatus status = new TransferStatus(); diff --git a/dropbox/src/main/java/ch/cyberduck/core/dropbox/DropboxSession.java b/dropbox/src/main/java/ch/cyberduck/core/dropbox/DropboxSession.java index fc008c25ec6..a0d5c66ed71 100644 --- a/dropbox/src/main/java/ch/cyberduck/core/dropbox/DropboxSession.java +++ b/dropbox/src/main/java/ch/cyberduck/core/dropbox/DropboxSession.java @@ -149,7 +149,7 @@ public T _getFeature(Class type) { return (T) new DropboxWriteFeature(this); } if(type == Upload.class) { - return (T) new DropboxUploadFeature(this); + return (T) new DropboxUploadFeature(); } if(type == Directory.class) { return (T) new DropboxDirectoryFeature(this); diff --git a/dropbox/src/main/java/ch/cyberduck/core/dropbox/DropboxUploadFeature.java b/dropbox/src/main/java/ch/cyberduck/core/dropbox/DropboxUploadFeature.java index 15c90469a92..5681ee5a41c 100644 --- a/dropbox/src/main/java/ch/cyberduck/core/dropbox/DropboxUploadFeature.java +++ b/dropbox/src/main/java/ch/cyberduck/core/dropbox/DropboxUploadFeature.java @@ -16,60 +16,10 @@ * GNU General Public License for more details. */ -import ch.cyberduck.core.Path; -import ch.cyberduck.core.exception.BackgroundException; import ch.cyberduck.core.http.HttpUploadFeature; -import ch.cyberduck.core.io.Checksum; -import ch.cyberduck.core.preferences.HostPreferencesFactory; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import java.io.IOException; -import java.io.InputStream; -import java.security.DigestInputStream; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; - -import com.dropbox.core.v2.files.FileMetadata; import com.dropbox.core.v2.files.Metadata; -public class DropboxUploadFeature extends HttpUploadFeature { - private static final Logger log = LogManager.getLogger(DropboxUploadFeature.class); - - final DropboxSession session; - - public DropboxUploadFeature(final DropboxSession session) { - this.session = session; - } - - @Override - protected InputStream decorate(final InputStream in, final MessageDigest digest) throws IOException { - if(null == digest) { - log.warn("Checksum calculation disabled"); - return super.decorate(in, null); - } - else { - return new DigestInputStream(in, digest); - } - } - - @Override - protected MessageDigest digest() throws IOException { - MessageDigest digest = null; - if(HostPreferencesFactory.get(session.getHost()).getBoolean("queue.upload.checksum.calculate")) { - try { - digest = new DropboxContentHasher(MessageDigest.getInstance("SHA-256"), MessageDigest.getInstance("SHA-256"), 0); - } - catch(NoSuchAlgorithmException e) { - throw new IOException(e.getMessage(), e); - } - } - return digest; - } +public class DropboxUploadFeature extends HttpUploadFeature { - @Override - protected void post(final Path file, final MessageDigest digest, final Metadata response) throws BackgroundException { - this.verify(file, digest, Checksum.parse(((FileMetadata) response).getContentHash())); - } } diff --git a/dropbox/src/main/java/ch/cyberduck/core/dropbox/DropboxWriteFeature.java b/dropbox/src/main/java/ch/cyberduck/core/dropbox/DropboxWriteFeature.java index bc06b98c7be..e291bca132d 100644 --- a/dropbox/src/main/java/ch/cyberduck/core/dropbox/DropboxWriteFeature.java +++ b/dropbox/src/main/java/ch/cyberduck/core/dropbox/DropboxWriteFeature.java @@ -21,6 +21,7 @@ import ch.cyberduck.core.exception.BackgroundException; import ch.cyberduck.core.http.AbstractHttpWriteFeature; import ch.cyberduck.core.http.HttpResponseOutputStream; +import ch.cyberduck.core.io.Checksum; import ch.cyberduck.core.io.ChecksumCompute; import ch.cyberduck.core.io.DefaultStreamCloser; import ch.cyberduck.core.preferences.HostPreferencesFactory; @@ -66,6 +67,7 @@ public DropboxWriteFeature(final DropboxSession session, final Long chunksize) { public HttpResponseOutputStream write(final Path file, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { try { final DbxUserFilesRequests files = new DbxUserFilesRequests(session.getClient(file)); + final Checksum checksum = status.getChecksum(); final UploadSessionStartUploader start = files.uploadSessionStart(); new DefaultStreamCloser().close(start.getOutputStream()); final String sessionId = start.finish().getSessionId(); diff --git a/dropbox/src/test/java/ch/cyberduck/core/dropbox/DropboxReadFeatureTest.java b/dropbox/src/test/java/ch/cyberduck/core/dropbox/DropboxReadFeatureTest.java index 8ffbb93e7b8..5935586863c 100644 --- a/dropbox/src/test/java/ch/cyberduck/core/dropbox/DropboxReadFeatureTest.java +++ b/dropbox/src/test/java/ch/cyberduck/core/dropbox/DropboxReadFeatureTest.java @@ -91,10 +91,10 @@ public void testReadRange() throws Exception { assertNotNull(out); IOUtils.write(content, out); out.close(); - new DefaultUploadFeature(session).upload( + new DefaultUploadFeature().upload( new DropboxWriteFeature(session), test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledProgressListener(), new DisabledStreamListener(), new TransferStatus().setLength(content.length), - new DisabledConnectionCallback()); + new DisabledConnectionCallback()); final TransferStatus status = new TransferStatus(); status.setLength(content.length); status.setAppend(true); diff --git a/dropbox/src/test/java/ch/cyberduck/core/dropbox/DropboxUploadFeatureTest.java b/dropbox/src/test/java/ch/cyberduck/core/dropbox/DropboxUploadFeatureTest.java index bcbeb01f104..9cc2904b43f 100644 --- a/dropbox/src/test/java/ch/cyberduck/core/dropbox/DropboxUploadFeatureTest.java +++ b/dropbox/src/test/java/ch/cyberduck/core/dropbox/DropboxUploadFeatureTest.java @@ -23,6 +23,7 @@ import ch.cyberduck.core.Local; import ch.cyberduck.core.Path; import ch.cyberduck.core.PathAttributes; +import ch.cyberduck.core.exception.BackgroundException; import ch.cyberduck.core.features.Delete; import ch.cyberduck.core.io.BandwidthThrottle; import ch.cyberduck.core.transfer.TransferStatus; @@ -34,6 +35,7 @@ import org.junit.Test; import org.junit.experimental.categories.Category; +import java.io.InputStream; import java.util.Collections; import java.util.EnumSet; @@ -47,7 +49,7 @@ public class DropboxUploadFeatureTest extends AbstractDropboxTest { @Test public void testUploadSmall() throws Exception { - final DropboxUploadFeature feature = new DropboxUploadFeature(session); + final DropboxUploadFeature feature = new DropboxUploadFeature(); final Path root = new Path("/", EnumSet.of(Path.Type.directory, Path.Type.volume)); final String name = new AlphanumericRandomStringService().random(); final Path test = new Path(root, name, EnumSet.of(Path.Type.file)); @@ -76,6 +78,11 @@ public void testUploadSmall() throws Exception { @Test public void testDecorate() throws Exception { final NullInputStream n = new NullInputStream(1L); - assertSame(NullInputStream.class, new DropboxUploadFeature(session).decorate(n, null).getClass()); + assertSame(NullInputStream.class, new DropboxUploadFeature() { + @Override + protected InputStream decorate(final InputStream in, final TransferStatus status) throws BackgroundException { + return super.decorate(in, status); + } + }.decorate(n, new TransferStatus()).getClass()); } } \ No newline at end of file diff --git a/eue/src/main/java/ch/cyberduck/core/eue/EueLargeUploadService.java b/eue/src/main/java/ch/cyberduck/core/eue/EueLargeUploadService.java index 586a09581eb..4bdd7ac2fcd 100644 --- a/eue/src/main/java/ch/cyberduck/core/eue/EueLargeUploadService.java +++ b/eue/src/main/java/ch/cyberduck/core/eue/EueLargeUploadService.java @@ -56,7 +56,7 @@ import java.util.Map; import java.util.concurrent.Future; -public class EueLargeUploadService extends HttpUploadFeature { +public class EueLargeUploadService extends HttpUploadFeature { private static final Logger log = LogManager.getLogger(EueLargeUploadService.class); private final EueSession session; @@ -127,8 +127,8 @@ public EueWriteFeature.Chunk upload(final Write write, fi } else { throw new ChecksumException(MessageFormat.format(LocaleFactory.localizedString("Upload {0} failed", "Error"), file.getName()), - MessageFormat.format("Mismatch between {0} hash {1} of uploaded data and ETag {2} returned by the server", - HashAlgorithm.cdash64, cdash64, completedUploadResponse.getCdash64())); + MessageFormat.format("Mismatch between {2} checksum {0} of transferred data and {1} returned by the server", + cdash64, completedUploadResponse.getCdash64(), HashAlgorithm.cdash64)); } } final EueWriteFeature.Chunk object = new EueWriteFeature.Chunk(resourceId, size, cdash64); @@ -167,7 +167,7 @@ public EueWriteFeature.Chunk call() throws BackgroundException { status.setHeader(overall.getHeader()); status.setChecksum(write.checksum(file, status).compute(local.getInputStream(), status)); status.setUrl(url); - final EueWriteFeature.Chunk chunk = EueLargeUploadService.this.upload( + final EueWriteFeature.Chunk chunk = EueLargeUploadService.this.transfer( write, file, local, throttle, listener, status, overall, status, callback); log.info("Received response {} for part {}", chunk, partNumber); return chunk; diff --git a/eue/src/main/java/ch/cyberduck/core/eue/EueMultipartWriteFeature.java b/eue/src/main/java/ch/cyberduck/core/eue/EueMultipartWriteFeature.java index 613a3655f6b..5dd382739bc 100644 --- a/eue/src/main/java/ch/cyberduck/core/eue/EueMultipartWriteFeature.java +++ b/eue/src/main/java/ch/cyberduck/core/eue/EueMultipartWriteFeature.java @@ -247,8 +247,8 @@ public void close() throws IOException { } else { throw new ChecksumException(MessageFormat.format(LocaleFactory.localizedString("Upload {0} failed", "Error"), file.getName()), - MessageFormat.format("Mismatch between {0} hash {1} of uploaded data and ETag {2} returned by the server", - HashAlgorithm.cdash64, cdash64, completedUploadResponse.getCdash64())); + MessageFormat.format("Mismatch between {2} checksum {0} of transferred data and {1} returned by the server", + cdash64, completedUploadResponse.getCdash64(), HashAlgorithm.cdash64)); } } result.set(new EueWriteFeature.Chunk(resourceId, offset, cdash64)); diff --git a/eue/src/main/java/ch/cyberduck/core/eue/EueSingleUploadService.java b/eue/src/main/java/ch/cyberduck/core/eue/EueSingleUploadService.java index 8db9d525311..ce665d79885 100644 --- a/eue/src/main/java/ch/cyberduck/core/eue/EueSingleUploadService.java +++ b/eue/src/main/java/ch/cyberduck/core/eue/EueSingleUploadService.java @@ -28,12 +28,11 @@ import ch.cyberduck.core.io.StreamListener; import ch.cyberduck.core.transfer.TransferStatus; -import java.security.MessageDigest; import java.util.Collections; import static ch.cyberduck.core.eue.EueWriteFeature.RESOURCE_ID; -public class EueSingleUploadService extends HttpUploadFeature { +public class EueSingleUploadService extends HttpUploadFeature { private final EueSession session; private final EueResourceIdProvider fileid; diff --git a/eue/src/main/java/ch/cyberduck/core/eue/EueThresholdUploadService.java b/eue/src/main/java/ch/cyberduck/core/eue/EueThresholdUploadService.java index d759e0d5e3f..08a5e0b59d5 100644 --- a/eue/src/main/java/ch/cyberduck/core/eue/EueThresholdUploadService.java +++ b/eue/src/main/java/ch/cyberduck/core/eue/EueThresholdUploadService.java @@ -59,7 +59,7 @@ public EueWriteFeature.Chunk upload(final Write write, fi return new EueLargeUploadService(session, fileid).upload(write, file, local, throttle, progress, streamListener, status, prompt); } // Write with multipart write feature for known file length sequentially 4MB chunks - return new EueUploadService(session).upload(write, file, local, throttle, progress, streamListener, status, prompt); + return new EueUploadService().upload(write, file, local, throttle, progress, streamListener, status, prompt); } // Write single chunk smaller than threshold return new EueSingleUploadService(session, fileid).upload(write, file, local, throttle, progress, streamListener, status, prompt); diff --git a/eue/src/main/java/ch/cyberduck/core/eue/EueUploadService.java b/eue/src/main/java/ch/cyberduck/core/eue/EueUploadService.java index 236f3cc696d..9a9fe3ce26f 100644 --- a/eue/src/main/java/ch/cyberduck/core/eue/EueUploadService.java +++ b/eue/src/main/java/ch/cyberduck/core/eue/EueUploadService.java @@ -17,11 +17,5 @@ import ch.cyberduck.core.http.HttpUploadFeature; -import java.security.MessageDigest; - -public class EueUploadService extends HttpUploadFeature { - - public EueUploadService(final EueSession session) { - - } +public class EueUploadService extends HttpUploadFeature { } diff --git a/eue/src/test/java/ch/cyberduck/core/cryptomator/EueUploadServiceTest.java b/eue/src/test/java/ch/cyberduck/core/cryptomator/EueUploadServiceTest.java index 27ecf049804..9a4340dc52b 100644 --- a/eue/src/test/java/ch/cyberduck/core/cryptomator/EueUploadServiceTest.java +++ b/eue/src/test/java/ch/cyberduck/core/cryptomator/EueUploadServiceTest.java @@ -91,7 +91,7 @@ public void testUploadVault() throws Exception { writeStatus.setLength(content.length); final BytecountStreamListener count = new BytecountStreamListener(); final CryptoUploadFeature feature = new CryptoUploadFeature<>(session, - new EueUploadService(session), + new EueUploadService(), cryptomator); feature.upload(new CryptoWriteFeature<>(session, new EueMultipartWriteFeature(session, fileid), cryptomator), test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledProgressListener(), count, writeStatus, new DisabledConnectionCallback()); assertEquals(content.length, count.getSent()); @@ -127,7 +127,7 @@ public void testUploadVaultWithBulkFeature() throws Exception { bulk.pre(Transfer.Type.upload, Collections.singletonMap(new TransferItem(test), writeStatus), new DisabledConnectionCallback()); final BytecountStreamListener count = new BytecountStreamListener(); final CryptoUploadFeature feature = new CryptoUploadFeature<>(session, - new EueUploadService(session), + new EueUploadService(), cryptomator); feature.upload(new CryptoWriteFeature<>(session, new EueMultipartWriteFeature(session, fileid), cryptomator), test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledProgressListener(), count, writeStatus, new DisabledConnectionCallback()); assertEquals(content.length, count.getSent()); diff --git a/eue/src/test/java/ch/cyberduck/core/eue/EueUploadServiceTest.java b/eue/src/test/java/ch/cyberduck/core/eue/EueUploadServiceTest.java index 64fb6eb21ae..e5b9717476f 100644 --- a/eue/src/test/java/ch/cyberduck/core/eue/EueUploadServiceTest.java +++ b/eue/src/test/java/ch/cyberduck/core/eue/EueUploadServiceTest.java @@ -44,7 +44,7 @@ public class EueUploadServiceTest extends AbstractEueSessionTest { @Test public void testUploadLargeFileInChunks() throws Exception { final EueResourceIdProvider fileid = new EueResourceIdProvider(session); - final EueUploadService s = new EueUploadService(session); + final EueUploadService s = new EueUploadService(); final Path container = new EueDirectoryFeature(session, fileid).mkdir(new EueWriteFeature(session, fileid), new Path( new AlphanumericRandomStringService().random(), EnumSet.of(AbstractPath.Type.directory)), new TransferStatus()); final String name = new AlphanumericRandomStringService().random(); diff --git a/ftp/src/main/java/ch/cyberduck/core/ftp/FTPSession.java b/ftp/src/main/java/ch/cyberduck/core/ftp/FTPSession.java index fcf6f6e4664..7146a7ecb85 100644 --- a/ftp/src/main/java/ch/cyberduck/core/ftp/FTPSession.java +++ b/ftp/src/main/java/ch/cyberduck/core/ftp/FTPSession.java @@ -295,7 +295,7 @@ public T _getFeature(final Class type) { return (T) read; } if(type == Upload.class) { - return (T) new FTPUploadFeature(this); + return (T) new FTPUploadFeature(); } if(type == Write.class) { return (T) new FTPWriteFeature(this); diff --git a/ftp/src/main/java/ch/cyberduck/core/ftp/FTPUploadFeature.java b/ftp/src/main/java/ch/cyberduck/core/ftp/FTPUploadFeature.java index 9de803f8d50..b070c9a5c68 100644 --- a/ftp/src/main/java/ch/cyberduck/core/ftp/FTPUploadFeature.java +++ b/ftp/src/main/java/ch/cyberduck/core/ftp/FTPUploadFeature.java @@ -16,7 +16,6 @@ */ import ch.cyberduck.core.Path; -import ch.cyberduck.core.Session; import ch.cyberduck.core.exception.BackgroundException; import ch.cyberduck.core.features.Write; import ch.cyberduck.core.shared.DefaultUploadFeature; @@ -24,10 +23,6 @@ public class FTPUploadFeature extends DefaultUploadFeature { - public FTPUploadFeature(final Session session) { - super(session); - } - @Override public Write.Append append(final Path file, final TransferStatus status) throws BackgroundException { return new Write.Append(status.isExists()).withStatus(status); diff --git a/ftp/src/test/java/ch/cyberduck/core/ftp/FTPUploadFeatureTest.java b/ftp/src/test/java/ch/cyberduck/core/ftp/FTPUploadFeatureTest.java index 1fb7a8ceff9..1cf5b05c5c2 100644 --- a/ftp/src/test/java/ch/cyberduck/core/ftp/FTPUploadFeatureTest.java +++ b/ftp/src/test/java/ch/cyberduck/core/ftp/FTPUploadFeatureTest.java @@ -34,7 +34,7 @@ public class FTPUploadFeatureTest extends AbstractFTPTest { public void testAppend() throws Exception { final Path f = new Path(new FTPWorkdirService(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)); new FTPTouchFeature(session).touch(new FTPWriteFeature(session), f, new TransferStatus()); - assertTrue(new FTPUploadFeature(session).append(f, new TransferStatus().setExists(true).setLength(0L).setRemote(new FTPAttributesFinderFeature(session).find(f))).append); + assertTrue(new FTPUploadFeature().append(f, new TransferStatus().setExists(true).setLength(0L).setRemote(new FTPAttributesFinderFeature(session).find(f))).append); new FTPDeleteFeature(session).delete(Collections.singletonList(f), new DisabledLoginCallback(), new Delete.DisabledCallback()); } } \ No newline at end of file diff --git a/ftp/src/test/java/ch/cyberduck/core/shared/DefaultUploadFeatureTest.java b/ftp/src/test/java/ch/cyberduck/core/shared/DefaultUploadFeatureTest.java index 993de99f1e2..9cbddc650fb 100644 --- a/ftp/src/test/java/ch/cyberduck/core/shared/DefaultUploadFeatureTest.java +++ b/ftp/src/test/java/ch/cyberduck/core/shared/DefaultUploadFeatureTest.java @@ -58,14 +58,14 @@ public void testTransferAppend() throws Exception { final Path test = new Path(new DefaultHomeFinderService(session).find(), UUID.randomUUID().toString(), EnumSet.of(Path.Type.file)); { final TransferStatus status = new TransferStatus().setLength(content.length / 2); - final Void reply = new DefaultUploadFeature(session).upload( + final Void reply = new DefaultUploadFeature().upload( new FTPWriteFeature(session), test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledProgressListener(), new DisabledStreamListener(), status, new DisabledConnectionCallback()); } { final TransferStatus status = new TransferStatus().setLength(content.length / 2).setOffset(content.length / 2).setAppend(true); - final Void reply = new DefaultUploadFeature(session).upload( + final Void reply = new DefaultUploadFeature().upload( new FTPWriteFeature(session), test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledProgressListener(), new DisabledStreamListener(), status, new DisabledConnectionCallback()); diff --git a/googledrive/src/main/java/ch/cyberduck/core/googledrive/DriveSession.java b/googledrive/src/main/java/ch/cyberduck/core/googledrive/DriveSession.java index 192a61b3f05..9034eb55652 100644 --- a/googledrive/src/main/java/ch/cyberduck/core/googledrive/DriveSession.java +++ b/googledrive/src/main/java/ch/cyberduck/core/googledrive/DriveSession.java @@ -129,7 +129,7 @@ public T _getFeature(Class type) { return (T) new DriveWriteFeature(this, fileid); } if(type == Upload.class) { - return (T) new DriveUploadFeature(this); + return (T) new DriveUploadFeature(); } if(type == Directory.class) { return (T) new DriveDirectoryFeature(this, fileid); diff --git a/googledrive/src/main/java/ch/cyberduck/core/googledrive/DriveUploadFeature.java b/googledrive/src/main/java/ch/cyberduck/core/googledrive/DriveUploadFeature.java index 135ab584720..324bec53cf5 100644 --- a/googledrive/src/main/java/ch/cyberduck/core/googledrive/DriveUploadFeature.java +++ b/googledrive/src/main/java/ch/cyberduck/core/googledrive/DriveUploadFeature.java @@ -17,12 +17,7 @@ import ch.cyberduck.core.http.HttpUploadFeature; -import java.security.MessageDigest; - import com.google.api.services.drive.model.File; -public class DriveUploadFeature extends HttpUploadFeature { - - public DriveUploadFeature(final DriveSession session) { - } +public class DriveUploadFeature extends HttpUploadFeature { } diff --git a/googledrive/src/main/java/ch/cyberduck/core/googledrive/DriveWriteFeature.java b/googledrive/src/main/java/ch/cyberduck/core/googledrive/DriveWriteFeature.java index 5a192222f27..896ad5f8fae 100644 --- a/googledrive/src/main/java/ch/cyberduck/core/googledrive/DriveWriteFeature.java +++ b/googledrive/src/main/java/ch/cyberduck/core/googledrive/DriveWriteFeature.java @@ -24,6 +24,9 @@ import ch.cyberduck.core.http.DefaultHttpResponseExceptionMappingService; import ch.cyberduck.core.http.DelayedHttpEntityCallable; import ch.cyberduck.core.http.HttpResponseOutputStream; +import ch.cyberduck.core.io.ChecksumCompute; +import ch.cyberduck.core.io.ChecksumComputeFactory; +import ch.cyberduck.core.io.HashAlgorithm; import ch.cyberduck.core.preferences.HostPreferencesFactory; import ch.cyberduck.core.transfer.TransferStatus; @@ -181,4 +184,9 @@ public long getContentLength() { }; return this.write(file, status, command); } + + @Override + public ChecksumCompute checksum(final Path file, final TransferStatus status) { + return ChecksumComputeFactory.get(HashAlgorithm.md5); + } } diff --git a/googledrive/src/test/java/ch/cyberduck/core/googledrive/DriveReadFeatureTest.java b/googledrive/src/test/java/ch/cyberduck/core/googledrive/DriveReadFeatureTest.java index e3da6555d56..a730b7a6572 100644 --- a/googledrive/src/test/java/ch/cyberduck/core/googledrive/DriveReadFeatureTest.java +++ b/googledrive/src/test/java/ch/cyberduck/core/googledrive/DriveReadFeatureTest.java @@ -76,7 +76,7 @@ public void testReadRange() throws Exception { IOUtils.write(content, out); out.close(); final DriveFileIdProvider fileid = new DriveFileIdProvider(session); - new DriveUploadFeature(session).upload( + new DriveUploadFeature().upload( new DriveWriteFeature(session, fileid), test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledProgressListener(), new DisabledStreamListener(), new TransferStatus().setLength(content.length), new DisabledConnectionCallback()); diff --git a/googledrive/src/test/java/ch/cyberduck/core/googledrive/DriveUploadFeatureTest.java b/googledrive/src/test/java/ch/cyberduck/core/googledrive/DriveUploadFeatureTest.java index 93e6e489740..e5c0461f0ff 100644 --- a/googledrive/src/test/java/ch/cyberduck/core/googledrive/DriveUploadFeatureTest.java +++ b/googledrive/src/test/java/ch/cyberduck/core/googledrive/DriveUploadFeatureTest.java @@ -56,9 +56,9 @@ public void testWrite() throws Exception { status.setLength(content.length); final Path test = new Path(DriveHomeFinderService.MYDRIVE_FOLDER, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)); final DriveFileIdProvider fileid = new DriveFileIdProvider(session); - final DriveUploadFeature upload = new DriveUploadFeature(session); + final DriveUploadFeature upload = new DriveUploadFeature(); upload.upload(new DriveWriteFeature(session, fileid), test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledProgressListener(), new DisabledStreamListener(), - status, new DisabledConnectionCallback()); + status, new DisabledConnectionCallback()); test.attributes().setFileId(fileid.getFileId(test)); assertTrue(session.getFeature(Find.class).find(test)); assertEquals(content.length, new DriveListService(session, fileid).list(test.getParent(), new DisabledListProgressListener()).get(test).attributes().getSize(), 0L); diff --git a/googlestorage/src/test/java/ch/cyberduck/core/googlestorage/DefaultUploadFeatureTest.java b/googlestorage/src/test/java/ch/cyberduck/core/googlestorage/DefaultUploadFeatureTest.java index 87b92ff0d04..4efb70c5a5d 100644 --- a/googlestorage/src/test/java/ch/cyberduck/core/googlestorage/DefaultUploadFeatureTest.java +++ b/googlestorage/src/test/java/ch/cyberduck/core/googlestorage/DefaultUploadFeatureTest.java @@ -50,7 +50,7 @@ public class DefaultUploadFeatureTest extends AbstractGoogleStorageTest { @Test public void testUpload() throws Exception { - final DefaultUploadFeature m = new DefaultUploadFeature<>(session); + final DefaultUploadFeature m = new DefaultUploadFeature<>(); final Path container = new Path("cyberduck-test-eu", EnumSet.of(Path.Type.directory, Path.Type.volume)); final Path test = new Path(container, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)); final Local local = new Local(System.getProperty("java.io.tmpdir"), UUID.randomUUID().toString()); diff --git a/i18n/src/main/resources/ar.lproj/Error.strings b/i18n/src/main/resources/ar.lproj/Error.strings index c191dd82f72..6f0ae5acd05 100644 Binary files a/i18n/src/main/resources/ar.lproj/Error.strings and b/i18n/src/main/resources/ar.lproj/Error.strings differ diff --git a/i18n/src/main/resources/bg.lproj/Error.strings b/i18n/src/main/resources/bg.lproj/Error.strings index 3a60a9eb0bd..dc2aaf3837e 100644 Binary files a/i18n/src/main/resources/bg.lproj/Error.strings and b/i18n/src/main/resources/bg.lproj/Error.strings differ diff --git a/i18n/src/main/resources/ca.lproj/Error.strings b/i18n/src/main/resources/ca.lproj/Error.strings index e1864fc4cdf..75c8a5106e6 100644 Binary files a/i18n/src/main/resources/ca.lproj/Error.strings and b/i18n/src/main/resources/ca.lproj/Error.strings differ diff --git a/i18n/src/main/resources/cs.lproj/Error.strings b/i18n/src/main/resources/cs.lproj/Error.strings index 8dad7731d90..33dd5e4be6a 100644 Binary files a/i18n/src/main/resources/cs.lproj/Error.strings and b/i18n/src/main/resources/cs.lproj/Error.strings differ diff --git a/i18n/src/main/resources/cy.lproj/Error.strings b/i18n/src/main/resources/cy.lproj/Error.strings index 156fb5bffe8..c3286bb9f45 100644 Binary files a/i18n/src/main/resources/cy.lproj/Error.strings and b/i18n/src/main/resources/cy.lproj/Error.strings differ diff --git a/i18n/src/main/resources/da.lproj/Error.strings b/i18n/src/main/resources/da.lproj/Error.strings index a26d5fb3b95..341338e3b90 100644 Binary files a/i18n/src/main/resources/da.lproj/Error.strings and b/i18n/src/main/resources/da.lproj/Error.strings differ diff --git a/i18n/src/main/resources/de.lproj/Error.strings b/i18n/src/main/resources/de.lproj/Error.strings index 5d45d0baab5..0edc57c368c 100644 Binary files a/i18n/src/main/resources/de.lproj/Error.strings and b/i18n/src/main/resources/de.lproj/Error.strings differ diff --git a/i18n/src/main/resources/el.lproj/Error.strings b/i18n/src/main/resources/el.lproj/Error.strings index 29e7ae929a9..cff05aa5d4f 100644 Binary files a/i18n/src/main/resources/el.lproj/Error.strings and b/i18n/src/main/resources/el.lproj/Error.strings differ diff --git a/i18n/src/main/resources/en.lproj/Error.strings b/i18n/src/main/resources/en.lproj/Error.strings index 14b60be900e..356f0066cbe 100644 Binary files a/i18n/src/main/resources/en.lproj/Error.strings and b/i18n/src/main/resources/en.lproj/Error.strings differ diff --git a/i18n/src/main/resources/es.lproj/Error.strings b/i18n/src/main/resources/es.lproj/Error.strings index 9e0dace1a21..6def790a8e8 100644 Binary files a/i18n/src/main/resources/es.lproj/Error.strings and b/i18n/src/main/resources/es.lproj/Error.strings differ diff --git a/i18n/src/main/resources/et.lproj/Error.strings b/i18n/src/main/resources/et.lproj/Error.strings index 543622d3743..cc39b09859b 100644 Binary files a/i18n/src/main/resources/et.lproj/Error.strings and b/i18n/src/main/resources/et.lproj/Error.strings differ diff --git a/i18n/src/main/resources/fi.lproj/Error.strings b/i18n/src/main/resources/fi.lproj/Error.strings index 3228549d7e4..bc82b7586e1 100644 Binary files a/i18n/src/main/resources/fi.lproj/Error.strings and b/i18n/src/main/resources/fi.lproj/Error.strings differ diff --git a/i18n/src/main/resources/fr.lproj/Error.strings b/i18n/src/main/resources/fr.lproj/Error.strings index ba6ddf4b858..8b63fea5353 100644 Binary files a/i18n/src/main/resources/fr.lproj/Error.strings and b/i18n/src/main/resources/fr.lproj/Error.strings differ diff --git a/i18n/src/main/resources/he.lproj/Error.strings b/i18n/src/main/resources/he.lproj/Error.strings index 015f5ae32ca..7e9d66ad924 100644 Binary files a/i18n/src/main/resources/he.lproj/Error.strings and b/i18n/src/main/resources/he.lproj/Error.strings differ diff --git a/i18n/src/main/resources/hr.lproj/Error.strings b/i18n/src/main/resources/hr.lproj/Error.strings index cc157633eb7..5c836362678 100644 Binary files a/i18n/src/main/resources/hr.lproj/Error.strings and b/i18n/src/main/resources/hr.lproj/Error.strings differ diff --git a/i18n/src/main/resources/hu.lproj/Error.strings b/i18n/src/main/resources/hu.lproj/Error.strings index 3fe11041172..4922acafa04 100644 Binary files a/i18n/src/main/resources/hu.lproj/Error.strings and b/i18n/src/main/resources/hu.lproj/Error.strings differ diff --git a/i18n/src/main/resources/it.lproj/Error.strings b/i18n/src/main/resources/it.lproj/Error.strings index 13465e30745..125ba5f9ec6 100644 Binary files a/i18n/src/main/resources/it.lproj/Error.strings and b/i18n/src/main/resources/it.lproj/Error.strings differ diff --git a/i18n/src/main/resources/ja.lproj/Error.strings b/i18n/src/main/resources/ja.lproj/Error.strings index 120faf05017..f5a45788475 100644 Binary files a/i18n/src/main/resources/ja.lproj/Error.strings and b/i18n/src/main/resources/ja.lproj/Error.strings differ diff --git a/i18n/src/main/resources/ka.lproj/Error.strings b/i18n/src/main/resources/ka.lproj/Error.strings index b7851992996..f8845bf9d55 100644 Binary files a/i18n/src/main/resources/ka.lproj/Error.strings and b/i18n/src/main/resources/ka.lproj/Error.strings differ diff --git a/i18n/src/main/resources/ko.lproj/Error.strings b/i18n/src/main/resources/ko.lproj/Error.strings index 22f1e4ab697..8796799bc9b 100644 Binary files a/i18n/src/main/resources/ko.lproj/Error.strings and b/i18n/src/main/resources/ko.lproj/Error.strings differ diff --git a/i18n/src/main/resources/lv.lproj/Error.strings b/i18n/src/main/resources/lv.lproj/Error.strings index 1da6a6cdca2..5c0262f186e 100644 Binary files a/i18n/src/main/resources/lv.lproj/Error.strings and b/i18n/src/main/resources/lv.lproj/Error.strings differ diff --git a/i18n/src/main/resources/nl.lproj/Error.strings b/i18n/src/main/resources/nl.lproj/Error.strings index 72261f0a4d8..644f0bb10e9 100644 Binary files a/i18n/src/main/resources/nl.lproj/Error.strings and b/i18n/src/main/resources/nl.lproj/Error.strings differ diff --git a/i18n/src/main/resources/no.lproj/Error.strings b/i18n/src/main/resources/no.lproj/Error.strings index a4a3f318fb1..edb25d0e766 100644 Binary files a/i18n/src/main/resources/no.lproj/Error.strings and b/i18n/src/main/resources/no.lproj/Error.strings differ diff --git a/i18n/src/main/resources/pl.lproj/Error.strings b/i18n/src/main/resources/pl.lproj/Error.strings index 4ca70f5d1c1..c178b85eb01 100644 Binary files a/i18n/src/main/resources/pl.lproj/Error.strings and b/i18n/src/main/resources/pl.lproj/Error.strings differ diff --git a/i18n/src/main/resources/pt_BR.lproj/Error.strings b/i18n/src/main/resources/pt_BR.lproj/Error.strings index e6729d4fe7e..44d5338e7c5 100644 Binary files a/i18n/src/main/resources/pt_BR.lproj/Error.strings and b/i18n/src/main/resources/pt_BR.lproj/Error.strings differ diff --git a/i18n/src/main/resources/pt_PT.lproj/Error.strings b/i18n/src/main/resources/pt_PT.lproj/Error.strings index efffedc9cc9..109723243da 100644 Binary files a/i18n/src/main/resources/pt_PT.lproj/Error.strings and b/i18n/src/main/resources/pt_PT.lproj/Error.strings differ diff --git a/i18n/src/main/resources/ro.lproj/Error.strings b/i18n/src/main/resources/ro.lproj/Error.strings index d7a92688373..a285daa6c5a 100644 Binary files a/i18n/src/main/resources/ro.lproj/Error.strings and b/i18n/src/main/resources/ro.lproj/Error.strings differ diff --git a/i18n/src/main/resources/ru.lproj/Error.strings b/i18n/src/main/resources/ru.lproj/Error.strings index 827b21c2bcd..a4f77881a40 100644 Binary files a/i18n/src/main/resources/ru.lproj/Error.strings and b/i18n/src/main/resources/ru.lproj/Error.strings differ diff --git a/i18n/src/main/resources/sk.lproj/Error.strings b/i18n/src/main/resources/sk.lproj/Error.strings index 28a868fa0c0..c1fa9e31c15 100644 Binary files a/i18n/src/main/resources/sk.lproj/Error.strings and b/i18n/src/main/resources/sk.lproj/Error.strings differ diff --git a/i18n/src/main/resources/sl.lproj/Error.strings b/i18n/src/main/resources/sl.lproj/Error.strings index 3142d78b1d8..f6b1b3693fe 100644 Binary files a/i18n/src/main/resources/sl.lproj/Error.strings and b/i18n/src/main/resources/sl.lproj/Error.strings differ diff --git a/i18n/src/main/resources/sr.lproj/Error.strings b/i18n/src/main/resources/sr.lproj/Error.strings index 57c1aeb07ff..760f50e18da 100644 Binary files a/i18n/src/main/resources/sr.lproj/Error.strings and b/i18n/src/main/resources/sr.lproj/Error.strings differ diff --git a/i18n/src/main/resources/sv.lproj/Error.strings b/i18n/src/main/resources/sv.lproj/Error.strings index 57e659c6566..78742aec8e5 100644 Binary files a/i18n/src/main/resources/sv.lproj/Error.strings and b/i18n/src/main/resources/sv.lproj/Error.strings differ diff --git a/i18n/src/main/resources/ta_IN.lproj/Error.strings b/i18n/src/main/resources/ta_IN.lproj/Error.strings index fb09a3667b1..8354ac7c8db 100644 Binary files a/i18n/src/main/resources/ta_IN.lproj/Error.strings and b/i18n/src/main/resources/ta_IN.lproj/Error.strings differ diff --git a/i18n/src/main/resources/th.lproj/Error.strings b/i18n/src/main/resources/th.lproj/Error.strings index d3f6d5d9117..ca7cd138e21 100644 Binary files a/i18n/src/main/resources/th.lproj/Error.strings and b/i18n/src/main/resources/th.lproj/Error.strings differ diff --git a/i18n/src/main/resources/tr.lproj/Error.strings b/i18n/src/main/resources/tr.lproj/Error.strings index c6a41c5fa57..cbc57697bf5 100644 Binary files a/i18n/src/main/resources/tr.lproj/Error.strings and b/i18n/src/main/resources/tr.lproj/Error.strings differ diff --git a/i18n/src/main/resources/uk.lproj/Error.strings b/i18n/src/main/resources/uk.lproj/Error.strings index 1ce8ac18ec2..9a0b8c576e7 100644 Binary files a/i18n/src/main/resources/uk.lproj/Error.strings and b/i18n/src/main/resources/uk.lproj/Error.strings differ diff --git a/i18n/src/main/resources/zh_CN.lproj/Error.strings b/i18n/src/main/resources/zh_CN.lproj/Error.strings index 6649c2bf610..e91e4283712 100644 Binary files a/i18n/src/main/resources/zh_CN.lproj/Error.strings and b/i18n/src/main/resources/zh_CN.lproj/Error.strings differ diff --git a/i18n/src/main/resources/zh_TW.lproj/Error.strings b/i18n/src/main/resources/zh_TW.lproj/Error.strings index b80c9097b8d..21aa790f836 100644 Binary files a/i18n/src/main/resources/zh_TW.lproj/Error.strings and b/i18n/src/main/resources/zh_TW.lproj/Error.strings differ diff --git a/irods/src/main/java/ch/cyberduck/core/irods/IRODSUploadFeature.java b/irods/src/main/java/ch/cyberduck/core/irods/IRODSUploadFeature.java index 93f4b591879..a5dbb866224 100644 --- a/irods/src/main/java/ch/cyberduck/core/irods/IRODSUploadFeature.java +++ b/irods/src/main/java/ch/cyberduck/core/irods/IRODSUploadFeature.java @@ -98,8 +98,8 @@ public Void upload(final Write write, final Path file, final Local local, final Checksum expected = ChecksumComputeFactory.get(fingerprint.algorithm).compute(local.getInputStream(), new TransferStatus(status)); if(!expected.equals(fingerprint)) { throw new ChecksumException(MessageFormat.format(LocaleFactory.localizedString("Upload {0} failed", "Error"), file.getName()), - MessageFormat.format("Mismatch between {0} hash {1} of uploaded data and ETag {2} returned by the server", - fingerprint.algorithm.toString(), expected, fingerprint.hash)); + MessageFormat.format("Mismatch between {2} checksum {0} of transferred data and {1} returned by the server", + expected, fingerprint.hash, fingerprint.algorithm)); } } } diff --git a/irods/src/test/java/ch/cyberduck/core/irods/IRODSReadFeatureTest.java b/irods/src/test/java/ch/cyberduck/core/irods/IRODSReadFeatureTest.java index e77c9083589..724174cc3bd 100644 --- a/irods/src/test/java/ch/cyberduck/core/irods/IRODSReadFeatureTest.java +++ b/irods/src/test/java/ch/cyberduck/core/irods/IRODSReadFeatureTest.java @@ -136,7 +136,7 @@ public void testReadRange() throws Exception { assertNotNull(out); IOUtils.write(content, out); out.close(); - new DefaultUploadFeature(session).upload( + new DefaultUploadFeature().upload( new IRODSWriteFeature(session), test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledProgressListener(), new DisabledStreamListener(), new TransferStatus().setLength(content.length), new DisabledConnectionCallback()); diff --git a/manta/src/test/java/ch/cyberduck/core/manta/MantaReadFeatureTest.java b/manta/src/test/java/ch/cyberduck/core/manta/MantaReadFeatureTest.java index 75794fc4aa2..27333b9c832 100644 --- a/manta/src/test/java/ch/cyberduck/core/manta/MantaReadFeatureTest.java +++ b/manta/src/test/java/ch/cyberduck/core/manta/MantaReadFeatureTest.java @@ -97,7 +97,7 @@ public void testReadRange() throws Exception { assertNotNull(out); IOUtils.write(content, out); out.close(); - new DefaultUploadFeature(session).upload( + new DefaultUploadFeature().upload( new MantaWriteFeature(session), test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), @@ -133,7 +133,7 @@ public void testReadRangeUnknownLength() throws Exception { assertNotNull(out); IOUtils.write(content, out); out.close(); - new DefaultUploadFeature(session).upload( + new DefaultUploadFeature().upload( new MantaWriteFeature(session), test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledProgressListener(), new DisabledStreamListener(), new TransferStatus().setLength(content.length), new DisabledConnectionCallback()); diff --git a/nio/src/main/java/ch/cyberduck/core/nio/LocalSession.java b/nio/src/main/java/ch/cyberduck/core/nio/LocalSession.java index c7db0dbf0b0..64f3db5891a 100644 --- a/nio/src/main/java/ch/cyberduck/core/nio/LocalSession.java +++ b/nio/src/main/java/ch/cyberduck/core/nio/LocalSession.java @@ -172,7 +172,7 @@ public T _getFeature(final Class type) { return (T) new LocalTimestampFeature(this); } if(type == Upload.class) { - return (T) new LocalUploadFeature(this); + return (T) new LocalUploadFeature(); } return super._getFeature(type); } diff --git a/nio/src/main/java/ch/cyberduck/core/nio/LocalUploadFeature.java b/nio/src/main/java/ch/cyberduck/core/nio/LocalUploadFeature.java index 94193a98335..74a278e6744 100644 --- a/nio/src/main/java/ch/cyberduck/core/nio/LocalUploadFeature.java +++ b/nio/src/main/java/ch/cyberduck/core/nio/LocalUploadFeature.java @@ -16,7 +16,6 @@ */ import ch.cyberduck.core.Path; -import ch.cyberduck.core.Session; import ch.cyberduck.core.exception.BackgroundException; import ch.cyberduck.core.features.Write; import ch.cyberduck.core.shared.DefaultUploadFeature; @@ -24,10 +23,6 @@ public class LocalUploadFeature extends DefaultUploadFeature { - public LocalUploadFeature(final Session session) { - super(session); - } - @Override public Write.Append append(final Path file, final TransferStatus status) throws BackgroundException { return new Write.Append(status.isExists()).withStatus(status); diff --git a/nio/src/test/java/ch/cyberduck/core/nio/LocalUploadFeatureTest.java b/nio/src/test/java/ch/cyberduck/core/nio/LocalUploadFeatureTest.java index 66d1099421f..e1bd50e92ec 100644 --- a/nio/src/test/java/ch/cyberduck/core/nio/LocalUploadFeatureTest.java +++ b/nio/src/test/java/ch/cyberduck/core/nio/LocalUploadFeatureTest.java @@ -42,7 +42,7 @@ public void testAppend() throws Exception { final Path workdir = new LocalHomeFinderFeature().find(); final Path test = new Path(workdir, UUID.randomUUID().toString(), EnumSet.of(Path.Type.file)); new LocalTouchFeature(session).touch(new LocalWriteFeature(session), test, new TransferStatus()); - assertTrue(new LocalUploadFeature(session).append(test, new TransferStatus().setExists(true).setLength(0L).setRemote(new LocalAttributesFinderFeature(session).find(test))).append); + assertTrue(new LocalUploadFeature().append(test, new TransferStatus().setExists(true).setLength(0L).setRemote(new LocalAttributesFinderFeature(session).find(test))).append); new LocalDeleteFeature(session).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback()); } } \ No newline at end of file diff --git a/onedrive/src/test/java/ch/cyberduck/core/onedrive/GraphReadFeatureTest.java b/onedrive/src/test/java/ch/cyberduck/core/onedrive/GraphReadFeatureTest.java index 24953e9bc70..81d15439914 100644 --- a/onedrive/src/test/java/ch/cyberduck/core/onedrive/GraphReadFeatureTest.java +++ b/onedrive/src/test/java/ch/cyberduck/core/onedrive/GraphReadFeatureTest.java @@ -91,7 +91,7 @@ public void testReadRange() throws Exception { assertNotNull(out); IOUtils.write(content, out); out.close(); - new DefaultUploadFeature(session).upload( + new DefaultUploadFeature().upload( new GraphWriteFeature(session, fileid), test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledProgressListener(), new DisabledStreamListener(), new TransferStatus().setLength(content.length), new DisabledConnectionCallback()); @@ -134,7 +134,7 @@ public void testReadRangeUnknownLength() throws Exception { assertNotNull(out); IOUtils.write(content, out); out.close(); - new DefaultUploadFeature(session).upload( + new DefaultUploadFeature().upload( new GraphWriteFeature(session, fileid), test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledProgressListener(), new DisabledStreamListener(), new TransferStatus().setLength(content.length), new DisabledConnectionCallback()); diff --git a/openstack/src/main/java/ch/cyberduck/core/openstack/SwiftLargeObjectUploadFeature.java b/openstack/src/main/java/ch/cyberduck/core/openstack/SwiftLargeObjectUploadFeature.java index 2cf863d2947..a592b9c1349 100644 --- a/openstack/src/main/java/ch/cyberduck/core/openstack/SwiftLargeObjectUploadFeature.java +++ b/openstack/src/main/java/ch/cyberduck/core/openstack/SwiftLargeObjectUploadFeature.java @@ -49,7 +49,6 @@ import org.apache.logging.log4j.Logger; import java.io.IOException; -import java.security.MessageDigest; import java.text.MessageFormat; import java.util.ArrayList; import java.util.Collections; @@ -59,7 +58,7 @@ import ch.iterate.openstack.swift.exception.GenericException; import ch.iterate.openstack.swift.model.StorageObject; -public class SwiftLargeObjectUploadFeature extends HttpUploadFeature { +public class SwiftLargeObjectUploadFeature extends HttpUploadFeature { private static final Logger log = LogManager.getLogger(SwiftLargeObjectUploadFeature.class); private final SwiftSession session; @@ -205,7 +204,7 @@ public StorageObject call() throws BackgroundException { status.setHeader(overall.getHeader()); status.setChecksum(write.checksum(segment, status).compute(local.getInputStream(), status)); status.setSegment(true); - return SwiftLargeObjectUploadFeature.this.upload( + return SwiftLargeObjectUploadFeature.this.transfer( write, segment, local, throttle, counter, status, overall, status, callback); } }, overall, counter)); diff --git a/openstack/src/main/java/ch/cyberduck/core/openstack/SwiftSmallObjectUploadFeature.java b/openstack/src/main/java/ch/cyberduck/core/openstack/SwiftSmallObjectUploadFeature.java index 11616da0e1c..1e3ea35f71e 100644 --- a/openstack/src/main/java/ch/cyberduck/core/openstack/SwiftSmallObjectUploadFeature.java +++ b/openstack/src/main/java/ch/cyberduck/core/openstack/SwiftSmallObjectUploadFeature.java @@ -17,59 +17,10 @@ * Bug fixes, suggestions and comments should be sent to feedback@cyberduck.ch */ -import ch.cyberduck.core.Path; -import ch.cyberduck.core.exception.BackgroundException; import ch.cyberduck.core.http.HttpUploadFeature; -import ch.cyberduck.core.io.Checksum; -import ch.cyberduck.core.preferences.HostPreferencesFactory; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import java.io.IOException; -import java.io.InputStream; -import java.security.DigestInputStream; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; import ch.iterate.openstack.swift.model.StorageObject; -public class SwiftSmallObjectUploadFeature extends HttpUploadFeature { - private static final Logger log = LogManager.getLogger(SwiftSmallObjectUploadFeature.class); - - private final SwiftSession session; - - public SwiftSmallObjectUploadFeature(final SwiftSession session) { - this.session = session; - } - - @Override - protected InputStream decorate(final InputStream in, final MessageDigest digest) throws IOException { - if(null == digest) { - log.warn("MD5 calculation disabled"); - return super.decorate(in, null); - } - else { - return new DigestInputStream(in, digest); - } - } - - @Override - protected MessageDigest digest() throws IOException { - MessageDigest digest = null; - if(HostPreferencesFactory.get(session.getHost()).getBoolean("queue.upload.checksum.calculate")) { - try { - digest = MessageDigest.getInstance("MD5"); - } - catch(NoSuchAlgorithmException e) { - throw new IOException(e.getMessage(), e); - } - } - return digest; - } +public class SwiftSmallObjectUploadFeature extends HttpUploadFeature { - @Override - protected void post(final Path file, final MessageDigest digest, final StorageObject response) throws BackgroundException { - this.verify(file, digest, Checksum.parse(response.getMd5sum())); - } } diff --git a/openstack/src/main/java/ch/cyberduck/core/openstack/SwiftThresholdUploadService.java b/openstack/src/main/java/ch/cyberduck/core/openstack/SwiftThresholdUploadService.java index 083867b1bc4..fb8e52dcfae 100644 --- a/openstack/src/main/java/ch/cyberduck/core/openstack/SwiftThresholdUploadService.java +++ b/openstack/src/main/java/ch/cyberduck/core/openstack/SwiftThresholdUploadService.java @@ -69,7 +69,7 @@ public StorageObject upload(final Write write, final Path file, f feature = new SwiftLargeObjectUploadFeature(session, regionService); } else { - feature = new SwiftSmallObjectUploadFeature(session); + feature = new SwiftSmallObjectUploadFeature(); } return feature.upload(write, file, local, throttle, progress, streamListener, status, callback); } diff --git a/openstack/src/test/java/ch/cyberduck/core/cryptomator/SwiftLargeObjectUploadFeatureTest.java b/openstack/src/test/java/ch/cyberduck/core/cryptomator/SwiftLargeObjectUploadFeatureTest.java index 3044112839d..ad1f0386a56 100644 --- a/openstack/src/test/java/ch/cyberduck/core/cryptomator/SwiftLargeObjectUploadFeatureTest.java +++ b/openstack/src/test/java/ch/cyberduck/core/cryptomator/SwiftLargeObjectUploadFeatureTest.java @@ -89,7 +89,8 @@ public void testLargeObjectUpload() throws Exception { writeStatus.setHeader(cryptomator.getFileHeaderCryptor().encryptHeader(header)); writeStatus.setLength(content.length); final BytecountStreamListener count = new BytecountStreamListener(); - service.upload(new CryptoWriteFeature<>(session, new SwiftWriteFeature(session, new SwiftRegionService(session)), cryptomator), test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledProgressListener(), count, writeStatus, null); + service.upload(new CryptoWriteFeature<>(session, new SwiftWriteFeature(session, new SwiftRegionService(session)), cryptomator), test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledProgressListener(), count, writeStatus, null + ); assertEquals(content.length, count.getSent()); assertTrue(writeStatus.isComplete()); assertEquals(content.length, writeStatus.getResponse().getSize()); diff --git a/openstack/src/test/java/ch/cyberduck/core/openstack/SwiftLargeObjectUploadFeatureTest.java b/openstack/src/test/java/ch/cyberduck/core/openstack/SwiftLargeObjectUploadFeatureTest.java index 0f87d29da9d..e289ea9dc77 100644 --- a/openstack/src/test/java/ch/cyberduck/core/openstack/SwiftLargeObjectUploadFeatureTest.java +++ b/openstack/src/test/java/ch/cyberduck/core/openstack/SwiftLargeObjectUploadFeatureTest.java @@ -123,13 +123,13 @@ public void testAppendSecondPart() throws Exception { final SwiftLargeObjectUploadFeature feature = new SwiftLargeObjectUploadFeature(session, regionService, 1024L * 1024L, 1) { @Override - public StorageObject upload(final Write write, final Path file, final Local local, final BandwidthThrottle throttle, final StreamListener listener, final TransferStatus status, final StreamCancelation cancel, final StreamProgress progress, final ConnectionCallback callback) throws BackgroundException { + public StorageObject transfer(final Write write, final Path file, final Local local, final BandwidthThrottle throttle, final StreamListener listener, final TransferStatus status, final StreamCancelation cancel, final StreamProgress progress, final ConnectionCallback callback) throws BackgroundException { if(!interrupt.get()) { if(status.getOffset() >= 1L * 1024L * 1024L) { throw new ConnectionTimeoutException("Test"); } } - return super.upload(write, file, local, throttle, listener, status, cancel, progress, callback); + return super.transfer(write, file, local, throttle, listener, status, cancel, progress, callback); } }; final BytecountStreamListener listener = new BytecountStreamListener(); @@ -152,7 +152,7 @@ public StorageObject upload(final Write write, final Path file, f final TransferStatus append = new TransferStatus().setAppend(true).setLength(1024L * 1024L).setOffset(1024L * 1024L); feature.upload(new SwiftWriteFeature(session, new SwiftRegionService(session)), test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledProgressListener(), listener, append, - new DisabledLoginCallback()); + new DisabledLoginCallback()); assertEquals(2 * 1024L * 1024L, listener.getSent()); assertTrue(append.isComplete()); assertNotSame(PathAttributes.EMPTY, append.getResponse()); diff --git a/openstack/src/test/java/ch/cyberduck/core/openstack/SwiftSmallObjectUploadFeatureTest.java b/openstack/src/test/java/ch/cyberduck/core/openstack/SwiftSmallObjectUploadFeatureTest.java deleted file mode 100644 index 5cc86a01a9d..00000000000 --- a/openstack/src/test/java/ch/cyberduck/core/openstack/SwiftSmallObjectUploadFeatureTest.java +++ /dev/null @@ -1,69 +0,0 @@ -package ch.cyberduck.core.openstack; - -/* - * Copyright (c) 2002-2013 David Kocher. All rights reserved. - * http://cyberduck.ch/ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * Bug fixes, suggestions and comments should be sent to feedback@cyberduck.ch - */ - -import ch.cyberduck.core.Path; -import ch.cyberduck.core.exception.ChecksumException; -import ch.cyberduck.test.IntegrationTest; - -import org.apache.commons.io.input.NullInputStream; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -import java.security.MessageDigest; -import java.util.EnumSet; - -import ch.iterate.openstack.swift.model.StorageObject; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertSame; - -@Category(IntegrationTest.class) -public class SwiftSmallObjectUploadFeatureTest extends AbstractSwiftTest { - - @Test - public void testDecorate() throws Exception { - final NullInputStream n = new NullInputStream(1L); - assertSame(NullInputStream.class, new SwiftSmallObjectUploadFeature(session).decorate(n, null).getClass()); - } - - @Test(expected = ChecksumException.class) - public void testPostChecksumFailure() throws Exception { - final StorageObject o = new StorageObject("f"); - o.setMd5sum("d41d8cd98f00b204e9800998ecf8427f"); - try { - new SwiftSmallObjectUploadFeature(session).post( - new Path("/f", EnumSet.of(Path.Type.file)), MessageDigest.getInstance("MD5"), o - ); - } - catch(ChecksumException e) { - assertEquals("Upload f failed", e.getMessage()); - assertEquals("Mismatch between MD5 hash d41d8cd98f00b204e9800998ecf8427e of uploaded data and ETag d41d8cd98f00b204e9800998ecf8427f returned by the server.", e.getDetail()); - throw e; - } - } - - @Test - public void testPostChecksum() throws Exception { - final StorageObject o = new StorageObject("f"); - o.setMd5sum("d41d8cd98f00b204e9800998ecf8427e"); - new SwiftSmallObjectUploadFeature(session).post( - new Path("/f", EnumSet.of(Path.Type.file)), MessageDigest.getInstance("MD5"), o - ); - } -} diff --git a/openstack/src/test/java/ch/cyberduck/core/worker/SwiftSingleTransferWorkerTest.java b/openstack/src/test/java/ch/cyberduck/core/worker/SwiftSingleTransferWorkerTest.java index f7d6709ed4a..151569e72c9 100644 --- a/openstack/src/test/java/ch/cyberduck/core/worker/SwiftSingleTransferWorkerTest.java +++ b/openstack/src/test/java/ch/cyberduck/core/worker/SwiftSingleTransferWorkerTest.java @@ -45,6 +45,7 @@ import ch.cyberduck.core.transfer.TransferItem; import ch.cyberduck.core.transfer.TransferOptions; import ch.cyberduck.core.transfer.TransferSpeedometer; +import ch.cyberduck.core.transfer.TransferStatus; import ch.cyberduck.core.transfer.UploadTransfer; import ch.cyberduck.test.IntegrationTest; import ch.cyberduck.test.VaultTest; @@ -58,7 +59,6 @@ import java.io.InputStream; import java.io.OutputStream; import java.net.SocketTimeoutException; -import java.security.MessageDigest; import java.util.Collections; import java.util.EnumSet; import java.util.Random; @@ -101,7 +101,7 @@ public T _getFeature(final Class type) { final SwiftRegionService regionService = new SwiftRegionService(this); return (T) new SwiftLargeObjectUploadFeature(this, regionService, 1024L * 1024L, 5) { @Override - protected InputStream decorate(final InputStream in, final MessageDigest digest) { + protected InputStream decorate(final InputStream in, final TransferStatus status) { if(failed.get()) { // Second attempt successful return in; diff --git a/s3/src/main/java/ch/cyberduck/core/s3/S3MultipartUploadService.java b/s3/src/main/java/ch/cyberduck/core/s3/S3MultipartUploadService.java index 8c8021a647c..e1df5eca829 100644 --- a/s3/src/main/java/ch/cyberduck/core/s3/S3MultipartUploadService.java +++ b/s3/src/main/java/ch/cyberduck/core/s3/S3MultipartUploadService.java @@ -55,7 +55,6 @@ import org.jets3t.service.model.S3Object; import org.jets3t.service.model.StorageObject; -import java.security.MessageDigest; import java.text.MessageFormat; import java.util.ArrayList; import java.util.Date; @@ -66,7 +65,7 @@ import java.util.Set; import java.util.concurrent.Future; -public class S3MultipartUploadService extends HttpUploadFeature { +public class S3MultipartUploadService extends HttpUploadFeature { private static final Logger log = LogManager.getLogger(S3MultipartUploadService.class); private final S3Session session; @@ -181,8 +180,8 @@ public StorageObject upload(final Write write, final Path file, f final String reference = StringUtils.remove(complete.getEtag(), "\""); if(!StringUtils.equalsIgnoreCase(expected, reference)) { throw new ChecksumException(MessageFormat.format(LocaleFactory.localizedString("Upload {0} failed", "Error"), file.getName()), - MessageFormat.format("Mismatch between MD5 hash {0} of uploaded data and ETag {1} returned by the server", - expected, reference)); + MessageFormat.format("Mismatch between {2} checksum {0} of transferred data and {1} returned by the server", + expected, reference, HashAlgorithm.md5)); } } } @@ -239,7 +238,7 @@ public MultipartPart call() throws BackgroundException { metadata.put(HttpHeaders.CONTENT_MD5, md5.get().base64); status.setMetadata(metadata); } - final StorageObject part = S3MultipartUploadService.this.upload( + final StorageObject part = S3MultipartUploadService.this.transfer( write, file, local, throttle, counter, status, overall, status, callback); log.info("Received response {} for part number {}", part, partNumber); // Populate part with response data that is accessible via the object's metadata diff --git a/s3/src/main/java/ch/cyberduck/core/s3/S3MultipartWriteFeature.java b/s3/src/main/java/ch/cyberduck/core/s3/S3MultipartWriteFeature.java index d1b1b92462f..95e8a8dc363 100644 --- a/s3/src/main/java/ch/cyberduck/core/s3/S3MultipartWriteFeature.java +++ b/s3/src/main/java/ch/cyberduck/core/s3/S3MultipartWriteFeature.java @@ -208,8 +208,8 @@ public void close() throws IOException { final String reference = StringUtils.remove(complete.getEtag(), "\""); if(!StringUtils.equalsIgnoreCase(expected, reference)) { throw new ChecksumException(MessageFormat.format(LocaleFactory.localizedString("Upload {0} failed", "Error"), file.getName()), - MessageFormat.format("Mismatch between MD5 hash {0} of uploaded data and ETag {1} returned by the server", - expected, reference)); + MessageFormat.format("Mismatch between {2} checksum {0} of transferred data and {1} returned by the server", + expected, reference, HashAlgorithm.md5)); } } } diff --git a/s3/src/main/java/ch/cyberduck/core/s3/S3SingleUploadService.java b/s3/src/main/java/ch/cyberduck/core/s3/S3SingleUploadService.java index 29bf4900e22..312d59e86e8 100644 --- a/s3/src/main/java/ch/cyberduck/core/s3/S3SingleUploadService.java +++ b/s3/src/main/java/ch/cyberduck/core/s3/S3SingleUploadService.java @@ -29,20 +29,13 @@ import ch.cyberduck.core.io.Checksum; import ch.cyberduck.core.io.HashAlgorithm; import ch.cyberduck.core.io.StreamListener; -import ch.cyberduck.core.preferences.HostPreferencesFactory; import ch.cyberduck.core.transfer.TransferStatus; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.jets3t.service.model.StorageObject; -import java.io.IOException; -import java.io.InputStream; -import java.security.DigestInputStream; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; - -public class S3SingleUploadService extends HttpUploadFeature { +public class S3SingleUploadService extends HttpUploadFeature { private static final Logger log = LogManager.getLogger(S3SingleUploadService.class); private final S3Session session; @@ -64,7 +57,12 @@ public StorageObject upload(final Write write, final Path file, f break; } try { - return super.upload(write, file, local, throttle, progress, streamListener, status, callback); + final StorageObject response = super.upload(write, file, local, throttle, progress, streamListener, status, callback); + if(null != response.getServerSideEncryptionAlgorithm()) { + log.warn("Skip checksum verification for {} with server side encryption enabled", file); + status.setChecksum(Checksum.NONE); + } + return response; } catch(InteroperabilityException e) { if(!session.getSignatureVersion().equals(signatureVersion)) { @@ -76,37 +74,4 @@ public StorageObject upload(final Write write, final Path file, f } } - @Override - protected InputStream decorate(final InputStream in, final MessageDigest digest) throws IOException { - if(null == digest) { - log.warn("MD5 calculation disabled"); - return super.decorate(in, null); - } - else { - return new DigestInputStream(in, digest); - } - } - - @Override - protected MessageDigest digest() throws IOException { - MessageDigest digest = null; - if(HostPreferencesFactory.get(session.getHost()).getBoolean("queue.upload.checksum.calculate")) { - try { - digest = MessageDigest.getInstance("MD5"); - } - catch(NoSuchAlgorithmException e) { - throw new IOException(e.getMessage(), e); - } - } - return digest; - } - - @Override - protected void post(final Path file, final MessageDigest digest, final StorageObject response) throws BackgroundException { - if(null != response.getServerSideEncryptionAlgorithm()) { - log.warn("Skip checksum verification for {} with server side encryption enabled", file); - return; - } - this.verify(file, digest, Checksum.parse(response.getETag())); - } } diff --git a/s3/src/test/java/ch/cyberduck/core/s3/S3MultipartUploadServiceTest.java b/s3/src/test/java/ch/cyberduck/core/s3/S3MultipartUploadServiceTest.java index 12277fd673b..e9ccb568b44 100644 --- a/s3/src/test/java/ch/cyberduck/core/s3/S3MultipartUploadServiceTest.java +++ b/s3/src/test/java/ch/cyberduck/core/s3/S3MultipartUploadServiceTest.java @@ -159,7 +159,8 @@ public void testUploadInvalidContainer() throws Exception { final Path test = new Path(container, UUID.randomUUID().toString(), EnumSet.of(Path.Type.file)); final Local local = new Local(System.getProperty("java.io.tmpdir"), UUID.randomUUID().toString()); final TransferStatus status = new TransferStatus(); - m.upload(new S3WriteFeature(session, acl), test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledProgressListener(), new DisabledStreamListener(), status, null); + m.upload(new S3WriteFeature(session, acl), test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledProgressListener(), new DisabledStreamListener(), status, null + ); } @Test @@ -176,7 +177,8 @@ public void testMultipleParts() throws Exception { final TransferStatus status = new TransferStatus(); status.setLength(content.length); final BytecountStreamListener count = new BytecountStreamListener(); - m.upload(new S3WriteFeature(session, acl), test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledProgressListener(), count, status, null); + m.upload(new S3WriteFeature(session, acl), test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledProgressListener(), count, status, null + ); assertEquals(content.length, count.getSent()); assertTrue(status.isComplete()); assertNotSame(PathAttributes.EMPTY, status.getResponse()); @@ -230,11 +232,11 @@ public void testAppendSecondPart() throws Exception { final S3AccessControlListFeature acl = new S3AccessControlListFeature(session); final S3MultipartUploadService feature = new S3MultipartUploadService(session, acl, 10L * 1024L * 1024L, 1) { @Override - public StorageObject upload(final Write write, final Path file, final Local local, final BandwidthThrottle throttle, final StreamListener listener, final TransferStatus status, final StreamCancelation cancel, final StreamProgress progress, final ConnectionCallback callback) throws BackgroundException { + public StorageObject transfer(final Write write, final Path file, final Local local, final BandwidthThrottle throttle, final StreamListener listener, final TransferStatus status, final StreamCancelation cancel, final StreamProgress progress, final ConnectionCallback callback) throws BackgroundException { if(status.getOffset() >= 10L * 1024L * 1024L) { throw new ConnectionTimeoutException("Test"); } - return super.upload(write, file, local, throttle, listener, status, cancel, progress, callback); + return super.transfer(write, file, local, throttle, listener, status, cancel, progress, callback); } }; try { diff --git a/s3/src/test/java/ch/cyberduck/core/s3/S3SingleUploadServiceTest.java b/s3/src/test/java/ch/cyberduck/core/s3/S3SingleUploadServiceTest.java index 47ddc2d5674..e73ea5180be 100644 --- a/s3/src/test/java/ch/cyberduck/core/s3/S3SingleUploadServiceTest.java +++ b/s3/src/test/java/ch/cyberduck/core/s3/S3SingleUploadServiceTest.java @@ -17,7 +17,6 @@ import ch.cyberduck.core.DisabledLoginCallback; import ch.cyberduck.core.DisabledProgressListener; -import ch.cyberduck.core.Host; import ch.cyberduck.core.Local; import ch.cyberduck.core.Path; import ch.cyberduck.core.PathAttributes; @@ -31,7 +30,6 @@ import ch.cyberduck.test.IntegrationTest; import org.apache.commons.io.IOUtils; -import org.apache.commons.io.input.NullInputStream; import org.apache.commons.lang3.RandomUtils; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -41,19 +39,12 @@ import java.util.EnumSet; import java.util.UUID; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; @Category(IntegrationTest.class) public class S3SingleUploadServiceTest extends AbstractS3Test { - @Test - public void testDecorate() throws Exception { - final NullInputStream n = new NullInputStream(1L); - final S3Session session = new S3Session(new Host(new S3Protocol())); - assertSame(NullInputStream.class, new S3SingleUploadService(session - ).decorate(n, null).getClass()); - } - @Test public void testUpload() throws Exception { final S3AccessControlListFeature acl = new S3AccessControlListFeature(session); diff --git a/s3/src/test/java/ch/cyberduck/core/worker/S3SingleTransferWorkerTest.java b/s3/src/test/java/ch/cyberduck/core/worker/S3SingleTransferWorkerTest.java index e88952037d9..cbb8596bf42 100644 --- a/s3/src/test/java/ch/cyberduck/core/worker/S3SingleTransferWorkerTest.java +++ b/s3/src/test/java/ch/cyberduck/core/worker/S3SingleTransferWorkerTest.java @@ -61,7 +61,6 @@ import java.io.InputStream; import java.io.OutputStream; import java.net.SocketTimeoutException; -import java.security.MessageDigest; import java.util.Collections; import java.util.EnumSet; import java.util.HashSet; @@ -147,7 +146,7 @@ public T _getFeature(final Class type) { if(type == Upload.class) { return (T) new S3MultipartUploadService(this, new S3AccessControlListFeature(this), 5 * 1024L * 1024L, 5) { @Override - protected InputStream decorate(final InputStream in, final MessageDigest digest) { + protected InputStream decorate(final InputStream in, final TransferStatus status) { if(failed.get()) { // Second attempt successful return in; @@ -225,7 +224,7 @@ public T _getFeature(final Class type) { if(type == Upload.class) { return (T) new S3SingleUploadService(this) { @Override - protected InputStream decorate(final InputStream in, final MessageDigest digest) { + protected InputStream decorate(final InputStream in, final TransferStatus status) { if(failed.get()) { // Second attempt successful return in; diff --git a/spectra/src/main/java/ch/cyberduck/core/spectra/SpectraUploadFeature.java b/spectra/src/main/java/ch/cyberduck/core/spectra/SpectraUploadFeature.java index 50b15aa60f9..d8981f9ae63 100644 --- a/spectra/src/main/java/ch/cyberduck/core/spectra/SpectraUploadFeature.java +++ b/spectra/src/main/java/ch/cyberduck/core/spectra/SpectraUploadFeature.java @@ -32,10 +32,9 @@ import org.jets3t.service.model.StorageObject; -import java.security.MessageDigest; import java.util.List; -public class SpectraUploadFeature extends HttpUploadFeature { +public class SpectraUploadFeature extends HttpUploadFeature { private final SpectraBulkService bulk; diff --git a/ssh/src/main/java/ch/cyberduck/core/sftp/SFTPUploadFeature.java b/ssh/src/main/java/ch/cyberduck/core/sftp/SFTPUploadFeature.java index 428690ef342..bb7948e0134 100644 --- a/ssh/src/main/java/ch/cyberduck/core/sftp/SFTPUploadFeature.java +++ b/ssh/src/main/java/ch/cyberduck/core/sftp/SFTPUploadFeature.java @@ -25,7 +25,7 @@ public class SFTPUploadFeature extends DefaultUploadFeature { public SFTPUploadFeature(final Session session) { - super(session); + super(); } @Override diff --git a/ssh/src/test/java/ch/cyberduck/core/shared/DefaultUploadFeatureTest.java b/ssh/src/test/java/ch/cyberduck/core/shared/DefaultUploadFeatureTest.java index 73707a9fbc9..32f41bdffb9 100644 --- a/ssh/src/test/java/ch/cyberduck/core/shared/DefaultUploadFeatureTest.java +++ b/ssh/src/test/java/ch/cyberduck/core/shared/DefaultUploadFeatureTest.java @@ -59,17 +59,17 @@ public void testTransferAppend() throws Exception { final Path test = new Path(new SFTPHomeDirectoryService(session).find(), UUID.randomUUID().toString(), EnumSet.of(Path.Type.file)); { final TransferStatus status = new TransferStatus().setLength(content.length / 2); - new DefaultUploadFeature(session).upload( + new DefaultUploadFeature().upload( new SFTPWriteFeature(session), test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledProgressListener(), new DisabledStreamListener(), status, - new DisabledConnectionCallback()); + new DisabledConnectionCallback()); } { final TransferStatus status = new TransferStatus().setLength(content.length / 2).setOffset(content.length / 2).setAppend(true); - new DefaultUploadFeature(session).upload( + new DefaultUploadFeature().upload( new SFTPWriteFeature(session), test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledProgressListener(), new DisabledStreamListener(), status, - new DisabledConnectionCallback()); + new DisabledConnectionCallback()); } final byte[] buffer = new byte[content.length]; final Read read = session.getFeature(Read.class); diff --git a/storegate/src/test/java/ch/cyberduck/core/storegate/StoregateReadFeatureTest.java b/storegate/src/test/java/ch/cyberduck/core/storegate/StoregateReadFeatureTest.java index b9060589b2c..d7cabb91bd5 100644 --- a/storegate/src/test/java/ch/cyberduck/core/storegate/StoregateReadFeatureTest.java +++ b/storegate/src/test/java/ch/cyberduck/core/storegate/StoregateReadFeatureTest.java @@ -111,9 +111,9 @@ public void testReadRange() throws Exception { out.close(); final TransferStatus upload = new TransferStatus().setLength(content.length); upload.setExists(true); - new DefaultUploadFeature(session).upload( + new DefaultUploadFeature().upload( new StoregateWriteFeature(session, nodeid), test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledProgressListener(), new DisabledStreamListener(), upload, - new DisabledConnectionCallback()); + new DisabledConnectionCallback()); final TransferStatus status = new TransferStatus(); status.setLength(content.length); status.setAppend(true); @@ -145,9 +145,9 @@ public void testReadRangeUnknownLength() throws Exception { out.close(); final TransferStatus upload = new TransferStatus().setLength(content.length); upload.setExists(true); - new DefaultUploadFeature(session).upload( + new DefaultUploadFeature().upload( new StoregateWriteFeature(session, nodeid), test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledProgressListener(), new DisabledStreamListener(), upload, - new DisabledConnectionCallback()); + new DisabledConnectionCallback()); final TransferStatus status = new TransferStatus(); status.setLength(-1L); status.setAppend(true); diff --git a/tus/src/main/java/ch/cyberduck/core/tus/TusUploadFeature.java b/tus/src/main/java/ch/cyberduck/core/tus/TusUploadFeature.java index b4f1485602c..9f535b4e762 100644 --- a/tus/src/main/java/ch/cyberduck/core/tus/TusUploadFeature.java +++ b/tus/src/main/java/ch/cyberduck/core/tus/TusUploadFeature.java @@ -57,7 +57,6 @@ import java.io.IOException; import java.nio.charset.StandardCharsets; -import java.security.MessageDigest; import java.util.ArrayList; import java.util.EnumSet; import java.util.HashMap; @@ -67,7 +66,7 @@ import static ch.cyberduck.core.tus.TusCapabilities.*; -public class TusUploadFeature extends HttpUploadFeature { +public class TusUploadFeature extends HttpUploadFeature { private static final Logger log = LogManager.getLogger(TusUploadFeature.class); public static final String UPLOAD_URL = "uploadUrl"; @@ -178,7 +177,7 @@ public Void call() throws BackgroundException { final Map parameters = new HashMap<>(); parameters.put(UPLOAD_URL, uploadUrl); status.setParameters(parameters); - final Void response = TusUploadFeature.this.upload( + final Void response = TusUploadFeature.this.transfer( write, file, local, throttle, listener, status, overall, status, callback); log.info("Received response {}", response); return null; diff --git a/webdav/src/main/java/ch/cyberduck/core/dav/DAVSession.java b/webdav/src/main/java/ch/cyberduck/core/dav/DAVSession.java index 31c7eac5ed5..32792f59627 100644 --- a/webdav/src/main/java/ch/cyberduck/core/dav/DAVSession.java +++ b/webdav/src/main/java/ch/cyberduck/core/dav/DAVSession.java @@ -309,7 +309,7 @@ public T _getFeature(final Class type) { return (T) new DAVWriteFeature(this, capabilities.expectcontinue); } if(type == Upload.class) { - return (T) new DAVUploadFeature(this); + return (T) new DAVUploadFeature(); } if(type == Delete.class) { return (T) new DAVDeleteFeature(this); diff --git a/webdav/src/main/java/ch/cyberduck/core/dav/DAVUploadFeature.java b/webdav/src/main/java/ch/cyberduck/core/dav/DAVUploadFeature.java index 498ba35114e..80c4eb08c0d 100644 --- a/webdav/src/main/java/ch/cyberduck/core/dav/DAVUploadFeature.java +++ b/webdav/src/main/java/ch/cyberduck/core/dav/DAVUploadFeature.java @@ -23,13 +23,7 @@ import ch.cyberduck.core.http.HttpUploadFeature; import ch.cyberduck.core.transfer.TransferStatus; -import java.security.MessageDigest; - -public class DAVUploadFeature extends HttpUploadFeature { - - public DAVUploadFeature(final DAVSession session) { - - } +public class DAVUploadFeature extends HttpUploadFeature { @Override public Write.Append append(final Path file, final TransferStatus status) throws BackgroundException { diff --git a/webdav/src/test/java/ch/cyberduck/core/cryptomator/DAVReadFeatureTest.java b/webdav/src/test/java/ch/cyberduck/core/cryptomator/DAVReadFeatureTest.java index 3f38d3f3b81..0d25a3db056 100644 --- a/webdav/src/test/java/ch/cyberduck/core/cryptomator/DAVReadFeatureTest.java +++ b/webdav/src/test/java/ch/cyberduck/core/cryptomator/DAVReadFeatureTest.java @@ -87,7 +87,7 @@ public void testReadRange() throws Exception { out.close(); assertTrue(cryptomator.getFeature(session, Find.class, new DAVFindFeature(session)).find(test)); assertEquals(content.length, new CryptoListService(session, new DAVListService(session), cryptomator).list(test.getParent(), new DisabledListProgressListener()).get(test).attributes().getSize()); - assertEquals(content.length, new CryptoUploadFeature<>(session, new DAVUploadFeature(session), cryptomator).append(test, status.setRemote(cryptomator.getFeature(session, AttributesFinder.class, new DAVAttributesFinderFeature(session)).find(test))).offset, 0L); + assertEquals(content.length, new CryptoUploadFeature<>(session, new DAVUploadFeature(), cryptomator).append(test, status.setRemote(cryptomator.getFeature(session, AttributesFinder.class, new DAVAttributesFinderFeature(session)).find(test))).offset, 0L); { final ByteArrayOutputStream buffer = new ByteArrayOutputStream(40000); final TransferStatus read = new TransferStatus(); diff --git a/webdav/src/test/java/ch/cyberduck/core/cryptomator/DAVWriteFeatureTest.java b/webdav/src/test/java/ch/cyberduck/core/cryptomator/DAVWriteFeatureTest.java index 1ca8f86568d..d8ed3995bdb 100644 --- a/webdav/src/test/java/ch/cyberduck/core/cryptomator/DAVWriteFeatureTest.java +++ b/webdav/src/test/java/ch/cyberduck/core/cryptomator/DAVWriteFeatureTest.java @@ -87,7 +87,7 @@ public void testWrite() throws Exception { out.close(); assertTrue(cryptomator.getFeature(session, Find.class, new DAVFindFeature(session)).find(test)); assertEquals(content.length, new CryptoListService(session, new DAVListService(session), cryptomator).list(test.getParent(), new DisabledListProgressListener()).get(test).attributes().getSize()); - assertEquals(content.length, new CryptoUploadFeature<>(session, new DAVUploadFeature(session), cryptomator).append(test, status + assertEquals(content.length, new CryptoUploadFeature<>(session, new DAVUploadFeature(), cryptomator).append(test, status .setRemote(cryptomator.getFeature(session, AttributesFinder.class, new DAVAttributesFinderFeature(session)).find(test))).offset, 0L); final ByteArrayOutputStream buffer = new ByteArrayOutputStream(content.length); final InputStream in = new CryptoReadFeature(session, new DAVReadFeature(session), cryptomator).read(test, new TransferStatus().setLength(content.length), new DisabledConnectionCallback()); diff --git a/webdav/src/test/java/ch/cyberduck/core/dav/DAVLockFeatureTest.java b/webdav/src/test/java/ch/cyberduck/core/dav/DAVLockFeatureTest.java index 4ebe667583d..775557ede8a 100644 --- a/webdav/src/test/java/ch/cyberduck/core/dav/DAVLockFeatureTest.java +++ b/webdav/src/test/java/ch/cyberduck/core/dav/DAVLockFeatureTest.java @@ -52,7 +52,7 @@ public void testLockNotSupported() throws Exception { out.close(); status.setLength(content.length); final Path test = new Path(new DefaultHomeFinderService(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)); - final HttpUploadFeature upload = new DAVUploadFeature(session); + final HttpUploadFeature upload = new DAVUploadFeature(); upload.upload(new DAVWriteFeature(session), test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledProgressListener(), new DisabledStreamListener(), status, new DisabledConnectionCallback()); String lock = null; diff --git a/webdav/src/test/java/ch/cyberduck/core/dav/DAVReadFeatureTest.java b/webdav/src/test/java/ch/cyberduck/core/dav/DAVReadFeatureTest.java index 7a6b39ac7a2..18e788eac26 100644 --- a/webdav/src/test/java/ch/cyberduck/core/dav/DAVReadFeatureTest.java +++ b/webdav/src/test/java/ch/cyberduck/core/dav/DAVReadFeatureTest.java @@ -55,7 +55,7 @@ public void testReadChunkedTransfer() throws Exception { assertNotNull(out); IOUtils.write(content, out); out.close(); - new DAVUploadFeature(session).upload( + new DAVUploadFeature().upload( new DAVWriteFeature(session), test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledProgressListener(), new DisabledStreamListener(), new TransferStatus().setLength(content.length), new DisabledConnectionCallback()); @@ -103,7 +103,7 @@ public void testReadRange() throws Exception { assertNotNull(out); IOUtils.write(content, out); out.close(); - new DAVUploadFeature(session).upload( + new DAVUploadFeature().upload( new DAVWriteFeature(session), test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledProgressListener(), new DisabledStreamListener(), new TransferStatus().setLength(content.length), new DisabledConnectionCallback()); @@ -131,7 +131,7 @@ public void testReadRangeUnknownLength() throws Exception { assertNotNull(out); IOUtils.write(content, out); out.close(); - new DAVUploadFeature(session).upload( + new DAVUploadFeature().upload( new DAVWriteFeature(session), test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledProgressListener(), new DisabledStreamListener(), new TransferStatus().setLength(content.length), new DisabledConnectionCallback()); diff --git a/webdav/src/test/java/ch/cyberduck/core/dav/DAVUploadFeatureTest.java b/webdav/src/test/java/ch/cyberduck/core/dav/DAVUploadFeatureTest.java index cde943a0569..56cdb859d6f 100644 --- a/webdav/src/test/java/ch/cyberduck/core/dav/DAVUploadFeatureTest.java +++ b/webdav/src/test/java/ch/cyberduck/core/dav/DAVUploadFeatureTest.java @@ -56,7 +56,7 @@ public void testAccessDenied() throws Exception { new DefaultLocalTouchFeature().touch(local); final Path test = new Path(new Path("/dav/accessdenied", EnumSet.of(Path.Type.directory)), "nosuchname", EnumSet.of(Path.Type.file)); try { - new DAVUploadFeature(session).upload( + new DAVUploadFeature().upload( new DAVWriteFeature(session), test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledProgressListener(), new DisabledStreamListener(), status, new DisabledConnectionCallback()); @@ -81,14 +81,14 @@ public void testAppend() throws Exception { final Path test = new Path(new DefaultHomeFinderService(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)); { final TransferStatus status = new TransferStatus().setLength(content.length / 2); - new DAVUploadFeature(session).upload( + new DAVUploadFeature().upload( new DAVWriteFeature(session), test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledProgressListener(), new DisabledStreamListener(), status, new DisabledConnectionCallback()); } { final TransferStatus status = new TransferStatus().setLength(content.length / 2).setOffset(content.length / 2).setAppend(true); - new DAVUploadFeature(session).upload( + new DAVUploadFeature().upload( new DAVWriteFeature(session), test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledProgressListener(), new DisabledStreamListener(), status, new DisabledConnectionCallback()); @@ -104,7 +104,7 @@ public void testAppend() throws Exception { @Test public void testAppendZeroBytes() throws Exception { - final DAVUploadFeature feature = new DAVUploadFeature(session); + final DAVUploadFeature feature = new DAVUploadFeature(); final Path test = new DAVTouchFeature(session).touch(new DAVWriteFeature(session), new Path(new DefaultHomeFinderService(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)), new TransferStatus()); assertTrue(feature.append(test, new TransferStatus().setExists(true).setLength(0L).setRemote(new DAVAttributesFinderFeature(session).find(test))).append); new DAVDeleteFeature(session).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback()); diff --git a/webdav/src/test/java/ch/cyberduck/core/dav/DAVWriteFeatureTest.java b/webdav/src/test/java/ch/cyberduck/core/dav/DAVWriteFeatureTest.java index e47bfed81ee..aa2b0184090 100644 --- a/webdav/src/test/java/ch/cyberduck/core/dav/DAVWriteFeatureTest.java +++ b/webdav/src/test/java/ch/cyberduck/core/dav/DAVWriteFeatureTest.java @@ -52,12 +52,12 @@ public void testReadWrite() throws Exception { out.close(); status.setLength(content.length); final Path test = new Path(new DefaultHomeFinderService(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)); - final HttpUploadFeature upload = new DAVUploadFeature(session); + final HttpUploadFeature upload = new DAVUploadFeature(); upload.upload(new DAVWriteFeature(session), test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledProgressListener(), new DisabledStreamListener(), status, new DisabledConnectionCallback()); assertTrue(session.getFeature(Find.class).find(test)); assertEquals(content.length, new DAVListService(session).list(test.getParent(), new DisabledListProgressListener()).get(test).attributes().getSize(), 0L); - assertEquals(content.length, new DAVUploadFeature(session).append(test, status.setRemote(new DAVAttributesFinderFeature(session).find(test))).offset, 0L); + assertEquals(content.length, new DAVUploadFeature().append(test, status.setRemote(new DAVAttributesFinderFeature(session).find(test))).offset, 0L); { final byte[] buffer = new byte[content.length]; IOUtils.readFully(new DAVReadFeature(session).read(test, new TransferStatus(), new DisabledConnectionCallback()), buffer); @@ -85,12 +85,12 @@ public void testReadWriteChunkedTransfer() throws Exception { out.close(); status.setLength(TransferStatus.UNKNOWN_LENGTH); final Path test = new Path(new DefaultHomeFinderService(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)); - final HttpUploadFeature upload = new DAVUploadFeature(session); + final HttpUploadFeature upload = new DAVUploadFeature(); upload.upload(new DAVWriteFeature(session), test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledProgressListener(), new DisabledStreamListener(), status, new DisabledConnectionCallback()); assertTrue(session.getFeature(Find.class).find(test)); assertEquals(content.length, new DAVListService(session).list(test.getParent(), new DisabledListProgressListener()).get(test).attributes().getSize(), 0L); - assertEquals(content.length, new DAVUploadFeature(session).append(test, status.setRemote(new DAVAttributesFinderFeature(session).find(test))).offset, 0L); + assertEquals(content.length, new DAVUploadFeature().append(test, status.setRemote(new DAVAttributesFinderFeature(session).find(test))).offset, 0L); { final byte[] buffer = new byte[content.length]; IOUtils.readFully(new DAVReadFeature(session).read(test, new TransferStatus(), new DisabledConnectionCallback()), buffer); @@ -113,7 +113,7 @@ public void testReplaceContent() throws Exception { final Local local = new Local(System.getProperty("java.io.tmpdir"), new AlphanumericRandomStringService().random()); final Path folder = new DAVDirectoryFeature(session).mkdir(new DAVWriteFeature(session), new Path(new DefaultHomeFinderService(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)), new TransferStatus()); final Path test = new Path(folder, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)); - final HttpUploadFeature upload = new DAVUploadFeature(session); + final HttpUploadFeature upload = new DAVUploadFeature(); { final String folderEtag = new DAVAttributesFinderFeature(session).find(folder).getETag(); final byte[] content = RandomUtils.nextBytes(100); diff --git a/webdav/src/test/java/ch/cyberduck/core/dav/microsoft/MicrosoftIISDAVLockFeatureTest.java b/webdav/src/test/java/ch/cyberduck/core/dav/microsoft/MicrosoftIISDAVLockFeatureTest.java index c1eddbf4b5a..df6e00ea2ca 100644 --- a/webdav/src/test/java/ch/cyberduck/core/dav/microsoft/MicrosoftIISDAVLockFeatureTest.java +++ b/webdav/src/test/java/ch/cyberduck/core/dav/microsoft/MicrosoftIISDAVLockFeatureTest.java @@ -60,14 +60,14 @@ public void testLock() throws Exception { out.close(); status.setLength(content.length); final Path test = new Path(new DefaultHomeFinderService(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)); - final HttpUploadFeature upload = new DAVUploadFeature(session); + final HttpUploadFeature upload = new DAVUploadFeature(); upload.upload(new DAVWriteFeature(session), test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledProgressListener(), new DisabledStreamListener(), status, new DisabledConnectionCallback()); final String lock = new DAVLockFeature(session).lock(test); assertTrue(new MicrosoftIISDAVFindFeature(session).find(test)); final PathAttributes attributes = new MicrosoftIISDAVListService(session, new MicrosoftIISDAVAttributesFinderFeature(session)).list(test.getParent(), new DisabledListProgressListener()).get(test).attributes(); assertEquals(content.length, attributes.getSize(), 0L); - assertEquals(content.length, new DAVUploadFeature(session).append(test, status.setRemote(attributes)).offset, 0L); + assertEquals(content.length, new DAVUploadFeature().append(test, status.setRemote(attributes)).offset, 0L); { final byte[] buffer = new byte[content.length]; IOUtils.readFully(new MicrosoftIISDAVReadFeature(session).read(test, new TransferStatus(), new DisabledConnectionCallback()), buffer); diff --git a/webdav/src/test/java/ch/cyberduck/core/dav/microsoft/MicrosoftIISDAVReadFeatureTest.java b/webdav/src/test/java/ch/cyberduck/core/dav/microsoft/MicrosoftIISDAVReadFeatureTest.java index f06817d01d8..7c053feafb4 100644 --- a/webdav/src/test/java/ch/cyberduck/core/dav/microsoft/MicrosoftIISDAVReadFeatureTest.java +++ b/webdav/src/test/java/ch/cyberduck/core/dav/microsoft/MicrosoftIISDAVReadFeatureTest.java @@ -66,7 +66,7 @@ public void testReadConcurrency() throws Exception { assertNotNull(out); IOUtils.write(content, out); out.close(); - new DAVUploadFeature(session).upload( + new DAVUploadFeature().upload( new DAVWriteFeature(session), test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledProgressListener(), new DisabledStreamListener(), new TransferStatus().setLength(content.length), new DisabledConnectionCallback()); diff --git a/webdav/src/test/java/ch/cyberduck/core/dav/microsoft/MicrosoftIISDAVUploadFeatureTest.java b/webdav/src/test/java/ch/cyberduck/core/dav/microsoft/MicrosoftIISDAVUploadFeatureTest.java index 9699d47379a..faabd188fe2 100644 --- a/webdav/src/test/java/ch/cyberduck/core/dav/microsoft/MicrosoftIISDAVUploadFeatureTest.java +++ b/webdav/src/test/java/ch/cyberduck/core/dav/microsoft/MicrosoftIISDAVUploadFeatureTest.java @@ -58,7 +58,7 @@ public void testUpload() throws Exception { assertNotNull(out); IOUtils.write(content, out); out.close(); - new DAVUploadFeature(session).upload( + new DAVUploadFeature().upload( new DAVWriteFeature(session), test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledProgressListener(), new DisabledStreamListener(), new TransferStatus().setLength(content.length), new DisabledConnectionCallback()); @@ -78,7 +78,7 @@ public void testUploadNoConnectionInPool() throws Exception { // Close connections in pool to require new NTLM handshake final ClientConnectionManager manager = session.getClient().getClient().getConnectionManager(); manager.closeIdleConnections(0L, TimeUnit.MILLISECONDS); - assertThrows(InteroperabilityException.class, () -> new DAVUploadFeature(session).upload( + assertThrows(InteroperabilityException.class, () -> new DAVUploadFeature().upload( new DAVWriteFeature(session), test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledProgressListener(), new DisabledStreamListener(), new TransferStatus().setLength(content.length), new DisabledConnectionCallback())); @@ -97,7 +97,7 @@ public void testZeroByteUploadNoConnectionInPool() throws Exception { // Close connections in pool to require new NTLM handshake final ClientConnectionManager manager = session.getClient().getClient().getConnectionManager(); manager.closeIdleConnections(0L, TimeUnit.MILLISECONDS); - new DAVUploadFeature(session).upload( + new DAVUploadFeature().upload( new DAVWriteFeature(session), test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledProgressListener(), new DisabledStreamListener(), new TransferStatus().setLength(content.length), new DisabledConnectionCallback()); diff --git a/webdav/src/test/java/ch/cyberduck/core/worker/DAVConcurrentTransferWorkerTest.java b/webdav/src/test/java/ch/cyberduck/core/worker/DAVConcurrentTransferWorkerTest.java index 764b51d40ad..5cbd45ab9cf 100644 --- a/webdav/src/test/java/ch/cyberduck/core/worker/DAVConcurrentTransferWorkerTest.java +++ b/webdav/src/test/java/ch/cyberduck/core/worker/DAVConcurrentTransferWorkerTest.java @@ -80,7 +80,8 @@ public void testLargeUpAndDownload() throws Exception { assertNotNull(out); IOUtils.write(content, out); out.close(); - new DAVUploadFeature(session).upload(new DAVWriteFeature(session), test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledProgressListener(), new DisabledStreamListener(), new TransferStatus().setLength(content.length), new DisabledConnectionCallback()); + new DAVUploadFeature().upload(new DAVWriteFeature(session), test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledProgressListener(), new DisabledStreamListener(), new TransferStatus().setLength(content.length), new DisabledConnectionCallback() + ); assertEquals(content.length, new DAVAttributesFinderFeature(session).find(test).getSize()); final Local localFile = new DefaultTemporaryFileService().create(test.getName()); final Transfer download = new DownloadTransfer(new Host(new TestProtocol()), Collections.singletonList(new TransferItem(test, localFile)), new NullFilter<>()); @@ -113,7 +114,8 @@ public void testDownloadTransferWithFailure() throws Exception { assertNotNull(out); IOUtils.write(content, out); out.close(); - new DAVUploadFeature(session).upload(new DAVWriteFeature(session), test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledProgressListener(), new DisabledStreamListener(), new TransferStatus().setLength(content.length), new DisabledConnectionCallback()); + new DAVUploadFeature().upload(new DAVWriteFeature(session), test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledProgressListener(), new DisabledStreamListener(), new TransferStatus().setLength(content.length), new DisabledConnectionCallback() + ); final AtomicBoolean failed = new AtomicBoolean(); final Host host = new Host(session.getHost()) { @Override diff --git a/webdav/src/test/java/ch/cyberduck/core/worker/DAVSingleTransferWorkerTest.java b/webdav/src/test/java/ch/cyberduck/core/worker/DAVSingleTransferWorkerTest.java index 3f8277d7b28..95528d9a70c 100644 --- a/webdav/src/test/java/ch/cyberduck/core/worker/DAVSingleTransferWorkerTest.java +++ b/webdav/src/test/java/ch/cyberduck/core/worker/DAVSingleTransferWorkerTest.java @@ -83,7 +83,8 @@ public void testDownloadTransferWithFailure() throws Exception { assertNotNull(out); IOUtils.write(content, out); out.close(); - new DAVUploadFeature(session).upload(new DAVWriteFeature(session), test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledProgressListener(), new DisabledStreamListener(), new TransferStatus().setLength(content.length), new DisabledConnectionCallback()); + new DAVUploadFeature().upload(new DAVWriteFeature(session), test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledProgressListener(), new DisabledStreamListener(), new TransferStatus().setLength(content.length), new DisabledConnectionCallback() + ); final AtomicBoolean failed = new AtomicBoolean(); final Host host = new Host(session.getHost()) { @Override