Skip to content

Commit 9e5b071

Browse files
committed
Require features on instantiation.
1 parent 386cde5 commit 9e5b071

Some content is hidden

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

51 files changed

+556
-539
lines changed

core/src/main/java/ch/cyberduck/core/profiles/ProfilesSynchronizeWorker.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
* GNU General Public License for more details.
1616
*/
1717

18-
import ch.cyberduck.core.DisabledProgressListener;
1918
import ch.cyberduck.core.Local;
2019
import ch.cyberduck.core.LocalFactory;
2120
import ch.cyberduck.core.ProtocolFactory;
@@ -55,7 +54,7 @@ public ProfilesSynchronizeWorker(final ProfilesFinder.Visitor visitor) {
5554
*/
5655
public ProfilesSynchronizeWorker(final ProtocolFactory registry, final ProfilesFinder.Visitor visitor) {
5756
this(registry, LocalFactory.get(SupportDirectoryFinderFactory.get().find(),
58-
PreferencesFactory.get().getProperty("profiles.folder.name")), visitor);
57+
PreferencesFactory.get().getProperty("profiles.folder.name")), visitor);
5958
}
6059

6160
public ProfilesSynchronizeWorker(final ProtocolFactory registry, final Local directory, final ProfilesFinder.Visitor visitor) {
@@ -127,6 +126,6 @@ public Set<ProfileDescription> run(final Session<?> session) throws BackgroundEx
127126
}
128127

129128
protected CompareFilter filter(final Session<?> session) {
130-
return new CompareFilter(new DisabledDownloadSymlinkResolver(), session, new DisabledProgressListener());
129+
return new CompareFilter(new DisabledDownloadSymlinkResolver(), session);
131130
}
132131
}

core/src/main/java/ch/cyberduck/core/profiles/RemoteProfilesFinder.java

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,13 @@
2020
import ch.cyberduck.core.DisabledListProgressListener;
2121
import ch.cyberduck.core.DisabledProgressListener;
2222
import ch.cyberduck.core.Filter;
23-
import ch.cyberduck.core.ListProgressListener;
2423
import ch.cyberduck.core.ListService;
2524
import ch.cyberduck.core.Local;
2625
import ch.cyberduck.core.Path;
2726
import ch.cyberduck.core.PathAttributes;
2827
import ch.cyberduck.core.ProtocolFactory;
2928
import ch.cyberduck.core.Session;
3029
import ch.cyberduck.core.exception.BackgroundException;
31-
import ch.cyberduck.core.features.AttributesFinder;
32-
import ch.cyberduck.core.features.Find;
3330
import ch.cyberduck.core.features.Read;
3431
import ch.cyberduck.core.local.TemporaryFileService;
3532
import ch.cyberduck.core.local.TemporaryFileServiceFactory;
@@ -66,7 +63,7 @@ public RemoteProfilesFinder(final Session<?> session) {
6663
}
6764

6865
public RemoteProfilesFinder(final ProtocolFactory protocols, final Session<?> session) {
69-
this(protocols, session, new CompareFilter(new DisabledDownloadSymlinkResolver(), session, new DisabledProgressListener()));
66+
this(protocols, session, new CompareFilter(new DisabledDownloadSymlinkResolver(), session));
7067
}
7168

