Skip to content

Commit 186f279

Browse files
committed
Add writer as parameter to allow wrapping with encryption feature.
1 parent 01613b9 commit 186f279

15 files changed

+56
-55
lines changed

spectra/src/main/java/ch/cyberduck/core/spectra/SpectraDirectoryFeature.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,19 @@ public class SpectraDirectoryFeature extends S3DirectoryFeature {
3333
private final Write<StorageObject> writer;
3434

3535
public SpectraDirectoryFeature(final SpectraSession session, final Write<StorageObject> writer) {
36-
super(session, writer, new S3AccessControlListFeature(session));
36+
super(session, new S3AccessControlListFeature(session));
3737
this.containerService = new S3PathContainerService(session.getHost());
3838
this.writer = writer;
3939
}
4040

4141
@Override
42-
public Path mkdir(final Path folder, final TransferStatus status) throws BackgroundException {
42+
public Path mkdir(final Write<StorageObject> writer, final Path folder, final TransferStatus status) throws BackgroundException {
4343
if(containerService.isContainer(folder)) {
44-
return super.mkdir(folder, status);
44+
return super.mkdir(writer, folder, status);
4545
}
4646
else {
47-
status.setChecksum(writer.checksum(folder, status).compute(new NullInputStream(0L), status));
48-
return super.mkdir(folder, status);
47+
status.setChecksum(this.writer.checksum(folder, status).compute(new NullInputStream(0L), status));
48+
return super.mkdir(writer, folder, status);
4949
}
5050
}
5151
}

spectra/src/main/java/ch/cyberduck/core/spectra/SpectraTouchFeature.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import ch.cyberduck.core.Path;
2020
import ch.cyberduck.core.exception.AccessDeniedException;
2121
import ch.cyberduck.core.exception.BackgroundException;
22+
import ch.cyberduck.core.features.Write;
2223
import ch.cyberduck.core.shared.DefaultTouchFeature;
2324
import ch.cyberduck.core.transfer.Transfer;
2425
import ch.cyberduck.core.transfer.TransferItem;
@@ -34,15 +35,15 @@ public class SpectraTouchFeature extends DefaultTouchFeature<StorageObject> {
3435
private final SpectraSession session;
3536

3637
public SpectraTouchFeature(final SpectraSession session) {
37-
super(new SpectraWriteFeature(session));
38+
super(session);
3839
this.session = session;
3940
}
4041

4142
@Override
42-
public Path touch(final Path file, final TransferStatus status) throws BackgroundException {
43+
public Path touch(final Write<StorageObject> writer, final Path file, final TransferStatus status) throws BackgroundException {
4344
final SpectraBulkService bulk = new SpectraBulkService(session);
4445
bulk.pre(Transfer.Type.upload, Collections.singletonMap(new TransferItem(file), status), new DisabledConnectionCallback());
45-
return super.touch(file, status);
46+
return super.touch(writer, file, status);
4647
}
4748

4849
@Override

spectra/src/test/java/ch/cyberduck/core/spectra/SpectraAttributesFinderFeatureTest.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ public class SpectraAttributesFinderFeatureTest extends AbstractSpectraTest {
3939
@Test
4040
public void testFindFile() throws Exception {
4141
final Path container = new SpectraDirectoryFeature(session, new SpectraWriteFeature(session)).mkdir(
42-
new Path(new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory, Path.Type.volume)), new TransferStatus());
42+
new SpectraWriteFeature(session), new Path(new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory, Path.Type.volume)), new TransferStatus());
4343
final Path test = new Path(container, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
44-
new SpectraTouchFeature(session).touch(test, new TransferStatus());
44+
new SpectraTouchFeature(session).touch(new SpectraWriteFeature(session), test, new TransferStatus());
4545
final SpectraAttributesFinderFeature f = new SpectraAttributesFinderFeature(session);
4646
final PathAttributes attributes = f.find(test);
4747
assertEquals(0L, attributes.getSize());
@@ -62,7 +62,7 @@ public void testFindFile() throws Exception {
6262
@Test
6363
public void testFindBucket() throws Exception {
6464
final Path container = new SpectraDirectoryFeature(session, new SpectraWriteFeature(session)).mkdir(
65-
new Path(new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory, Path.Type.volume)), new TransferStatus());
65+
new SpectraWriteFeature(session), new Path(new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory, Path.Type.volume)), new TransferStatus());
6666
final PathAttributes attributes = new SpectraAttributesFinderFeature(session).find(container);
6767
assertEquals(-1L, attributes.getSize());
6868
assertNull(attributes.getRegion());
@@ -81,8 +81,8 @@ public void testFindNotFound() throws Exception {
8181
@Test
8282
public void testFindPlaceholder() throws Exception {
8383
final Path container = new SpectraDirectoryFeature(session, new SpectraWriteFeature(session)).mkdir(
84-
new Path(new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory, Path.Type.volume)), new TransferStatus());
85-
final Path test = new SpectraDirectoryFeature(session, new SpectraWriteFeature(session)).mkdir(new Path(container, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)), new TransferStatus());
84+
new SpectraWriteFeature(session), new Path(new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory, Path.Type.volume)), new TransferStatus());
85+
final Path test = new SpectraDirectoryFeature(session, new SpectraWriteFeature(session)).mkdir(new SpectraWriteFeature(session), new Path(container, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)), new TransferStatus());
8686
final PathAttributes attributes = new SpectraAttributesFinderFeature(session).find(test);
8787
assertEquals(0L, attributes.getSize());
8888
assertEquals(Checksum.parse("d41d8cd98f00b204e9800998ecf8427e"), attributes.getChecksum());
@@ -94,21 +94,21 @@ public void testFindPlaceholder() throws Exception {
9494
@Test
9595
public void testReadTildeInKey() throws Exception {
9696
final Path container = new SpectraDirectoryFeature(session, new SpectraWriteFeature(session)).mkdir(
97-
new Path(new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory, Path.Type.volume)), new TransferStatus());
97+
new SpectraWriteFeature(session), new Path(new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory, Path.Type.volume)), new TransferStatus());
9898
container.attributes().setRegion("us-east-1");
9999
final Path file = new Path(container, String.format("%s~", new AlphanumericRandomStringService().random()), EnumSet.of(Path.Type.file));
100-
new SpectraTouchFeature(session).touch(file, new TransferStatus());
100+
new SpectraTouchFeature(session).touch(new SpectraWriteFeature(session), file, new TransferStatus());
101101
new SpectraAttributesFinderFeature(session).find(file);
102102
new SpectraDeleteFeature(session).delete(Collections.singletonList(container), new DisabledLoginCallback(), new Delete.DisabledCallback());
103103
}
104104

