Skip to content

Commit 6fb1992

Browse files
committed
Revert "Generalize checksum validation for uploads by comparing with attributes from server."
This reverts commit 07f53e5.
1 parent e3c3571 commit 6fb1992

File tree

88 files changed

+249
-336
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+249
-336
lines changed

backblaze/src/main/java/ch/cyberduck/core/b2/B2LargeUploadService.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@
3939
import ch.cyberduck.core.transfer.SegmentRetryCallable;
4040
import ch.cyberduck.core.transfer.TransferStatus;
4141

42-
import ch.cyberduck.core.transfer.upload.UploadFilterOptions;
43-
4442
import org.apache.logging.log4j.LogManager;
4543
import org.apache.logging.log4j.Logger;
4644

@@ -94,7 +92,7 @@ public B2LargeUploadService(final B2Session session, final B2VersionIdProvider f
9492

9593
@Override
9694
public BaseB2Response upload(final Write<BaseB2Response> write, final Path file, final Local local, final BandwidthThrottle throttle,
97-
final ProgressListener progress, final StreamListener streamListener, final TransferStatus status, final ConnectionCallback callback, final UploadFilterOptions options) throws BackgroundException {
95+
final ProgressListener progress, final StreamListener streamListener, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException {
9896
final long partSize;
9997
if(file.getType().contains(Path.Type.encrypted)) {
10098
// For uploads to vault part size must be a multiple of 32 * 1024. Recommended partsize from B2 API may not meet that requirement.
@@ -104,12 +102,12 @@ public BaseB2Response upload(final Write<BaseB2Response> write, final Path file,
104102
partSize = this.partSize;
105103
}
106104
return this.upload(write, file, local, throttle, progress, streamListener, status, callback,
107-
partSize < status.getLength() ? partSize : PreferencesFactory.get().getLong("b2.upload.largeobject.size.minimum"), options);
105+
partSize < status.getLength() ? partSize : PreferencesFactory.get().getLong("b2.upload.largeobject.size.minimum"));
108106
}
109107

110108
public BaseB2Response upload(final Write<BaseB2Response> write, final Path file, final Local local,
111109
final BandwidthThrottle throttle, final ProgressListener progress, final StreamListener streamListener, final TransferStatus status,
112-
final ConnectionCallback callback, final Long partSize, final UploadFilterOptions options) throws BackgroundException {
110+
final ConnectionCallback callback, final Long partSize) throws BackgroundException {
113111
final ThreadPool pool = ThreadPoolFactory.get("largeupload", concurrency);
114112
try {
115113
// Get the results of the uploads in the order they were submitted
@@ -171,7 +169,7 @@ public BaseB2Response upload(final Write<BaseB2Response> write, final Path file,
171169
if(!skip) {
172170
final long length = Math.min(Math.max((size / B2LargeUploadService.MAXIMUM_UPLOAD_PARTS), partSize), remaining);
173171
// Submit to queue
174-
parts.add(this.submit(pool, write, file, local, throttle, streamListener, status, fileId, partNumber, offset, length, callback, options));
172+
parts.add(this.submit(pool, write, file, local, throttle, streamListener, status, fileId, partNumber, offset, length, callback));
175173
log.debug("Part {} submitted with size {} and offset {}", partNumber, length, offset);
176174
remaining -= length;
177175
offset += length;
@@ -212,7 +210,7 @@ private Future<B2UploadPartResponse> submit(final ThreadPool pool, final Write<B
212210
final BandwidthThrottle throttle, final StreamListener listener,
213211
final TransferStatus overall,
214212
final String fileId, final int partNumber,
215-
final Long offset, final Long length, final ConnectionCallback callback, final UploadFilterOptions options) throws ConnectionCanceledException {
213+
final Long offset, final Long length, final ConnectionCallback callback) throws ConnectionCanceledException {
216214
overall.validate();
217215
log.info("Submit part {} of {} to queue with offset {} and length {}", partNumber, file, offset, length);
218216
final BytecountStreamListener counter = new BytecountStreamListener(listener);
@@ -230,7 +228,7 @@ public B2UploadPartResponse call() throws BackgroundException {
230228
status.setChecksum(write.checksum(file, status).compute(local.getInputStream(), status));
231229
status.setSegment(true);
232230
status.setPart(partNumber);
233-
return (B2UploadPartResponse) B2LargeUploadService.this.transfer(write, file, local, throttle, counter, status, overall, status, callback, options);
231+
return (B2UploadPartResponse) B2LargeUploadService.this.transfer(write, file, local, throttle, counter, status, overall, status, callback);
234232
}
235233
}, overall, counter));
236234
}

backblaze/src/main/java/ch/cyberduck/core/b2/B2ThresholdUploadService.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
import ch.cyberduck.core.preferences.HostPreferencesFactory;
2828
import ch.cyberduck.core.transfer.TransferStatus;
2929

30-
import ch.cyberduck.core.transfer.upload.UploadFilterOptions;
31-
3230
import org.apache.logging.log4j.LogManager;
3331
import org.apache.logging.log4j.Logger;
3432

@@ -61,12 +59,12 @@ public Write.Append append(final Path file, final TransferStatus status) throws
6159

6260
@Override
6361
public BaseB2Response upload(final Write<BaseB2Response> write, final Path file, final Local local, final BandwidthThrottle throttle, final ProgressListener progress, final StreamListener streamListener,
64-
final TransferStatus status, final ConnectionCallback callback, final UploadFilterOptions options) throws BackgroundException {
62+
final TransferStatus status, final ConnectionCallback callback) throws BackgroundException {
6563
if(this.threshold(status)) {
66-
return new B2LargeUploadService(session, fileid).upload(write, file, local, throttle, progress, streamListener, status, callback, options);
64+
return new B2LargeUploadService(session, fileid).upload(write, file, local, throttle, progress, streamListener, status, callback);
6765
}
6866
else {
69-
return new B2SingleUploadService().upload(write, file, local, throttle, progress, streamListener, status, callback, options);
67+
return new B2SingleUploadService().upload(write, file, local, throttle, progress, streamListener, status, callback);
7068
}
7169
}
7270

backblaze/src/test/java/ch/cyberduck/core/b2/B2LargeUploadServiceTest.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
import ch.cyberduck.core.io.StreamProgress;
3939
import ch.cyberduck.core.shared.DefaultFindFeature;
4040
import ch.cyberduck.core.transfer.TransferStatus;
41-
import ch.cyberduck.core.transfer.upload.UploadFilterOptions;
4241
import ch.cyberduck.test.IntegrationTest;
4342

4443
import org.apache.commons.io.IOUtils;
@@ -84,7 +83,7 @@ public void testUpload() throws Exception {
8483
final B2LargeUploadService upload = new B2LargeUploadService(session, fileid, 5 * 1000L * 1000L, 5);
8584

8685
upload.upload(new B2WriteFeature(session, fileid), test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledProgressListener(), new DisabledStreamListener(),
87-
status, new DisabledConnectionCallback(), new UploadFilterOptions(session.getHost()));
86+
status, new DisabledConnectionCallback());
8887
final PathAttributes attr = new B2AttributesFinderFeature(session, fileid).find(test);
8988
assertNotEquals(Checksum.NONE, attr.getChecksum());
9089
assertEquals(checksum, attr.getChecksum());
@@ -119,15 +118,15 @@ public void testAppendNoPartCompleted() throws Exception {
119118
final B2VersionIdProvider fileid = new B2VersionIdProvider(session);
120119
final B2LargeUploadService service = new B2LargeUploadService(session, fileid, 5 * 1000L * 1000L, 1) {
121120
@Override
122-
public BaseB2Response transfer(final Write<BaseB2Response> 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 UploadFilterOptions options) throws BackgroundException {
121+
public BaseB2Response transfer(final Write<BaseB2Response> 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 {
123122
if(!interrupt.get()) {
124123
throw new ConnectionTimeoutException("Test");
125124
}
126-
return super.transfer(write, file, local, throttle, listener, status, cancel, progress, callback, options);
125+
return super.transfer(write, file, local, throttle, listener, status, cancel, progress, callback);
127126
}
128127
};
129128
try {
130-
service.upload(new B2WriteFeature(session, fileid), test, new Local(System.getProperty("java.io.tmpdir"), name), new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledProgressListener(), count, status, new DisabledLoginCallback(), new UploadFilterOptions(session.getHost()));
129+
service.upload(new B2WriteFeature(session, fileid), test, new Local(System.getProperty("java.io.tmpdir"), name), new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledProgressListener(), count, status, new DisabledLoginCallback());
131130
}
132131
catch(BackgroundException e) {
133132
// Expected
@@ -143,7 +142,7 @@ public BaseB2Response transfer(final Write<BaseB2Response> write, final Path fil
143142
final TransferStatus append = new TransferStatus().setAppend(true).setLength(content.length);
144143
service.upload(new B2WriteFeature(session, fileid), test, local,
145144
new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledProgressListener(), new DisabledStreamListener(), append,
146-
new DisabledLoginCallback(), new UploadFilterOptions(session.getHost()));
145+
new DisabledLoginCallback());
147146
assertEquals(content.length, append.getResponse().getSize());
148147
assertTrue(new B2FindFeature(session, fileid).find(test));
149148
assertEquals(content.length, new B2AttributesFinderFeature(session, fileid).find(test).getSize());
@@ -172,18 +171,18 @@ public void testAppendSecondPart() throws Exception {
172171
final B2VersionIdProvider fileid = new B2VersionIdProvider(session);
173172
final B2LargeUploadService feature = new B2LargeUploadService(session, fileid, 5 * 1000L * 1000L, 1) {
174173
@Override
175-
public BaseB2Response transfer(final Write<BaseB2Response> 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 UploadFilterOptions options) throws BackgroundException {
174+
public BaseB2Response transfer(final Write<BaseB2Response> 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 {
176175
if(!interrupt.get()) {
177176
if(status.getOffset() >= 5L * 1000L * 1000L) {
178177
throw new ConnectionTimeoutException("Test");
179178
}
180179
}
181-
return super.transfer(write, file, local, throttle, listener, status, cancel, progress, callback, options);
180+
return super.transfer(write, file, local, throttle, listener, status, cancel, progress, callback);
182181
}
183182
};
184183
final BytecountStreamListener count = new BytecountStreamListener();
185184
try {
186-
feature.upload(new B2WriteFeature(session, fileid), test, new Local(System.getProperty("java.io.tmpdir"), name), new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledProgressListener(), count, status, new DisabledLoginCallback(), new UploadFilterOptions(session.getHost()));
185+
feature.upload(new B2WriteFeature(session, fileid), test, new Local(System.getProperty("java.io.tmpdir"), name), new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledProgressListener(), count, status, new DisabledLoginCallback());
187186
}
188187
catch(BackgroundException e) {
189188
// Expected
@@ -202,7 +201,7 @@ public BaseB2Response transfer(final Write<BaseB2Response> write, final Path fil
202201
final TransferStatus append = new TransferStatus().setAppend(true).setLength(2L * 1000L * 1000L).setOffset(5 * 1000L * 1000L);
203202
feature.upload(new B2WriteFeature(session, fileid), test, local,
204203
new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledProgressListener(), count, append,
205-
new DisabledLoginCallback(), new UploadFilterOptions(session.getHost()));
204+
new DisabledLoginCallback());
206205
assertEquals(6 * 1000L * 1000L, count.getSent());
207206
assertTrue(append.isComplete());
208207
assertEquals(content.length, append.getResponse().getSize());

backblaze/src/test/java/ch/cyberduck/core/b2/B2ReadFeatureTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import ch.cyberduck.core.io.StreamCopier;
3333
import ch.cyberduck.core.shared.DefaultDownloadFeature;
3434
import ch.cyberduck.core.transfer.TransferStatus;
35-
import ch.cyberduck.core.transfer.upload.UploadFilterOptions;
3635
import ch.cyberduck.test.IntegrationTest;
3736

3837
import org.apache.commons.io.IOUtils;
@@ -132,7 +131,7 @@ public void testReadRange() throws Exception {
132131
final BaseB2Response reply = new B2SingleUploadService().upload(
133132
new B2WriteFeature(session, fileid), test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledProgressListener(), new DisabledStreamListener(),
134133
new TransferStatus().setLength(content.length),
135-
new DisabledConnectionCallback(), new UploadFilterOptions(session.getHost()));
134+
new DisabledConnectionCallback());
136135
final TransferStatus status = new TransferStatus();
137136
status.setLength(content.length);
138137
status.setAppend(true);
@@ -164,7 +163,7 @@ public void testReadRangeUnknownLength() throws Exception {
164163
new B2SingleUploadService().upload(
165164
new B2WriteFeature(session, fileid), test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledProgressListener(), new DisabledStreamListener(),
166165
new TransferStatus().setLength(content.length),
167-
new DisabledConnectionCallback(), new UploadFilterOptions(session.getHost()));
166+
new DisabledConnectionCallback());
168167
final TransferStatus status = new TransferStatus();
169168
status.setLength(-1L);
170169
status.setAppend(true);

backblaze/src/test/java/ch/cyberduck/core/b2/B2SingleUploadServiceTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import ch.cyberduck.core.io.SHA1ChecksumCompute;
2929
import ch.cyberduck.core.io.StreamCopier;
3030
import ch.cyberduck.core.transfer.TransferStatus;
31-
import ch.cyberduck.core.transfer.upload.UploadFilterOptions;
3231
import ch.cyberduck.test.IntegrationTest;
3332

3433
import org.apache.commons.io.IOUtils;
@@ -64,7 +63,7 @@ public void testUpload() throws Exception {
6463
final B2VersionIdProvider fileid = new B2VersionIdProvider(session);
6564
final B2SingleUploadService upload = new B2SingleUploadService();
6665
upload.upload(new B2WriteFeature(session, fileid), test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledProgressListener(), new DisabledStreamListener(),
67-
status, new DisabledConnectionCallback(), new UploadFilterOptions(session.getHost()));
66+
status, new DisabledConnectionCallback());
6867
assertEquals(checksum, new B2AttributesFinderFeature(session, fileid).find(test).getChecksum());
6968
status.validate();
7069
assertTrue(status.isComplete());

backblaze/src/test/java/ch/cyberduck/core/cryptomator/B2LargeUploadServiceTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
import ch.cyberduck.core.transfer.Transfer;
4545
import ch.cyberduck.core.transfer.TransferItem;
4646
import ch.cyberduck.core.transfer.TransferStatus;
47-
import ch.cyberduck.core.transfer.upload.UploadFilterOptions;
4847
import ch.cyberduck.core.vault.DefaultVaultRegistry;
4948
import ch.cyberduck.core.vault.VaultCredentials;
5049
import ch.cyberduck.test.IntegrationTest;
@@ -94,7 +93,7 @@ public void testWrite() throws Exception {
9493
writeStatus.setLength(content.length);
9594
final Path test = new Path(vault, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
9695
final BytecountStreamListener counter = new BytecountStreamListener();
97-
service.upload(new CryptoWriteFeature<>(session, new B2WriteFeature(session, fileid), cryptomator), test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledProgressListener(), counter, writeStatus, new DisabledConnectionCallback(), new UploadFilterOptions(session.getHost()));
96+
service.upload(new CryptoWriteFeature<>(session, new B2WriteFeature(session, fileid), cryptomator), test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledProgressListener(), counter, writeStatus, new DisabledConnectionCallback());
9897
assertEquals(content.length, counter.getSent());
9998
assertTrue(writeStatus.isComplete());
10099
assertTrue(cryptomator.getFeature(session, Find.class, new B2FindFeature(session, fileid)).find(test));
@@ -130,7 +129,7 @@ public void testUploadWithBulk() throws Exception {
130129
final Local local = new Local(System.getProperty("java.io.tmpdir"), UUID.randomUUID().toString());
131130
IOUtils.write(content, local.getOutputStream(false));
132131
final BytecountStreamListener counter = new BytecountStreamListener();
133-
service.upload(new CryptoWriteFeature<>(session, new B2WriteFeature(session, fileid), cryptomator), test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledProgressListener(), counter, writeStatus, new DisabledConnectionCallback(), new UploadFilterOptions(session.getHost()));
132+
service.upload(new CryptoWriteFeature<>(session, new B2WriteFeature(session, fileid), cryptomator), test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledProgressListener(), counter, writeStatus, new DisabledConnectionCallback());
134133
assertEquals(content.length, counter.getSent());
135134
assertTrue(writeStatus.isComplete());
136135
assertTrue(cryptomator.getFeature(session, Find.class, new B2FindFeature(session, fileid)).find(test));

backblaze/src/test/java/ch/cyberduck/core/worker/B2ConcurrentTransferWorkerTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
import ch.cyberduck.core.transfer.TransferSpeedometer;
4444
import ch.cyberduck.core.transfer.TransferStatus;
4545
import ch.cyberduck.core.transfer.UploadTransfer;
46-
import ch.cyberduck.core.transfer.upload.UploadFilterOptions;
4746
import ch.cyberduck.core.vault.DefaultVaultRegistry;
4847
import ch.cyberduck.test.IntegrationTest;
4948

@@ -113,7 +112,7 @@ public Session create() {
113112
final B2LargeUploadService upload = new B2LargeUploadService(this, new B2VersionIdProvider(this)
114113
) {
115114
@Override
116-
protected InputStream decorate(final InputStream in, final TransferStatus status, final UploadFilterOptions options) {
115+
protected InputStream decorate(final InputStream in, final TransferStatus status) {
117116
if(failed.get()) {
118117
// Second attempt successful
119118
return in;

0 commit comments

Comments
 (0)