Skip to content

Commit 317a345

Browse files
committed
Lessen boilerplate.
1 parent afbab42 commit 317a345

File tree

56 files changed

+238
-278
lines changed

Some content is hidden

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

56 files changed

+238
-278
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public PathAttributes find(final Path file, final ListProgressListener listener)
7070
// Pending large file upload
7171
final Write.Append append = new B2LargeUploadService(session, fileid, new B2WriteFeature(session, fileid)).append(file, new TransferStatus());
7272
if(append.append) {
73-
return new PathAttributes().withSize(append.offset);
73+
return new PathAttributes().setSize(append.offset);
7474
}
7575
return PathAttributes.EMPTY;
7676
}

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@
4444
import java.util.Map;
4545
import java.util.concurrent.Future;
4646

47-
import static ch.cyberduck.core.b2.B2LargeUploadService.X_BZ_INFO_LARGE_FILE_SHA1;
48-
import static ch.cyberduck.core.b2.B2MetadataFeature.X_BZ_INFO_SRC_CREATION_DATE_MILLIS;
49-
import static ch.cyberduck.core.b2.B2MetadataFeature.X_BZ_INFO_SRC_LAST_MODIFIED_MILLIS;
50-
5147
import synapticloop.b2.exception.B2ApiException;
5248
import synapticloop.b2.response.B2StartLargeFileResponse;
5349
import synapticloop.b2.response.B2UploadPartResponse;
5450