7269
public RemoteProfilesFinder(final ProtocolFactory protocols, final Session<?> session, final TransferPathFilter comparison) {
@@ -87,20 +84,7 @@ public Set<ProfileDescription> find(final Visitor visitor) throws BackgroundExce
8784
protected Local initialize() throws ConcurrentException {
8885
try {
8986
final Local local = temp.create("profiles", file);
90-
final TransferPathFilter filter = comparison
91-
.withFinder(new Find() {
92-
@Override
93-
public boolean find(final Path file, final ListProgressListener listener) {
94-
return true;
95-
}
96-
})
97-
.withAttributes(new AttributesFinder() {
98-
@Override
99-
public PathAttributes find(final Path file, final ListProgressListener listener) {
100-
return file.attributes();
101-
}
102-
});
103-
if(filter.accept(file, local, new TransferStatus().exists(true))) {
87+
if(comparison.accept(file, local, new TransferStatus().exists(true), new DisabledProgressListener())) {
10488
final Read read = session.getFeature(Read.class);
10589
log.info("Download profile {}", file);
10690
// Read latest version

core/src/main/java/ch/cyberduck/core/synchronization/CachingComparePathFilter.java

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,21 @@
2222
import ch.cyberduck.core.Path;
2323
import ch.cyberduck.core.ProgressListener;
2424
import ch.cyberduck.core.exception.BackgroundException;
25-
import ch.cyberduck.core.features.AttributesFinder;
26-
import ch.cyberduck.core.features.Find;
2725
import ch.cyberduck.core.transfer.TransferItem;
2826

2927
import org.apache.logging.log4j.LogManager;
3028
import org.apache.logging.log4j.Logger;
3129

32-
import java.util.Collections;
3330
import java.util.Map;
3431

3532
public class CachingComparePathFilter implements ComparePathFilter {
3633
private static final Logger log = LogManager.getLogger(CachingComparePathFilter.class);
3734

38-
private Map<TransferItem, Comparison> cache = Collections.emptyMap();
39-
35+
private final Map<TransferItem, Comparison> cache;
4036
private final DefaultComparePathFilter delegate;
4137

42-
public CachingComparePathFilter(final DefaultComparePathFilter delegate) {
38+
public CachingComparePathFilter(final Map<TransferItem, Comparison> cache, final DefaultComparePathFilter delegate) {
39+
this.cache = cache;
4340
this.delegate = delegate;
4441
}
4542

@@ -60,26 +57,4 @@ public Comparison get(final TransferItem item) {
6057
}
6158
return Comparison.unknown;
6259
}
63-
64-
public void reset() {
65-
cache.clear();
66-
}
67-
68-
@Override
69-
public CachingComparePathFilter withFinder(final Find finder) {
70-
delegate.withFinder(finder);
71-
return this;
72-
}
73-
74-
@Override
75-
public CachingComparePathFilter withAttributes(final AttributesFinder attribute) {
76-
delegate.withAttributes(attribute);
77-
return this;
78-
}
79-
80-
@Override
81-
public CachingComparePathFilter withCache(final Map<TransferItem, Comparison> cache) {
82-
this.cache = cache;
83-
return this;
84-
}
8560
}

core/src/main/java/ch/cyberduck/core/synchronization/ComparePathFilter.java

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,7 @@
2121
import ch.cyberduck.core.Path;
2222
import ch.cyberduck.core.ProgressListener;
2323
import ch.cyberduck.core.exception.BackgroundException;
24-
import ch.cyberduck.core.features.AttributesFinder;
25-
import ch.cyberduck.core.features.Find;
26-
import ch.cyberduck.core.transfer.TransferItem;
27-
28-
import java.util.Map;
2924

3025
public interface ComparePathFilter {
3126
Comparison compare(Path file, Local local, ProgressListener listener) throws BackgroundException;
32-
33-
default ComparePathFilter withFinder(Find finder) {
34-
return this;
35-
}
36-
37-
default ComparePathFilter withAttributes(AttributesFinder attribute) {
38-
return this;
39-
}
40-
41-
default ComparePathFilter withCache(Map<TransferItem, Comparison> cache) {
42-
return this;
43-
}
4427
}

core/src/main/java/ch/cyberduck/core/synchronization/DefaultComparePathFilter.java

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -30,46 +30,32 @@
3030
import ch.cyberduck.core.io.Checksum;
3131
import ch.cyberduck.core.io.ChecksumComputeFactory;
3232
import ch.cyberduck.core.io.HashAlgorithm;
33-
import ch.cyberduck.core.shared.DefaultAttributesFinderFeature;
34-
import ch.cyberduck.core.shared.DefaultFindFeature;
35-
import ch.cyberduck.core.transfer.TransferItem;
3633
import ch.cyberduck.core.transfer.TransferStatus;
3734

3835
import org.apache.logging.log4j.LogManager;
3936
import org.apache.logging.log4j.Logger;
4037

4138
import java.text.MessageFormat;
42-
import java.util.Map;
4339

4440
public class DefaultComparePathFilter implements ComparePathFilter {
4541
private static final Logger log = LogManager.getLogger(DefaultComparePathFilter.class);
4642

47-
private Find finder;
48-
private AttributesFinder attribute;
49-
43+
private final Find finder;
44+
private final AttributesFinder attribute;
5045
private final ComparisonService comparison;
5146

5247
public DefaultComparePathFilter(final Session<?> session) {
53-
this.finder = session.getFeature(Find.class, new DefaultFindFeature(session));
54-
this.attribute = session.getFeature(AttributesFinder.class, new DefaultAttributesFinderFeature(session));
55-
this.comparison = session.getFeature(ComparisonService.class);
48+
this(session, session.getFeature(Find.class), session.getFeature(AttributesFinder.class));
5649
}
5750

58-
@Override
59-
public ComparePathFilter withFinder(final Find finder) {
60-
this.finder = finder;
61-
return this;
51+
public DefaultComparePathFilter(final Session<?> session, final Find finder, final AttributesFinder attribute) {
52+
this(finder, attribute, session.getFeature(ComparisonService.class));
6253
}
6354

64-
@Override
65-
public ComparePathFilter withAttributes(final AttributesFinder attribute) {
55+
public DefaultComparePathFilter(final Find finder, final AttributesFinder attribute, final ComparisonService comparison) {
56+
this.finder = finder;
6657
this.attribute = attribute;
67-
return this;
68-
}
69-
70-
@Override
71-
public ComparePathFilter withCache(final Map<TransferItem, Comparison> cache) {
72-
return this;
58+
this.comparison = comparison;
7359
}
7460

7561
@Override

core/src/main/java/ch/cyberduck/core/threading/QuicklookTransferBackgroundAction.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,17 @@ public TransferAction action(final Session<?> source, final Session<?> destinati
8888
public AbstractDownloadFilter filter(final Session<?> source, final Session<?> destination, final TransferAction action, final ProgressListener listener) {
8989
final DownloadFilterOptions options = new DownloadFilterOptions(session.getHost());
9090
options.segments = false;
91-
return new CompareFilter(new DisabledDownloadSymlinkResolver(), source, options, listener, new DefaultComparePathFilter(source) {
91+
return new CompareFilter(new DisabledDownloadSymlinkResolver(), source, new Find() {
92+
@Override
93+
public boolean find(final Path file, final ListProgressListener listener) {
94+
return true;
95+
}
96+
}, new AttributesFinder() {
97+
@Override
98+
public PathAttributes find(final Path file, final ListProgressListener listener) {
99+
return file.attributes();
100+
}
101+
}, new DefaultComparePathFilter(source) {
92102
@Override
93103
public Comparison compare(final Path file, final Local local, final ProgressListener listener) throws BackgroundException {
94104
switch(super.compare(file, local, listener)) {
@@ -98,17 +108,7 @@ public Comparison compare(final Path file, final Local local, final ProgressList
98108
// Comparison may return local when no checksum to compare is avavailable
99109
return Comparison.remote;
100110
}
101-
}).withFinder(new Find() {
102-
@Override
103-
public boolean find(final Path file, final ListProgressListener listener) {
104-
return true;
105-
}
106-
}).withAttributes(new AttributesFinder() {
107-
@Override
108-
public PathAttributes find(final Path file, final ListProgressListener listener) {
109-
return file.attributes();
110-
}
111-
});
111+
}, options);
112112
}
113113
};
114114
}

core/src/main/java/ch/cyberduck/core/transfer/CopyTransfer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,9 @@ public TransferPathFilter filter(final Session<?> source, final Session<?> desti
175175
final AttributesFinder attributes = new CachingAttributesFinderFeature(destination, cache,
176176
destination.getFeature(AttributesFinder.class, new DefaultAttributesFinderFeature(destination)));
177177
if(action.equals(TransferAction.comparison)) {
178-
return new ChecksumFilter(source, destination, mapping).withFinder(find).withAttributes(attributes);
178+
return new ChecksumFilter(source, destination, mapping, find, attributes);
179179
}
180-
return new OverwriteFilter(source, destination, mapping).withFinder(find).withAttributes(attributes);
180+
return new OverwriteFilter(source, destination, mapping, find, attributes);
181181
}
182182

183183
@Override

core/src/main/java/ch/cyberduck/core/transfer/DownloadTransfer.java

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import ch.cyberduck.core.features.AttributesFinder;
2525
import ch.cyberduck.core.features.Bulk;
2626
import ch.cyberduck.core.features.Download;
27-
import ch.cyberduck.core.features.Find;
2827
import ch.cyberduck.core.filter.DownloadDuplicateFilter;
2928
import ch.cyberduck.core.filter.DownloadRegexFilter;
3029
import ch.cyberduck.core.io.BandwidthThrottle;
@@ -34,7 +33,6 @@
3433
import ch.cyberduck.core.local.features.Symlink;
3534
import ch.cyberduck.core.preferences.PreferencesFactory;
3635
import ch.cyberduck.core.shared.DefaultAttributesFinderFeature;
37-
import ch.cyberduck.core.shared.DefaultFindFeature;
3836
import ch.cyberduck.core.transfer.download.AbstractDownloadFilter;
3937
import ch.cyberduck.core.transfer.download.CompareFilter;
4038
import ch.cyberduck.core.transfer.download.DownloadFilterOptions;
@@ -144,36 +142,33 @@ && new DownloadSymlinkResolver(roots).resolve(directory)) {
144142
public AbstractDownloadFilter filter(final Session<?> source, final Session<?> destination, final TransferAction action, final ProgressListener listener) {
145143
log.debug("Filter transfer with action {} and options {}", action, options);
146144
final DownloadSymlinkResolver resolver = new DownloadSymlinkResolver(roots);
147-
final Find find;
148145
final AttributesFinder attributes;
149146
if(roots.size() > 1 || roots.stream().filter(item -> item.remote.isDirectory()).findAny().isPresent()) {
150-
find = new CachingFindFeature(source, cache, source.getFeature(Find.class, new DefaultFindFeature(source)));
151147
attributes = new CachingAttributesFinderFeature(source, cache, source.getFeature(AttributesFinder.class, new DefaultAttributesFinderFeature(source)));
152148
}
153149
else {
154-
find = new CachingFindFeature(source, cache, source.getFeature(Find.class));
155150
attributes = new CachingAttributesFinderFeature(source, cache, source.getFeature(AttributesFinder.class));
156151
}
157-
log.debug("Determined features {} and {}", find, attributes);
152+
log.debug("Determined feature {}", attributes);
158153
if(action.equals(TransferAction.resume)) {
159-
return new ResumeFilter(resolver, source, options).withFinder(find).withAttributes(attributes);
154+
return new ResumeFilter(resolver, source, attributes, options);
160155
}
161156
if(action.equals(TransferAction.rename)) {
162-
return new RenameFilter(resolver, source, options).withFinder(find).withAttributes(attributes);
157+
return new RenameFilter(resolver, source, attributes, options);
163158
}
164159
if(action.equals(TransferAction.renameexisting)) {
165-
return new RenameExistingFilter(resolver, source, options).withFinder(find).withAttributes(attributes);
160+
return new RenameExistingFilter(resolver, source, attributes, options);
166161
}
167162
if(action.equals(TransferAction.skip)) {
168-
return new SkipFilter(resolver, source, options).withFinder(find).withAttributes(attributes);
163+
return new SkipFilter(resolver, source, attributes, options);
169164
}
170165
if(action.equals(TransferAction.trash)) {
171-
return new TrashFilter(resolver, source, options).withFinder(find).withAttributes(attributes);
166+
return new TrashFilter(resolver, source, attributes, options);
172167
}
173168
if(action.equals(TransferAction.comparison)) {
174-
return new CompareFilter(resolver, source, options, listener).withFinder(find).withAttributes(attributes);
169+
return new CompareFilter(resolver, source, options);
175170
}
176-
return new OverwriteFilter(resolver, source, options).withFinder(find).withAttributes(attributes);
171+
return new OverwriteFilter(resolver, source, attributes, options);
177172
}
178173

179174
@Override

core/src/main/java/ch/cyberduck/core/transfer/SyncTransfer.java

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -76,18 +76,18 @@ public class SyncTransfer extends Transfer {
7676
private TransferAction action;
7777

7878
private Cache<Path> cache
79-
= new PathCache(PreferencesFactory.get().getInteger("transfer.cache.size"));
79+
= new PathCache(PreferencesFactory.get().getInteger("transfer.cache.size"));
8080

8181
private final Map<TransferItem, Comparison> comparisons = Collections.synchronizedMap(new LRUMap<>(
82-
PreferencesFactory.get().getInteger("transfer.cache.size")));
82+
PreferencesFactory.get().getInteger("transfer.cache.size")));
8383

8484
public SyncTransfer(final Host host, final TransferItem item) {
8585
this(host, item, TransferAction.callback);
8686
}
8787

8888
public SyncTransfer(final Host host, final TransferItem item, final TransferAction action) {
8989
super(host, Collections.singletonList(item),
90-
new BandwidthThrottle(PreferencesFactory.get().getFloat("queue.upload.bandwidth.bytes")));
90+
new BandwidthThrottle(PreferencesFactory.get().getFloat("queue.upload.bandwidth.bytes")));
9191
this.upload = new UploadTransfer(host, roots).withCache(cache);
9292
this.download = new DownloadTransfer(host, roots).withCache(cache);
9393
this.item = item;
@@ -136,7 +136,7 @@ public void setBandwidth(float bytesPerSecond) {
136136
@Override
137137
public String getName() {
138138
return this.getRoot().remote.getName()
139-
+ " \u2194 " /*left-right arrow*/ + this.getRoot().local.getName();
139+
+ " \u2194 " /*left-right arrow*/ + this.getRoot().local.getName();
140140
}
141141

142142
@Override
@@ -149,22 +149,15 @@ public Long getTransferred() {
149149
public TransferPathFilter filter(final Session<?> source, final Session<?> destination, final TransferAction action, final ProgressListener listener) {
150150
log.debug("Filter transfer with action {}", action);
151151
final Find find = new CachingFindFeature(source, cache,
152-
source.getFeature(Find.class, new DefaultFindFeature(source)));
152+
source.getFeature(Find.class, new DefaultFindFeature(source)));
153153
final AttributesFinder attributes = new CachingAttributesFinderFeature(source, cache,
154-
source.getFeature(AttributesFinder.class, new DefaultAttributesFinderFeature(source)));
154+
source.getFeature(AttributesFinder.class, new DefaultAttributesFinderFeature(source)));
155155
// Set chosen action (upload, download, mirror) from prompt
156-
comparison = new CachingComparePathFilter(new DefaultComparePathFilter(source))
157-
.withCache(comparisons)
158-
.withAttributes(attributes)
159-
.withFinder(find);
156+
comparison = new CachingComparePathFilter(comparisons, new DefaultComparePathFilter(source, find, attributes));
160157
return new SynchronizationPathFilter(comparison,
161-
download.filter(source, destination, TransferAction.overwrite, listener)
162-
.withAttributes(attributes)
163-
.withFinder(find),
164-
upload.filter(source, destination, TransferAction.overwrite, listener)
165-
.withAttributes(attributes)
166-
.withFinder(find),
167-
action
158+
download.filter(source, destination, TransferAction.overwrite, listener),
159+
upload.filter(source, destination, TransferAction.overwrite, listener),
160+
action
168161
);
169162
}
170163

0 commit comments

Comments
 (0)