105105
@Test
106106
public void testReadAtSignInKey() throws Exception {
107107
final Path container = new SpectraDirectoryFeature(session, new SpectraWriteFeature(session)).mkdir(
108-
new Path(new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory, Path.Type.volume)), new TransferStatus());
108+
new SpectraWriteFeature(session), new Path(new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory, Path.Type.volume)), new TransferStatus());
109109
container.attributes().setRegion("us-east-1");
110110
final Path file = new Path(container, String.format("%s@", new AlphanumericRandomStringService().random()), EnumSet.of(Path.Type.file));
111-
new SpectraTouchFeature(session).touch(file, new TransferStatus());
111+
new SpectraTouchFeature(session).touch(new SpectraWriteFeature(session), file, new TransferStatus());
112112
new SpectraAttributesFinderFeature(session).find(file);
113113
new SpectraDeleteFeature(session).delete(Collections.singletonList(container), new DisabledLoginCallback(), new Delete.DisabledCallback());
114114
}

spectra/src/test/java/ch/cyberduck/core/spectra/SpectraBulkServiceTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public void testPreUploadSingleFile() throws Exception {
4949
final Map<TransferItem, TransferStatus> files = new HashMap<>();
5050
final TransferStatus status = new TransferStatus();
5151
final Path container = new SpectraDirectoryFeature(session, new SpectraWriteFeature(session)).mkdir(
52-
new Path(new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory, Path.Type.volume)), new TransferStatus());
52+
new SpectraWriteFeature(session), new Path(new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory, Path.Type.volume)), new TransferStatus());
5353
final Path file = new Path(container, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
5454
files.put(new TransferItem(file), status.setLength(1L));
5555
final SpectraBulkService bulk = new SpectraBulkService(session);
@@ -64,7 +64,7 @@ public void testPreUploadSingleFile() throws Exception {
6464
public void testPreUploadDirectoryFile() throws Exception {
6565
final Map<TransferItem, TransferStatus> files = new HashMap<>();
6666
final Path container = new SpectraDirectoryFeature(session, new SpectraWriteFeature(session)).mkdir(
67-
new Path(new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory, Path.Type.volume)), new TransferStatus());
67+
new SpectraWriteFeature(session), new Path(new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory, Path.Type.volume)), new TransferStatus());
6868
final Path directory = new Path(container, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory));
6969
final TransferStatus directoryStatus = new TransferStatus().setLength(0L);
7070
files.put(new TransferItem(directory), directoryStatus);
@@ -98,7 +98,7 @@ public void testPreUploadLargeFile() throws Exception {
9898
final Map<TransferItem, TransferStatus> files = new HashMap<>();
9999
final TransferStatus status = new TransferStatus();
100100
final Path container = new SpectraDirectoryFeature(session, new SpectraWriteFeature(session)).mkdir(
101-
new Path(new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory, Path.Type.volume)), new TransferStatus());
101+
new SpectraWriteFeature(session), new Path(new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory, Path.Type.volume)), new TransferStatus());
102102
final Path file = new Path(container, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
103103
files.put(new TransferItem(file),
104104
// 11GB
@@ -130,7 +130,7 @@ public void testPreUploadMultipleLargeFile() throws Exception {
130130
final Map<TransferItem, TransferStatus> files = new HashMap<>();
131131
final TransferStatus status = new TransferStatus();
132132
final Path container = new SpectraDirectoryFeature(session, new SpectraWriteFeature(session)).mkdir(
133-
new Path(new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory, Path.Type.volume)), new TransferStatus());
133+
new SpectraWriteFeature(session), new Path(new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory, Path.Type.volume)), new TransferStatus());
134134
files.put(new TransferItem(new Path(container, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file))),
135135
// 11GB
136136
status.setLength(118111600640L)