51+
import static ch.cyberduck.core.b2.B2LargeUploadService.X_BZ_INFO_LARGE_FILE_SHA1;
52+
import static ch.cyberduck.core.b2.B2MetadataFeature.X_BZ_INFO_SRC_CREATION_DATE_MILLIS;
53+
import static ch.cyberduck.core.b2.B2MetadataFeature.X_BZ_INFO_SRC_LAST_MODIFIED_MILLIS;
54+
5555
public class B2LargeCopyFeature implements Copy {
5656
private static final Logger log = LogManager.getLogger(B2LargeCopyFeature.class);
5757

@@ -129,7 +129,7 @@ public int compare(final B2UploadPartResponse o1, final B2UploadPartResponse o2)
129129
session.getClient().finishLargeFileUpload(response.getFileId(), checksums.toArray(new String[checksums.size()]));
130130
log.info("Finished large file upload {} with {} parts", target, completed.size());
131131
fileid.cache(target, response.getFileId());
132-
return new Path(target).withAttributes(new PathAttributes(source.attributes()).withVersionId(response.getFileId()));
132+
return new Path(target).withAttributes(new PathAttributes(source.attributes()).setVersionId(response.getFileId()));
133133
}
134134
catch(B2ApiException e) {
135135
throw new B2ExceptionMappingService(fileid).map("Cannot copy {0}", e, source);

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ public void testListRevisions() throws Exception {
216216
assertEquals(Long.valueOf(1L), list.find(path -> path.attributes().isDuplicate()).attributes().getRevision());
217217
}
218218
// Add hide marker
219-
new B2DeleteFeature(session, fileid).delete(Collections.singletonList(file.withAttributes(new PathAttributes(file.attributes()).withVersionId(null))), new DisabledLoginCallback(), new Delete.DisabledCallback());
219+
new B2DeleteFeature(session, fileid).delete(Collections.singletonList(file.withAttributes(new PathAttributes(file.attributes()).setVersionId(null))), new DisabledLoginCallback(), new Delete.DisabledCallback());
220220
{
221221
final AttributedList<Path> list = new B2ObjectListService(session, fileid).list(bucket, new DisabledListProgressListener());
222222
assertEquals(3, list.size());
@@ -336,14 +336,14 @@ public void testListFolder() throws Exception {
336336
assertSame(folder1, list.find(new SimplePathPredicate(file1)).getParent());
337337
assertSame(folder1, list.find(new SimplePathPredicate(folder2)).getParent());
338338
// Nullify version to add delete marker
339-
new B2DeleteFeature(session, fileid).delete(Collections.singletonList(new Path(file2).withAttributes(new PathAttributes(file2.attributes()).withVersionId(null))), new DisabledLoginCallback(), new Delete.DisabledCallback());
339+
new B2DeleteFeature(session, fileid).delete(Collections.singletonList(new Path(file2).withAttributes(new PathAttributes(file2.attributes()).setVersionId(null))), new DisabledLoginCallback(), new Delete.DisabledCallback());
340340
assertTrue(new B2ObjectListService(session, fileid, 1, VersioningConfiguration.empty()).list(folder2, new DisabledListProgressListener()).isEmpty());
341341
assertFalse(new B2ObjectListService(session, fileid).list(folder2, new DisabledListProgressListener()).isEmpty());
342342
new B2DeleteFeature(session, fileid).delete(Collections.singletonList(folder2), new DisabledLoginCallback(), new Delete.DisabledCallback());
343343
assertTrue(new B2ObjectListService(session, fileid).list(folder2, new DisabledListProgressListener()).contains(file2));
344344
assertThrows(NotfoundException.class, () -> new B2ObjectListService(session, fileid, 1, VersioningConfiguration.empty()).list(folder2, new DisabledListProgressListener()));
345345
// Nullify version to add delete marker
346-
new B2DeleteFeature(session, fileid).delete(Collections.singletonList(new Path(file1).withAttributes(new PathAttributes(file1.attributes()).withVersionId(null))), new DisabledLoginCallback(), new Delete.DisabledCallback());
346+
new B2DeleteFeature(session, fileid).delete(Collections.singletonList(new Path(file1).withAttributes(new PathAttributes(file1.attributes()).setVersionId(null))), new DisabledLoginCallback(), new Delete.DisabledCallback());
347347
assertTrue(new B2ObjectListService(session, fileid, 1, VersioningConfiguration.empty()).list(folder1, new DisabledListProgressListener()).isEmpty());
348348
assertTrue(new B2ObjectListService(session, fileid).list(folder1, new DisabledListProgressListener()).contains(folder2));
349349
new B2DeleteFeature(session, fileid).delete(Collections.singletonList(folder1), new DisabledLoginCallback(), new Delete.DisabledCallback());
@@ -373,7 +373,7 @@ public void testDisplayFolderInBucketMissingPlaceholder() throws Exception {
373373
assertFalse(foundFolder1.attributes().isDuplicate());
374374
}
375375
// Nullify version to add delete marker
376-
new B2DeleteFeature(session, fileid).delete(Collections.singletonList(new Path(file1).withAttributes(new PathAttributes(file1.attributes()).withVersionId(null))), new DisabledLoginCallback(), new Delete.DisabledCallback());
376+
new B2DeleteFeature(session, fileid).delete(Collections.singletonList(new Path(file1).withAttributes(new PathAttributes(file1.attributes()).setVersionId(null))), new DisabledLoginCallback(), new Delete.DisabledCallback());
377377
assertTrue(new B2ObjectListService(session, fileid, 1, VersioningConfiguration.empty()).list(bucket, new DisabledListProgressListener()).isEmpty());
378378
{
379379
final AttributedList<Path> list = new B2ObjectListService(session, fileid).list(bucket, new DisabledListProgressListener());
@@ -410,7 +410,7 @@ public void testDisplayFolderInFolderMissingPlaceholder() throws Exception {
410410
assertFalse(foundFolder2.attributes().isDuplicate());
411411
}
412412
// Nullify version to add delete marker
413-
new B2DeleteFeature(session, fileid).delete(Collections.singletonList(file.withAttributes(new PathAttributes(file.attributes()).withVersionId(null))), new DisabledLoginCallback(), new Delete.DisabledCallback());
413+
new B2DeleteFeature(session, fileid).delete(Collections.singletonList(file.withAttributes(new PathAttributes(file.attributes()).setVersionId(null))), new DisabledLoginCallback(), new Delete.DisabledCallback());
414414
assertTrue(new DefaultFindFeature(session).find(folder1, new DisabledListProgressListener()));
415415
assertTrue(new B2ObjectListService(session, fileid).list(folder1, new DisabledListProgressListener()).contains(folder2));
416416
assertTrue(new DefaultFindFeature(session).find(folder2, new DisabledListProgressListener()));

0 commit comments

Comments
 (0)