spectra/src/test/java/ch/cyberduck/core/spectra/SpectraDeleteFeatureTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public class SpectraDeleteFeatureTest extends AbstractSpectraTest {
3737
public void testDeleteContainer() throws Exception {
3838
final Path container = new Path(new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.volume, Path.Type.directory));
3939
container.attributes().setRegion("US");
40-
new SpectraDirectoryFeature(session, new SpectraWriteFeature(session)).mkdir(container, new TransferStatus());
40+
new SpectraDirectoryFeature(session, new SpectraWriteFeature(session)).mkdir(new SpectraWriteFeature(session), container, new TransferStatus());
4141
assertTrue(new SpectraFindFeature(session).find(container));
4242
new SpectraDeleteFeature(session).delete(Collections.singletonList(container), new DisabledLoginCallback(), new Delete.DisabledCallback());
4343
}

spectra/src/test/java/ch/cyberduck/core/spectra/SpectraDirectoryFeatureTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public class SpectraDirectoryFeatureTest extends AbstractSpectraTest {
3838
public void testCreateBucket() throws Exception {
3939
final SpectraDirectoryFeature feature = new SpectraDirectoryFeature(session, new SpectraWriteFeature(session));
4040
final Path test = new Path(new DefaultHomeFinderService(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory, Path.Type.volume));
41-
feature.mkdir(test, new TransferStatus());
41+
feature.mkdir(new SpectraWriteFeature(session), test, new TransferStatus());
4242
assertTrue(new SpectraFindFeature(session).find(test));
4343
new SpectraDeleteFeature(session).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback());
4444
}
@@ -48,9 +48,9 @@ public void testCreatePlaceholder() throws Exception {
4848
final String bucketname = new AlphanumericRandomStringService().random();
4949
final String name = new AlphanumericRandomStringService().random();
5050
final Path container = new SpectraDirectoryFeature(session, new SpectraWriteFeature(session)).mkdir(
51-
new Path(bucketname, EnumSet.of(Path.Type.directory, Path.Type.volume)), new TransferStatus());
51+
new SpectraWriteFeature(session), new Path(bucketname, EnumSet.of(Path.Type.directory, Path.Type.volume)), new TransferStatus());
5252
final Path test = new SpectraDirectoryFeature(session, new SpectraWriteFeature(session)).mkdir(
53-
new Path(container, name, EnumSet.of(Path.Type.directory)), new TransferStatus());
53+
new SpectraWriteFeature(session), new Path(container, name, EnumSet.of(Path.Type.directory)), new TransferStatus());
5454
assertTrue(new SpectraFindFeature(session).find(test));
5555
assertTrue(new DefaultFindFeature(session).find(test));
5656
new SpectraDeleteFeature(session).delete(Collections.singletonList(container), new DisabledLoginCallback(), new Delete.DisabledCallback());

spectra/src/test/java/ch/cyberduck/core/spectra/SpectraFindFeatureTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public class SpectraFindFeatureTest extends AbstractSpectraTest {
3737
@Test
3838
public void testFindNotFound() throws Exception {
3939
final Path container = new SpectraDirectoryFeature(session, new SpectraWriteFeature(session)).mkdir(
40-
new Path(new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory, Path.Type.volume)), new TransferStatus());
40+
new SpectraWriteFeature(session), new Path(new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory, Path.Type.volume)), new TransferStatus());
4141
final Path test = new Path(container, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
4242
final SpectraFindFeature f = new SpectraFindFeature(session);
4343
assertFalse(f.find(test));
@@ -53,7 +53,7 @@ public void testFindUnknownBucket() throws Exception {
5353
@Test
5454
public void testFindBucket() throws Exception {
5555
final Path container = new SpectraDirectoryFeature(session, new SpectraWriteFeature(session)).mkdir(
56-
new Path(new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory, Path.Type.volume)), new TransferStatus());
56+
new SpectraWriteFeature(session), new Path(new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory, Path.Type.volume)), new TransferStatus());
5757
assertTrue(new SpectraFindFeature(session).find(container));
5858
new SpectraDeleteFeature(session).delete(Collections.singletonList(container), new DisabledLoginCallback(), new Delete.DisabledCallback());
5959
}

spectra/src/test/java/ch/cyberduck/core/spectra/SpectraMultipleDeleteFeatureTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public class SpectraMultipleDeleteFeatureTest extends AbstractSpectraTest {
4343
@Test
4444
public void testDeleteFile() throws Exception {
4545
final Path container = new SpectraDirectoryFeature(session, new SpectraWriteFeature(session)).mkdir(
46-
new Path(new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory, Path.Type.volume)), new TransferStatus());
46+
new SpectraWriteFeature(session), new Path(new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory, Path.Type.volume)), new TransferStatus());
4747
final Path test = new Path(container, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
4848
final byte[] content = RandomUtils.nextBytes(1024);
4949
final HttpResponseOutputStream<StorageObject> out = new SpectraWriteFeature(session).write(test, new TransferStatus().setLength(content.length), new DisabledConnectionCallback());
@@ -58,9 +58,9 @@ public void testDeleteFile() throws Exception {
5858
@Test
5959
public void testDeletePlaceholder() throws Exception {
6060
final Path container = new SpectraDirectoryFeature(session, new SpectraWriteFeature(session)).mkdir(
61-
new Path(new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory, Path.Type.volume)), new TransferStatus());
61+
new SpectraWriteFeature(session), new Path(new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory, Path.Type.volume)), new TransferStatus());
6262
final Path test = new SpectraDirectoryFeature(session, new SpectraWriteFeature(session)).mkdir(
63-
new Path(container, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)), new TransferStatus());
63+
new SpectraWriteFeature(session), new Path(container, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)), new TransferStatus());
6464
assertTrue(new SpectraFindFeature(session).find(test));
6565
new SpectraDeleteFeature(session).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback());
6666
assertFalse(new SpectraFindFeature(session).find(test));

0 commit comments

Comments
 (0)