diff --git a/core/src/main/java/ch/cyberduck/core/editor/EditSaveWorker.java b/core/src/main/java/ch/cyberduck/core/editor/EditSaveWorker.java index 985e210e730..155dccf48b5 100644 --- a/core/src/main/java/ch/cyberduck/core/editor/EditSaveWorker.java +++ b/core/src/main/java/ch/cyberduck/core/editor/EditSaveWorker.java @@ -38,7 +38,6 @@ import ch.cyberduck.core.transfer.TransferPrompt; import ch.cyberduck.core.transfer.TransferSpeedometer; import ch.cyberduck.core.transfer.UploadTransfer; -import ch.cyberduck.core.transfer.upload.AbstractUploadFilter; import ch.cyberduck.core.transfer.upload.UploadFilterOptions; import ch.cyberduck.core.worker.SingleTransferWorker; import ch.cyberduck.core.worker.Worker; @@ -73,14 +72,9 @@ public TransferAction action(final Session source, final TransferPrompt prompt, final ListProgressListener listener) { return TransferAction.overwrite; } - - @Override - public AbstractUploadFilter filter(final Session session, final Session destination, final TransferAction action, final ProgressListener listener) { - return super.filter(session, destination, action, listener).withOptions(new UploadFilterOptions(host) - .withVersioning(PreferencesFactory.get().getBoolean("editor.upload.file.versioning")) - .withPermission(PreferencesFactory.get().getBoolean("editor.upload.permissions.change"))); - } - }; + }.withOptions(new UploadFilterOptions(bookmark) + .withVersioning(PreferencesFactory.get().getBoolean("editor.upload.file.versioning")) + .withPermission(PreferencesFactory.get().getBoolean("editor.upload.permissions.change"))); this.listener = listener; } diff --git a/core/src/main/java/ch/cyberduck/core/features/UnixPermission.java b/core/src/main/java/ch/cyberduck/core/features/UnixPermission.java index 0ef7c0d9f23..fd5fb6b2db9 100644 --- a/core/src/main/java/ch/cyberduck/core/features/UnixPermission.java +++ b/core/src/main/java/ch/cyberduck/core/features/UnixPermission.java @@ -15,7 +15,6 @@ * GNU General Public License for more details. */ -import ch.cyberduck.core.Local; import ch.cyberduck.core.Path; import ch.cyberduck.core.Permission; import ch.cyberduck.core.exception.BackgroundException; @@ -57,18 +56,4 @@ default Permission getDefault(final EnumSet type) { } return Permission.EMPTY; } - - /** - * @param file File on local disk - * @return Default mask to set for file - */ - default Permission getDefault(final Local file) { - if(preferences.getBoolean("queue.upload.permissions.default")) { - return this.getDefault(file.getType()); - } - else { - // Read permissions from local file - return file.attributes().getPermission(); - } - } } diff --git a/core/src/main/java/ch/cyberduck/core/profiles/ProfilesSynchronizeWorker.java b/core/src/main/java/ch/cyberduck/core/profiles/ProfilesSynchronizeWorker.java index 886490f7bdc..e3044308b45 100644 --- a/core/src/main/java/ch/cyberduck/core/profiles/ProfilesSynchronizeWorker.java +++ b/core/src/main/java/ch/cyberduck/core/profiles/ProfilesSynchronizeWorker.java @@ -15,7 +15,6 @@ * GNU General Public License for more details. */ -import ch.cyberduck.core.DisabledProgressListener; import ch.cyberduck.core.Local; import ch.cyberduck.core.LocalFactory; import ch.cyberduck.core.ProtocolFactory; @@ -55,7 +54,7 @@ public ProfilesSynchronizeWorker(final ProfilesFinder.Visitor visitor) { */ public ProfilesSynchronizeWorker(final ProtocolFactory registry, final ProfilesFinder.Visitor visitor) { this(registry, LocalFactory.get(SupportDirectoryFinderFactory.get().find(), - PreferencesFactory.get().getProperty("profiles.folder.name")), visitor); + PreferencesFactory.get().getProperty("profiles.folder.name")), visitor); } public ProfilesSynchronizeWorker(final ProtocolFactory registry, final Local directory, final ProfilesFinder.Visitor visitor) { @@ -127,6 +126,6 @@ public Set run(final Session session) throws BackgroundEx } protected CompareFilter filter(final Session session) { - return new CompareFilter(new DisabledDownloadSymlinkResolver(), session, new DisabledProgressListener()); + return new CompareFilter(new DisabledDownloadSymlinkResolver(), session); } } diff --git a/core/src/main/java/ch/cyberduck/core/profiles/RemoteProfilesFinder.java b/core/src/main/java/ch/cyberduck/core/profiles/RemoteProfilesFinder.java index 8012f93f228..728fe5dcd61 100644 --- a/core/src/main/java/ch/cyberduck/core/profiles/RemoteProfilesFinder.java +++ b/core/src/main/java/ch/cyberduck/core/profiles/RemoteProfilesFinder.java @@ -20,7 +20,6 @@ import ch.cyberduck.core.DisabledListProgressListener; import ch.cyberduck.core.DisabledProgressListener; import ch.cyberduck.core.Filter; -import ch.cyberduck.core.ListProgressListener; import ch.cyberduck.core.ListService; import ch.cyberduck.core.Local; import ch.cyberduck.core.Path; @@ -28,8 +27,6 @@ import ch.cyberduck.core.ProtocolFactory; import ch.cyberduck.core.Session; import ch.cyberduck.core.exception.BackgroundException; -import ch.cyberduck.core.features.AttributesFinder; -import ch.cyberduck.core.features.Find; import ch.cyberduck.core.features.Read; import ch.cyberduck.core.local.TemporaryFileService; import ch.cyberduck.core.local.TemporaryFileServiceFactory; @@ -66,7 +63,7 @@ public RemoteProfilesFinder(final Session session) { } public RemoteProfilesFinder(final ProtocolFactory protocols, final Session session) { - this(protocols, session, new CompareFilter(new DisabledDownloadSymlinkResolver(), session, new DisabledProgressListener())); + this(protocols, session, new CompareFilter(new DisabledDownloadSymlinkResolver(), session)); } public RemoteProfilesFinder(final ProtocolFactory protocols, final Session session, final TransferPathFilter comparison) { @@ -87,20 +84,7 @@ public Set find(final Visitor visitor) throws BackgroundExce protected Local initialize() throws ConcurrentException { try { final Local local = temp.create("profiles", file); - final TransferPathFilter filter = comparison - .withFinder(new Find() { - @Override - public boolean find(final Path file, final ListProgressListener listener) { - return true; - } - }) - .withAttributes(new AttributesFinder() { - @Override - public PathAttributes find(final Path file, final ListProgressListener listener) { - return file.attributes(); - } - }); - if(filter.accept(file, local, new TransferStatus().exists(true))) { + if(comparison.accept(file, local, new TransferStatus().exists(true), new DisabledProgressListener())) { final Read read = session.getFeature(Read.class); log.info("Download profile {}", file); // Read latest version diff --git a/core/src/main/java/ch/cyberduck/core/synchronization/CachingComparePathFilter.java b/core/src/main/java/ch/cyberduck/core/synchronization/CachingComparePathFilter.java index a44df2bd51f..fb0512c940f 100644 --- a/core/src/main/java/ch/cyberduck/core/synchronization/CachingComparePathFilter.java +++ b/core/src/main/java/ch/cyberduck/core/synchronization/CachingComparePathFilter.java @@ -22,24 +22,21 @@ import ch.cyberduck.core.Path; import ch.cyberduck.core.ProgressListener; import ch.cyberduck.core.exception.BackgroundException; -import ch.cyberduck.core.features.AttributesFinder; -import ch.cyberduck.core.features.Find; import ch.cyberduck.core.transfer.TransferItem; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import java.util.Collections; import java.util.Map; public class CachingComparePathFilter implements ComparePathFilter { private static final Logger log = LogManager.getLogger(CachingComparePathFilter.class); - private Map cache = Collections.emptyMap(); - + private final Map cache; private final DefaultComparePathFilter delegate; - public CachingComparePathFilter(final DefaultComparePathFilter delegate) { + public CachingComparePathFilter(final Map cache, final DefaultComparePathFilter delegate) { + this.cache = cache; this.delegate = delegate; } @@ -60,26 +57,4 @@ public Comparison get(final TransferItem item) { } return Comparison.unknown; } - - public void reset() { - cache.clear(); - } - - @Override - public CachingComparePathFilter withFinder(final Find finder) { - delegate.withFinder(finder); - return this; - } - - @Override - public CachingComparePathFilter withAttributes(final AttributesFinder attribute) { - delegate.withAttributes(attribute); - return this; - } - - @Override - public CachingComparePathFilter withCache(final Map cache) { - this.cache = cache; - return this; - } } diff --git a/core/src/main/java/ch/cyberduck/core/synchronization/ComparePathFilter.java b/core/src/main/java/ch/cyberduck/core/synchronization/ComparePathFilter.java index b091899a90d..d8f36281b54 100644 --- a/core/src/main/java/ch/cyberduck/core/synchronization/ComparePathFilter.java +++ b/core/src/main/java/ch/cyberduck/core/synchronization/ComparePathFilter.java @@ -21,24 +21,7 @@ import ch.cyberduck.core.Path; import ch.cyberduck.core.ProgressListener; import ch.cyberduck.core.exception.BackgroundException; -import ch.cyberduck.core.features.AttributesFinder; -import ch.cyberduck.core.features.Find; -import ch.cyberduck.core.transfer.TransferItem; - -import java.util.Map; public interface ComparePathFilter { Comparison compare(Path file, Local local, ProgressListener listener) throws BackgroundException; - - default ComparePathFilter withFinder(Find finder) { - return this; - } - - default ComparePathFilter withAttributes(AttributesFinder attribute) { - return this; - } - - default ComparePathFilter withCache(Map cache) { - return this; - } } diff --git a/core/src/main/java/ch/cyberduck/core/synchronization/DefaultComparePathFilter.java b/core/src/main/java/ch/cyberduck/core/synchronization/DefaultComparePathFilter.java index f5f7189986d..3157645c008 100644 --- a/core/src/main/java/ch/cyberduck/core/synchronization/DefaultComparePathFilter.java +++ b/core/src/main/java/ch/cyberduck/core/synchronization/DefaultComparePathFilter.java @@ -30,46 +30,32 @@ import ch.cyberduck.core.io.Checksum; import ch.cyberduck.core.io.ChecksumComputeFactory; import ch.cyberduck.core.io.HashAlgorithm; -import ch.cyberduck.core.shared.DefaultAttributesFinderFeature; -import ch.cyberduck.core.shared.DefaultFindFeature; -import ch.cyberduck.core.transfer.TransferItem; import ch.cyberduck.core.transfer.TransferStatus; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import java.text.MessageFormat; -import java.util.Map; public class DefaultComparePathFilter implements ComparePathFilter { private static final Logger log = LogManager.getLogger(DefaultComparePathFilter.class); - private Find finder; - private AttributesFinder attribute; - + private final Find finder; + private final AttributesFinder attribute; private final ComparisonService comparison; public DefaultComparePathFilter(final Session session) { - this.finder = session.getFeature(Find.class, new DefaultFindFeature(session)); - this.attribute = session.getFeature(AttributesFinder.class, new DefaultAttributesFinderFeature(session)); - this.comparison = session.getFeature(ComparisonService.class); + this(session, session.getFeature(Find.class), session.getFeature(AttributesFinder.class)); } - @Override - public ComparePathFilter withFinder(final Find finder) { - this.finder = finder; - return this; + public DefaultComparePathFilter(final Session session, final Find finder, final AttributesFinder attribute) { + this(finder, attribute, session.getFeature(ComparisonService.class)); } - @Override - public ComparePathFilter withAttributes(final AttributesFinder attribute) { + public DefaultComparePathFilter(final Find finder, final AttributesFinder attribute, final ComparisonService comparison) { + this.finder = finder; this.attribute = attribute; - return this; - } - - @Override - public ComparePathFilter withCache(final Map cache) { - return this; + this.comparison = comparison; } @Override diff --git a/core/src/main/java/ch/cyberduck/core/threading/QuicklookTransferBackgroundAction.java b/core/src/main/java/ch/cyberduck/core/threading/QuicklookTransferBackgroundAction.java index 29d9c36b731..c6f67ec0831 100644 --- a/core/src/main/java/ch/cyberduck/core/threading/QuicklookTransferBackgroundAction.java +++ b/core/src/main/java/ch/cyberduck/core/threading/QuicklookTransferBackgroundAction.java @@ -88,7 +88,17 @@ public TransferAction action(final Session source, final Session destinati public AbstractDownloadFilter filter(final Session source, final Session destination, final TransferAction action, final ProgressListener listener) { final DownloadFilterOptions options = new DownloadFilterOptions(session.getHost()); options.segments = false; - return new CompareFilter(new DisabledDownloadSymlinkResolver(), source, options, listener, new DefaultComparePathFilter(source) { + return new CompareFilter(new DisabledDownloadSymlinkResolver(), source, new Find() { + @Override + public boolean find(final Path file, final ListProgressListener listener) { + return true; + } + }, new AttributesFinder() { + @Override + public PathAttributes find(final Path file, final ListProgressListener listener) { + return file.attributes(); + } + }, new DefaultComparePathFilter(source) { @Override public Comparison compare(final Path file, final Local local, final ProgressListener listener) throws BackgroundException { switch(super.compare(file, local, listener)) { @@ -98,17 +108,7 @@ public Comparison compare(final Path file, final Local local, final ProgressList // Comparison may return local when no checksum to compare is avavailable return Comparison.remote; } - }).withFinder(new Find() { - @Override - public boolean find(final Path file, final ListProgressListener listener) { - return true; - } - }).withAttributes(new AttributesFinder() { - @Override - public PathAttributes find(final Path file, final ListProgressListener listener) { - return file.attributes(); - } - }); + }, options); } }; } diff --git a/core/src/main/java/ch/cyberduck/core/transfer/CopyTransfer.java b/core/src/main/java/ch/cyberduck/core/transfer/CopyTransfer.java index c6f083f63a8..a25a2aea8d7 100644 --- a/core/src/main/java/ch/cyberduck/core/transfer/CopyTransfer.java +++ b/core/src/main/java/ch/cyberduck/core/transfer/CopyTransfer.java @@ -175,9 +175,9 @@ public TransferPathFilter filter(final Session source, final Session desti final AttributesFinder attributes = new CachingAttributesFinderFeature(destination, cache, destination.getFeature(AttributesFinder.class, new DefaultAttributesFinderFeature(destination))); if(action.equals(TransferAction.comparison)) { - return new ChecksumFilter(source, destination, mapping).withFinder(find).withAttributes(attributes); + return new ChecksumFilter(source, destination, mapping, find, attributes); } - return new OverwriteFilter(source, destination, mapping).withFinder(find).withAttributes(attributes); + return new OverwriteFilter(source, destination, mapping, find, attributes); } @Override diff --git a/core/src/main/java/ch/cyberduck/core/transfer/DownloadTransfer.java b/core/src/main/java/ch/cyberduck/core/transfer/DownloadTransfer.java index 82d240edcf9..aa48093cdbc 100644 --- a/core/src/main/java/ch/cyberduck/core/transfer/DownloadTransfer.java +++ b/core/src/main/java/ch/cyberduck/core/transfer/DownloadTransfer.java @@ -24,7 +24,6 @@ import ch.cyberduck.core.features.AttributesFinder; import ch.cyberduck.core.features.Bulk; import ch.cyberduck.core.features.Download; -import ch.cyberduck.core.features.Find; import ch.cyberduck.core.filter.DownloadDuplicateFilter; import ch.cyberduck.core.filter.DownloadRegexFilter; import ch.cyberduck.core.io.BandwidthThrottle; @@ -34,7 +33,6 @@ import ch.cyberduck.core.local.features.Symlink; import ch.cyberduck.core.preferences.PreferencesFactory; import ch.cyberduck.core.shared.DefaultAttributesFinderFeature; -import ch.cyberduck.core.shared.DefaultFindFeature; import ch.cyberduck.core.transfer.download.AbstractDownloadFilter; import ch.cyberduck.core.transfer.download.CompareFilter; import ch.cyberduck.core.transfer.download.DownloadFilterOptions; @@ -144,36 +142,33 @@ && new DownloadSymlinkResolver(roots).resolve(directory)) { public AbstractDownloadFilter filter(final Session source, final Session destination, final TransferAction action, final ProgressListener listener) { log.debug("Filter transfer with action {} and options {}", action, options); final DownloadSymlinkResolver resolver = new DownloadSymlinkResolver(roots); - final Find find; final AttributesFinder attributes; if(roots.size() > 1 || roots.stream().filter(item -> item.remote.isDirectory()).findAny().isPresent()) { - find = new CachingFindFeature(source, cache, source.getFeature(Find.class, new DefaultFindFeature(source))); attributes = new CachingAttributesFinderFeature(source, cache, source.getFeature(AttributesFinder.class, new DefaultAttributesFinderFeature(source))); } else { - find = new CachingFindFeature(source, cache, source.getFeature(Find.class)); attributes = new CachingAttributesFinderFeature(source, cache, source.getFeature(AttributesFinder.class)); } - log.debug("Determined features {} and {}", find, attributes); + log.debug("Determined feature {}", attributes); if(action.equals(TransferAction.resume)) { - return new ResumeFilter(resolver, source, options).withFinder(find).withAttributes(attributes); + return new ResumeFilter(resolver, source, attributes, options); } if(action.equals(TransferAction.rename)) { - return new RenameFilter(resolver, source, options).withFinder(find).withAttributes(attributes); + return new RenameFilter(resolver, source, attributes, options); } if(action.equals(TransferAction.renameexisting)) { - return new RenameExistingFilter(resolver, source, options).withFinder(find).withAttributes(attributes); + return new RenameExistingFilter(resolver, source, attributes, options); } if(action.equals(TransferAction.skip)) { - return new SkipFilter(resolver, source, options).withFinder(find).withAttributes(attributes); + return new SkipFilter(resolver, source, attributes, options); } if(action.equals(TransferAction.trash)) { - return new TrashFilter(resolver, source, options).withFinder(find).withAttributes(attributes); + return new TrashFilter(resolver, source, attributes, options); } if(action.equals(TransferAction.comparison)) { - return new CompareFilter(resolver, source, options, listener).withFinder(find).withAttributes(attributes); + return new CompareFilter(resolver, source, options); } - return new OverwriteFilter(resolver, source, options).withFinder(find).withAttributes(attributes); + return new OverwriteFilter(resolver, source, attributes, options); } @Override diff --git a/core/src/main/java/ch/cyberduck/core/transfer/SyncTransfer.java b/core/src/main/java/ch/cyberduck/core/transfer/SyncTransfer.java index 5cd66d3c992..cf1e8b5a56d 100644 --- a/core/src/main/java/ch/cyberduck/core/transfer/SyncTransfer.java +++ b/core/src/main/java/ch/cyberduck/core/transfer/SyncTransfer.java @@ -76,10 +76,10 @@ public class SyncTransfer extends Transfer { private TransferAction action; private Cache cache - = new PathCache(PreferencesFactory.get().getInteger("transfer.cache.size")); + = new PathCache(PreferencesFactory.get().getInteger("transfer.cache.size")); private final Map comparisons = Collections.synchronizedMap(new LRUMap<>( - PreferencesFactory.get().getInteger("transfer.cache.size"))); + PreferencesFactory.get().getInteger("transfer.cache.size"))); public SyncTransfer(final Host host, final TransferItem item) { this(host, item, TransferAction.callback); @@ -87,7 +87,7 @@ public SyncTransfer(final Host host, final TransferItem item) { public SyncTransfer(final Host host, final TransferItem item, final TransferAction action) { super(host, Collections.singletonList(item), - new BandwidthThrottle(PreferencesFactory.get().getFloat("queue.upload.bandwidth.bytes"))); + new BandwidthThrottle(PreferencesFactory.get().getFloat("queue.upload.bandwidth.bytes"))); this.upload = new UploadTransfer(host, roots).withCache(cache); this.download = new DownloadTransfer(host, roots).withCache(cache); this.item = item; @@ -136,7 +136,7 @@ public void setBandwidth(float bytesPerSecond) { @Override public String getName() { return this.getRoot().remote.getName() - + " \u2194 " /*left-right arrow*/ + this.getRoot().local.getName(); + + " \u2194 " /*left-right arrow*/ + this.getRoot().local.getName(); } @Override @@ -149,22 +149,15 @@ public Long getTransferred() { public TransferPathFilter filter(final Session source, final Session destination, final TransferAction action, final ProgressListener listener) { log.debug("Filter transfer with action {}", action); final Find find = new CachingFindFeature(source, cache, - source.getFeature(Find.class, new DefaultFindFeature(source))); + source.getFeature(Find.class, new DefaultFindFeature(source))); final AttributesFinder attributes = new CachingAttributesFinderFeature(source, cache, - source.getFeature(AttributesFinder.class, new DefaultAttributesFinderFeature(source))); + source.getFeature(AttributesFinder.class, new DefaultAttributesFinderFeature(source))); // Set chosen action (upload, download, mirror) from prompt - comparison = new CachingComparePathFilter(new DefaultComparePathFilter(source)) - .withCache(comparisons) - .withAttributes(attributes) - .withFinder(find); + comparison = new CachingComparePathFilter(comparisons, new DefaultComparePathFilter(source, find, attributes)); return new SynchronizationPathFilter(comparison, - download.filter(source, destination, TransferAction.overwrite, listener) - .withAttributes(attributes) - .withFinder(find), - upload.filter(source, destination, TransferAction.overwrite, listener) - .withAttributes(attributes) - .withFinder(find), - action + download.filter(source, destination, TransferAction.overwrite, listener), + upload.filter(source, destination, TransferAction.overwrite, listener), + action ); } diff --git a/core/src/main/java/ch/cyberduck/core/transfer/TransferPathFilter.java b/core/src/main/java/ch/cyberduck/core/transfer/TransferPathFilter.java index 3b964f26991..3e46bc53b29 100644 --- a/core/src/main/java/ch/cyberduck/core/transfer/TransferPathFilter.java +++ b/core/src/main/java/ch/cyberduck/core/transfer/TransferPathFilter.java @@ -23,17 +23,16 @@ import ch.cyberduck.core.ProgressListener; import ch.cyberduck.core.exception.BackgroundException; import ch.cyberduck.core.exception.TransferStatusCanceledException; -import ch.cyberduck.core.features.AttributesFinder; -import ch.cyberduck.core.features.Find; public interface TransferPathFilter { /** - * @param file File - * @param parent Parent transfer status + * @param file File + * @param parent Parent transfer status + * @param progress * @return True if file should be transferred */ - boolean accept(Path file, Local local, TransferStatus parent) throws BackgroundException; + boolean accept(Path file, Local local, TransferStatus parent, ProgressListener progress) throws BackgroundException; /** * Called before the file will actually get transferred. Should prepare for the transfer such as calculating its @@ -59,7 +58,7 @@ TransferStatus prepare(Path file, Local local, TransferStatus parent, ProgressLi * @throws BackgroundException */ void apply(Path file, Local local, TransferStatus status, ProgressListener listener) - throws BackgroundException; + throws BackgroundException; /** * Post processing of completed transfer. @@ -70,9 +69,4 @@ void apply(Path file, Local local, TransferStatus status, ProgressListener liste */ void complete(Path file, Local local, TransferStatus status, ProgressListener listener) throws BackgroundException; - - TransferPathFilter withFinder(Find finder); - - TransferPathFilter withAttributes(AttributesFinder attributes); - } diff --git a/core/src/main/java/ch/cyberduck/core/transfer/UploadTransfer.java b/core/src/main/java/ch/cyberduck/core/transfer/UploadTransfer.java index bb0bfbf3c00..ab5e06c8011 100644 --- a/core/src/main/java/ch/cyberduck/core/transfer/UploadTransfer.java +++ b/core/src/main/java/ch/cyberduck/core/transfer/UploadTransfer.java @@ -161,21 +161,21 @@ public AbstractUploadFilter filter(final Session source, final Session des } log.debug("Determined features {} and {}", find, attributes); if(action.equals(TransferAction.resume)) { - return new ResumeFilter(resolver, source, options).withFinder(find).withAttributes(attributes); + return new ResumeFilter(resolver, source, find, attributes, options); } if(action.equals(TransferAction.rename)) { - return new RenameFilter(resolver, source, options).withFinder(find).withAttributes(attributes); + return new RenameFilter(resolver, source, find, attributes, options); } if(action.equals(TransferAction.renameexisting)) { - return new RenameExistingFilter(resolver, source, options).withFinder(find).withAttributes(attributes); + return new RenameExistingFilter(resolver, source, find, attributes, options); } if(action.equals(TransferAction.skip)) { - return new SkipFilter(resolver, source, options).withFinder(find).withAttributes(attributes); + return new SkipFilter(resolver, source, find, attributes, options); } if(action.equals(TransferAction.comparison)) { - return new CompareFilter(resolver, source, options, listener).withFinder(find).withAttributes(attributes); + return new CompareFilter(resolver, source, find, attributes, options); } - return new OverwriteFilter(resolver, source, options).withFinder(find).withAttributes(attributes); + return new OverwriteFilter(resolver, source, find, attributes, options); } @Override diff --git a/core/src/main/java/ch/cyberduck/core/transfer/copy/AbstractCopyFilter.java b/core/src/main/java/ch/cyberduck/core/transfer/copy/AbstractCopyFilter.java index 0baeebbb853..87ef246c333 100644 --- a/core/src/main/java/ch/cyberduck/core/transfer/copy/AbstractCopyFilter.java +++ b/core/src/main/java/ch/cyberduck/core/transfer/copy/AbstractCopyFilter.java @@ -40,7 +40,6 @@ import ch.cyberduck.core.features.Timestamp; import ch.cyberduck.core.features.UnixPermission; import ch.cyberduck.core.shared.DefaultAttributesFinderFeature; -import ch.cyberduck.core.shared.DefaultFindFeature; import ch.cyberduck.core.transfer.TransferPathFilter; import ch.cyberduck.core.transfer.TransferStatus; import ch.cyberduck.core.transfer.upload.UploadFilterOptions; @@ -55,47 +54,38 @@ public abstract class AbstractCopyFilter implements TransferPathFilter { private static final Logger log = LogManager.getLogger(AbstractCopyFilter.class); - protected final Session sourceSession; - protected final Session targetSession; + protected final Session source; + protected final Session destination; protected final Map files; private final Filter hidden = SearchFilterFactory.HIDDEN_FILTER; - protected Find find; - protected AttributesFinder attribute; - private final UploadFilterOptions options; + protected final Find find; + protected final AttributesFinder attribute; + protected final UploadFilterOptions options; public AbstractCopyFilter(final Session source, final Session destination, final Map files) { this(source, destination, files, new UploadFilterOptions(destination.getHost())); } - public AbstractCopyFilter(final Session source, final Session destination, - final Map files, final UploadFilterOptions options) { - this.sourceSession = source; - this.targetSession = destination; - this.files = files; - this.options = options; - this.find = destination.getFeature(Find.class, new DefaultFindFeature(destination)); - this.attribute = destination.getFeature(AttributesFinder.class, new DefaultAttributesFinderFeature(destination)); - } - - @Override - public AbstractCopyFilter withFinder(final Find finder) { - this.find = finder; - return this; + public AbstractCopyFilter(final Session source, final Session destination, final Map files, final UploadFilterOptions options) { + this(source, destination, files, destination.getFeature(Find.class), destination.getFeature(AttributesFinder.class), options); } - @Override - public AbstractCopyFilter withAttributes(final AttributesFinder attributes) { - this.attribute = attributes; - return this; + public AbstractCopyFilter(final Session source, final Session destination, final Map files, final Find find, final AttributesFinder attribute, final UploadFilterOptions options) { + this.source = source; + this.destination = destination; + this.files = files; + this.find = find; + this.attribute = attribute; + this.options = options; } @Override public TransferStatus prepare(final Path file, final Local n, final TransferStatus parent, final ProgressListener progress) throws BackgroundException { final TransferStatus status = new TransferStatus() - .hidden(!hidden.accept(file)) - .withLockId(parent.getLockId()); + .hidden(!hidden.accept(file)) + .withLockId(parent.getLockId()); if(parent.isExists()) { final Path target = files.get(file); if(find.find(target)) { @@ -106,7 +96,7 @@ public TransferStatus prepare(final Path file, final Local n, final TransferStat } } // Read remote attributes from source - final PathAttributes attributes = sourceSession.getFeature(AttributesFinder.class, new DefaultAttributesFinderFeature(sourceSession)).find(file); + final PathAttributes attributes = source.getFeature(AttributesFinder.class, new DefaultAttributesFinderFeature(source)).find(file); if(file.isFile()) { // Content length status.setLength(attributes.getSize()); @@ -118,22 +108,22 @@ public TransferStatus prepare(final Path file, final Local n, final TransferStat status.setPermission(attributes.getPermission()); } if(options.acl) { - final AclPermission sourceFeature = sourceSession.getFeature(AclPermission.class); + final AclPermission sourceFeature = source.getFeature(AclPermission.class); if(sourceFeature != null) { progress.message(MessageFormat.format(LocaleFactory.localizedString("Getting permission of {0}", "Status"), - file.getName())); + file.getName())); try { status.setAcl(sourceFeature.getPermission(file)); } catch(NotfoundException | AccessDeniedException | InteroperabilityException e) { - final AclPermission targetFeature = targetSession.getFeature(AclPermission.class); + final AclPermission targetFeature = destination.getFeature(AclPermission.class); if(targetFeature != null) { status.setAcl(targetFeature.getDefault(file)); } } } else { - final AclPermission targetFeature = targetSession.getFeature(AclPermission.class); + final AclPermission targetFeature = destination.getFeature(AclPermission.class); if(targetFeature != null) { status.setAcl(targetFeature.getDefault(file)); } @@ -144,10 +134,10 @@ public TransferStatus prepare(final Path file, final Local n, final TransferStat status.setCreated(attributes.getCreationDate()); } if(options.metadata) { - final Headers sourceFeature = sourceSession.getFeature(Headers.class); + final Headers sourceFeature = source.getFeature(Headers.class); if(sourceFeature != null) { progress.message(MessageFormat.format(LocaleFactory.localizedString("Reading metadata of {0}", "Status"), - file.getName())); + file.getName())); try { status.setMetadata(sourceFeature.getMetadata(file)); } @@ -157,22 +147,22 @@ public TransferStatus prepare(final Path file, final Local n, final TransferStat } } if(options.encryption) { - final Encryption sourceFeature = sourceSession.getFeature(Encryption.class); + final Encryption sourceFeature = source.getFeature(Encryption.class); if(sourceFeature != null) { progress.message(MessageFormat.format(LocaleFactory.localizedString("Reading metadata of {0}", "Status"), - file.getName())); + file.getName())); try { status.setEncryption(sourceFeature.getEncryption(file)); } catch(NotfoundException | AccessDeniedException | InteroperabilityException e) { - final Encryption targetFeature = targetSession.getFeature(Encryption.class); + final Encryption targetFeature = destination.getFeature(Encryption.class); if(targetFeature != null) { status.setEncryption(targetFeature.getDefault(file)); } } } else { - final Encryption targetFeature = targetSession.getFeature(Encryption.class); + final Encryption targetFeature = destination.getFeature(Encryption.class); if(targetFeature != null) { status.setEncryption(targetFeature.getDefault(file)); } @@ -180,22 +170,22 @@ public TransferStatus prepare(final Path file, final Local n, final TransferStat } if(options.redundancy) { if(file.isFile()) { - final Redundancy sourceFeature = sourceSession.getFeature(Redundancy.class); + final Redundancy sourceFeature = source.getFeature(Redundancy.class); if(sourceFeature != null) { progress.message(MessageFormat.format(LocaleFactory.localizedString("Reading metadata of {0}", "Status"), - file.getName())); + file.getName())); try { status.setStorageClass(sourceFeature.getClass(file)); } catch(NotfoundException | AccessDeniedException | InteroperabilityException e) { - final Redundancy targetFeature = targetSession.getFeature(Redundancy.class); + final Redundancy targetFeature = destination.getFeature(Redundancy.class); if(targetFeature != null) { status.setStorageClass(targetFeature.getDefault()); } } } else { - final Redundancy targetFeature = targetSession.getFeature(Redundancy.class); + final Redundancy targetFeature = destination.getFeature(Redundancy.class); if(targetFeature != null) { status.setStorageClass(targetFeature.getDefault()); } @@ -220,12 +210,12 @@ public void complete(final Path source, final Local n, final TransferStatus stat if(status.isComplete()) { final Path target = files.get(source); if(!Permission.EMPTY.equals(status.getPermission())) { - final UnixPermission feature = targetSession.getFeature(UnixPermission.class); + final UnixPermission feature = destination.getFeature(UnixPermission.class); if(feature != null) { if(!Permission.EMPTY.equals(status.getPermission())) { try { listener.message(MessageFormat.format(LocaleFactory.localizedString("Changing permission of {0} to {1}", "Status"), - target.getName(), status.getPermission())); + target.getName(), status.getPermission())); feature.setUnixPermission(target, status); } catch(BackgroundException e) { @@ -236,11 +226,11 @@ public void complete(final Path source, final Local n, final TransferStatus stat } } if(!Acl.EMPTY.equals(status.getAcl())) { - final AclPermission feature = targetSession.getFeature(AclPermission.class); + final AclPermission feature = destination.getFeature(AclPermission.class); if(feature != null) { try { listener.message(MessageFormat.format(LocaleFactory.localizedString("Changing permission of {0} to {1}", "Status"), - target.getName(), status.getAcl())); + target.getName(), status.getAcl())); feature.setPermission(target, status.getAcl()); } catch(BackgroundException e) { @@ -250,7 +240,7 @@ public void complete(final Path source, final Local n, final TransferStatus stat } } if(status.getModified() != null) { - final Timestamp timestamp = targetSession.getFeature(Timestamp.class); + final Timestamp timestamp = destination.getFeature(Timestamp.class); if(timestamp != null) { listener.message(MessageFormat.format(LocaleFactory.localizedString("Changing timestamp of {0} to {1}", "Status"), target.getName(), UserDateFormatterFactory.get().getShortFormat(status.getModified()))); diff --git a/core/src/main/java/ch/cyberduck/core/transfer/copy/ChecksumFilter.java b/core/src/main/java/ch/cyberduck/core/transfer/copy/ChecksumFilter.java index 3b6220af21b..a84bb9f6ea7 100644 --- a/core/src/main/java/ch/cyberduck/core/transfer/copy/ChecksumFilter.java +++ b/core/src/main/java/ch/cyberduck/core/transfer/copy/ChecksumFilter.java @@ -20,8 +20,11 @@ import ch.cyberduck.core.Local; import ch.cyberduck.core.Path; import ch.cyberduck.core.PathAttributes; +import ch.cyberduck.core.ProgressListener; import ch.cyberduck.core.Session; import ch.cyberduck.core.exception.BackgroundException; +import ch.cyberduck.core.features.AttributesFinder; +import ch.cyberduck.core.features.Find; import ch.cyberduck.core.io.Checksum; import ch.cyberduck.core.transfer.TransferStatus; import ch.cyberduck.core.transfer.upload.UploadFilterOptions; @@ -36,15 +39,23 @@ public class ChecksumFilter extends AbstractCopyFilter { private static final Logger log = LogManager.getLogger(ChecksumFilter.class); public ChecksumFilter(final Session source, final Session destination, final Map files) { - super(source, destination, files); + this(source, destination, files, new UploadFilterOptions(destination.getHost())); } public ChecksumFilter(final Session source, final Session destination, final Map files, final UploadFilterOptions options) { - super(source, destination, files, options); + this(source, destination, files, destination.getFeature(Find.class), destination.getFeature(AttributesFinder.class), options); + } + + public ChecksumFilter(final Session source, final Session destination, final Map files, final Find find, final AttributesFinder attribute) { + this(source, destination, files, find, attribute, new UploadFilterOptions(destination.getHost())); + } + + public ChecksumFilter(final Session source, final Session destination, final Map files, final Find find, final AttributesFinder attribute, final UploadFilterOptions options) { + super(source, destination, files, find, attribute, options); } @Override - public boolean accept(final Path source, final Local local, final TransferStatus parent) throws BackgroundException { + public boolean accept(final Path source, final Local local, final TransferStatus parent, final ProgressListener progress) throws BackgroundException { final Path target = files.get(source); if(source.isFile()) { if(parent.isExists()) { diff --git a/core/src/main/java/ch/cyberduck/core/transfer/copy/OverwriteFilter.java b/core/src/main/java/ch/cyberduck/core/transfer/copy/OverwriteFilter.java index 3d954551ec7..6131c0465eb 100644 --- a/core/src/main/java/ch/cyberduck/core/transfer/copy/OverwriteFilter.java +++ b/core/src/main/java/ch/cyberduck/core/transfer/copy/OverwriteFilter.java @@ -19,7 +19,10 @@ import ch.cyberduck.core.Local; import ch.cyberduck.core.Path; +import ch.cyberduck.core.ProgressListener; import ch.cyberduck.core.Session; +import ch.cyberduck.core.features.AttributesFinder; +import ch.cyberduck.core.features.Find; import ch.cyberduck.core.transfer.TransferStatus; import ch.cyberduck.core.transfer.upload.UploadFilterOptions; @@ -28,15 +31,23 @@ public class OverwriteFilter extends AbstractCopyFilter { public OverwriteFilter(final Session source, final Session destination, final Map files) { - super(source, destination, files); + this(source, destination, files, new UploadFilterOptions(destination.getHost())); } public OverwriteFilter(final Session source, final Session destination, final Map files, final UploadFilterOptions options) { - super(source, destination, files, options); + this(source, destination, files, destination.getFeature(Find.class), destination.getFeature(AttributesFinder.class), options); + } + + public OverwriteFilter(final Session source, final Session destination, final Map files, final Find find, final AttributesFinder attribute) { + this(source, destination, files, find, attribute, new UploadFilterOptions(destination.getHost())); + } + + public OverwriteFilter(final Session source, final Session destination, final Map files, final Find find, final AttributesFinder attribute, final UploadFilterOptions options) { + super(source, destination, files, find, attribute, options); } @Override - public boolean accept(final Path source, final Local local, final TransferStatus parent) { + public boolean accept(final Path source, final Local local, final TransferStatus parent, final ProgressListener progress) { return true; } } 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 d634370108d..a333c8384eb 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 @@ -35,7 +35,6 @@ import ch.cyberduck.core.exception.LocalAccessDeniedException; import ch.cyberduck.core.exception.NotfoundException; import ch.cyberduck.core.features.AttributesFinder; -import ch.cyberduck.core.features.Find; import ch.cyberduck.core.features.Read; import ch.cyberduck.core.io.Checksum; import ch.cyberduck.core.io.ChecksumCompute; @@ -76,35 +75,23 @@ public abstract class AbstractDownloadFilter implements TransferPathFilter { private final ApplicationLauncher launcher = ApplicationLauncherFactory.get(); private final IconService icon = IconServiceFactory.get(); - protected AttributesFinder attribute; - private DownloadFilterOptions options; + protected final AttributesFinder attribute; + protected final DownloadFilterOptions options; - protected AbstractDownloadFilter(final SymlinkResolver symlinkResolver, final Session session, final DownloadFilterOptions options) { - this.symlinkResolver = symlinkResolver; - this.session = session; - this.options = options; - this.attribute = session.getFeature(AttributesFinder.class); - this.preferences = new HostPreferences(session.getHost()); - } - - @Override - public AbstractDownloadFilter withFinder(final Find finder) { - return this; + public AbstractDownloadFilter(final SymlinkResolver symlinkResolver, final Session session, final DownloadFilterOptions options) { + this(symlinkResolver, session, session.getFeature(AttributesFinder.class), options); } - @Override - public AbstractDownloadFilter withAttributes(final AttributesFinder attributes) { - this.attribute = attributes; - return this; - } - - public AbstractDownloadFilter withOptions(final DownloadFilterOptions options) { + public AbstractDownloadFilter(final SymlinkResolver symlinkResolver, final Session session, final AttributesFinder attribute, final DownloadFilterOptions options) { + this.session = session; + this.symlinkResolver = symlinkResolver; + this.attribute = attribute; this.options = options; - return this; + this.preferences = new HostPreferences(session.getHost()); } @Override - public boolean accept(final Path file, final Local local, final TransferStatus parent) throws BackgroundException { + public boolean accept(final Path file, final Local local, final TransferStatus parent, final ProgressListener progress) throws BackgroundException { final Local volume = local.getVolume(); if(!volume.exists()) { throw new NotfoundException(String.format("Volume %s not mounted", volume.getAbsolute())); diff --git a/core/src/main/java/ch/cyberduck/core/transfer/download/CompareFilter.java b/core/src/main/java/ch/cyberduck/core/transfer/download/CompareFilter.java index aa6039cec9b..7939d2ecec7 100644 --- a/core/src/main/java/ch/cyberduck/core/transfer/download/CompareFilter.java +++ b/core/src/main/java/ch/cyberduck/core/transfer/download/CompareFilter.java @@ -36,57 +36,47 @@ public class CompareFilter extends AbstractDownloadFilter { private static final Logger log = LogManager.getLogger(CompareFilter.class); - private final ProgressListener listener; private final ComparePathFilter comparison; - public CompareFilter(final SymlinkResolver symlinkResolver, final Session session, final ProgressListener listener) { - this(symlinkResolver, session, new DownloadFilterOptions(session.getHost()), listener); + public CompareFilter(final SymlinkResolver symlinkResolver, final Session session) { + this(symlinkResolver, session, new DownloadFilterOptions(session.getHost())); } - public CompareFilter(final SymlinkResolver symlinkResolver, final Session session, - final DownloadFilterOptions options, - final ProgressListener listener) { - this(symlinkResolver, session, options, listener, new DefaultComparePathFilter(session)); + public CompareFilter(final SymlinkResolver symlinkResolver, final Session session, final Find find, final AttributesFinder attribute) { + this(symlinkResolver, session, find, attribute, new DefaultComparePathFilter(session, find, attribute), new DownloadFilterOptions(session.getHost())); } - public CompareFilter(final SymlinkResolver symlinkResolver, final Session session, - final DownloadFilterOptions options, final ProgressListener listener, - final ComparePathFilter comparison) { - super(symlinkResolver, session, options); - this.listener = listener; - this.comparison = comparison; + public CompareFilter(final SymlinkResolver symlinkResolver, final Session session, final DownloadFilterOptions options) { + this(symlinkResolver, session, new DefaultComparePathFilter(session), options); } - @Override - public AbstractDownloadFilter withFinder(final Find finder) { - comparison.withFinder(finder); - return super.withFinder(finder); + public CompareFilter(final SymlinkResolver symlinkResolver, final Session session, final ComparePathFilter comparison, final DownloadFilterOptions options) { + this(symlinkResolver, session, session.getFeature(Find.class), session.getFeature(AttributesFinder.class), comparison, options); } - @Override - public AbstractDownloadFilter withAttributes(final AttributesFinder attributes) { - comparison.withAttributes(attributes); - return super.withAttributes(attributes); + public CompareFilter(final SymlinkResolver symlinkResolver, final Session session, final Find find, final AttributesFinder attribute, final ComparePathFilter comparison, final DownloadFilterOptions options) { + super(symlinkResolver, session, attribute, options); + this.comparison = comparison; } @Override - public boolean accept(final Path file, final Local local, final TransferStatus parent) throws BackgroundException { - if(super.accept(file, local, parent)) { - final Comparison comparison = this.comparison.compare(file, local, listener); - switch(comparison) { + public boolean accept(final Path file, final Local local, final TransferStatus parent, final ProgressListener progress) throws BackgroundException { + if(super.accept(file, local, parent, progress)) { + final Comparison result = comparison.compare(file, local, progress); + switch(result) { case local: - log.info("Skip file {} with comparison {}", file, comparison); + log.info("Skip file {} with result {}", file, result); return false; case equal: if(file.isDirectory()) { return true; } - log.info("Skip file {} with comparison {}", file, comparison); + log.info("Skip file {} with result {}", file, result); return false; case remote: return true; } - log.warn("Invalid comparison result {}", comparison); + log.warn("Invalid result result {}", result); } return false; } diff --git a/core/src/main/java/ch/cyberduck/core/transfer/download/OverwriteFilter.java b/core/src/main/java/ch/cyberduck/core/transfer/download/OverwriteFilter.java index 07ea9c12eec..7ba2743df30 100644 --- a/core/src/main/java/ch/cyberduck/core/transfer/download/OverwriteFilter.java +++ b/core/src/main/java/ch/cyberduck/core/transfer/download/OverwriteFilter.java @@ -19,16 +19,21 @@ import ch.cyberduck.core.Path; import ch.cyberduck.core.Session; +import ch.cyberduck.core.features.AttributesFinder; import ch.cyberduck.core.transfer.symlink.SymlinkResolver; public class OverwriteFilter extends AbstractDownloadFilter { public OverwriteFilter(final SymlinkResolver symlinkResolver, final Session session) { - super(symlinkResolver, session, new DownloadFilterOptions(session.getHost())); + this(symlinkResolver, session, new DownloadFilterOptions(session.getHost())); } - public OverwriteFilter(final SymlinkResolver symlinkResolver, final Session session, - final DownloadFilterOptions options) { - super(symlinkResolver, session, options); + public OverwriteFilter(final SymlinkResolver symlinkResolver, final Session session, final DownloadFilterOptions options) { + this(symlinkResolver, session, session.getFeature(AttributesFinder.class), options); } + + public OverwriteFilter(final SymlinkResolver symlinkResolver, final Session session, final AttributesFinder attribute, final DownloadFilterOptions options) { + super(symlinkResolver, session, attribute, options); + } + } diff --git a/core/src/main/java/ch/cyberduck/core/transfer/download/RenameExistingFilter.java b/core/src/main/java/ch/cyberduck/core/transfer/download/RenameExistingFilter.java index b4397e0ed1a..99bbc1c272a 100755 --- a/core/src/main/java/ch/cyberduck/core/transfer/download/RenameExistingFilter.java +++ b/core/src/main/java/ch/cyberduck/core/transfer/download/RenameExistingFilter.java @@ -24,6 +24,7 @@ import ch.cyberduck.core.Session; import ch.cyberduck.core.UserDateFormatterFactory; import ch.cyberduck.core.exception.BackgroundException; +import ch.cyberduck.core.features.AttributesFinder; import ch.cyberduck.core.preferences.PreferencesFactory; import ch.cyberduck.core.transfer.TransferStatus; import ch.cyberduck.core.transfer.symlink.SymlinkResolver; @@ -39,12 +40,15 @@ public class RenameExistingFilter extends AbstractDownloadFilter { private static final Logger log = LogManager.getLogger(RenameExistingFilter.class); public RenameExistingFilter(final SymlinkResolver symlinkResolver, final Session session) { - super(symlinkResolver, session, new DownloadFilterOptions(session.getHost())); + this(symlinkResolver, session, session.getFeature(AttributesFinder.class), new DownloadFilterOptions(session.getHost())); } - public RenameExistingFilter(final SymlinkResolver symlinkResolver, final Session session, - final DownloadFilterOptions options) { - super(symlinkResolver, session, options); + public RenameExistingFilter(final SymlinkResolver symlinkResolver, final Session session, final DownloadFilterOptions options) { + this(symlinkResolver, session, session.getFeature(AttributesFinder.class), options); + } + + public RenameExistingFilter(final SymlinkResolver symlinkResolver, final Session session, final AttributesFinder attribute, final DownloadFilterOptions options) { + super(symlinkResolver, session, attribute, options); } @Override @@ -59,9 +63,9 @@ public void apply(final Path file, final Local local, final TransferStatus statu Local rename; do { String proposal = MessageFormat.format(PreferencesFactory.get().getProperty("queue.download.file.rename.format"), - FilenameUtils.getBaseName(file.getName()), - UserDateFormatterFactory.get().getMediumFormat(System.currentTimeMillis(), false).replace(local.getDelimiter(), '-').replace(':', '-'), - StringUtils.isNotBlank(file.getExtension()) ? String.format(".%s", file.getExtension()) : StringUtils.EMPTY); + FilenameUtils.getBaseName(file.getName()), + UserDateFormatterFactory.get().getMediumFormat(System.currentTimeMillis(), false).replace(local.getDelimiter(), '-').replace(':', '-'), + StringUtils.isNotBlank(file.getExtension()) ? String.format(".%s", file.getExtension()) : StringUtils.EMPTY); rename = LocalFactory.get(local.getParent().getAbsolute(), proposal); } while(rename.exists()); diff --git a/core/src/main/java/ch/cyberduck/core/transfer/download/RenameFilter.java b/core/src/main/java/ch/cyberduck/core/transfer/download/RenameFilter.java index 0a7779681a3..77d67bf09ff 100644 --- a/core/src/main/java/ch/cyberduck/core/transfer/download/RenameFilter.java +++ b/core/src/main/java/ch/cyberduck/core/transfer/download/RenameFilter.java @@ -23,6 +23,7 @@ import ch.cyberduck.core.ProgressListener; import ch.cyberduck.core.Session; import ch.cyberduck.core.exception.BackgroundException; +import ch.cyberduck.core.features.AttributesFinder; import ch.cyberduck.core.transfer.TransferStatus; import ch.cyberduck.core.transfer.symlink.SymlinkResolver; @@ -35,12 +36,15 @@ public class RenameFilter extends AbstractDownloadFilter { private static final Logger log = LogManager.getLogger(RenameFilter.class); public RenameFilter(final SymlinkResolver symlinkResolver, final Session session) { - super(symlinkResolver, session, new DownloadFilterOptions(session.getHost())); + this(symlinkResolver, session, session.getFeature(AttributesFinder.class), new DownloadFilterOptions(session.getHost())); } - public RenameFilter(final SymlinkResolver symlinkResolver, final Session session, - final DownloadFilterOptions options) { - super(symlinkResolver, session, options); + public RenameFilter(final SymlinkResolver symlinkResolver, final Session session, final DownloadFilterOptions options) { + this(symlinkResolver, session, session.getFeature(AttributesFinder.class), options); + } + + public RenameFilter(final SymlinkResolver symlinkResolver, final Session session, final AttributesFinder attribute, final DownloadFilterOptions options) { + super(symlinkResolver, session, attribute, options); } @Override diff --git a/core/src/main/java/ch/cyberduck/core/transfer/download/ResumeFilter.java b/core/src/main/java/ch/cyberduck/core/transfer/download/ResumeFilter.java index 6321690adb7..dc25116d04e 100644 --- a/core/src/main/java/ch/cyberduck/core/transfer/download/ResumeFilter.java +++ b/core/src/main/java/ch/cyberduck/core/transfer/download/ResumeFilter.java @@ -23,6 +23,7 @@ import ch.cyberduck.core.ProgressListener; import ch.cyberduck.core.Session; import ch.cyberduck.core.exception.BackgroundException; +import ch.cyberduck.core.features.AttributesFinder; import ch.cyberduck.core.features.Download; import ch.cyberduck.core.io.Checksum; import ch.cyberduck.core.io.ChecksumCompute; @@ -42,19 +43,25 @@ public ResumeFilter(final SymlinkResolver symlinkResolver, final Session symlinkResolver, final Session session, - final DownloadFilterOptions options) { - this(symlinkResolver, session, options, session.getFeature(Download.class)); + public ResumeFilter(final SymlinkResolver symlinkResolver, final Session session, final DownloadFilterOptions options) { + this(symlinkResolver, session, session.getFeature(AttributesFinder.class), session.getFeature(Download.class), options); } - public ResumeFilter(final SymlinkResolver symlinkResolver, final Session session, - final DownloadFilterOptions options, final Download download) { - super(symlinkResolver, session, options); + public ResumeFilter(final SymlinkResolver symlinkResolver, final Session session, final AttributesFinder attribute, final DownloadFilterOptions options) { + this(symlinkResolver, session, attribute, session.getFeature(Download.class), options); + } + + public ResumeFilter(final SymlinkResolver symlinkResolver, final Session session, final Download download, final DownloadFilterOptions options) { + this(symlinkResolver, session, session.getFeature(AttributesFinder.class), download, options); + } + + public ResumeFilter(final SymlinkResolver symlinkResolver, final Session session, final AttributesFinder attribute, final Download download, final DownloadFilterOptions options) { + super(symlinkResolver, session, attribute, options); this.download = download; } @Override - public boolean accept(final Path file, final Local local, final TransferStatus parent) throws BackgroundException { + public boolean accept(final Path file, final Local local, final TransferStatus parent, final ProgressListener progress) throws BackgroundException { if(local.isFile()) { if(local.exists()) { // Read remote attributes @@ -78,7 +85,7 @@ public boolean accept(final Path file, final Local local, final TransferStatus p } } } - return super.accept(file, local, parent); + return super.accept(file, local, parent, progress); } @Override diff --git a/core/src/main/java/ch/cyberduck/core/transfer/download/SkipFilter.java b/core/src/main/java/ch/cyberduck/core/transfer/download/SkipFilter.java index 6aa6a8a5f05..e6eec848023 100644 --- a/core/src/main/java/ch/cyberduck/core/transfer/download/SkipFilter.java +++ b/core/src/main/java/ch/cyberduck/core/transfer/download/SkipFilter.java @@ -19,8 +19,10 @@ 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.AttributesFinder; import ch.cyberduck.core.transfer.TransferStatus; import ch.cyberduck.core.transfer.symlink.SymlinkResolver; @@ -31,22 +33,25 @@ public class SkipFilter extends AbstractDownloadFilter { private static final Logger log = LogManager.getLogger(SkipFilter.class); public SkipFilter(final SymlinkResolver symlinkResolver, final Session session) { - super(symlinkResolver, session, new DownloadFilterOptions(session.getHost())); + this(symlinkResolver, session, session.getFeature(AttributesFinder.class), new DownloadFilterOptions(session.getHost())); } - public SkipFilter(final SymlinkResolver symlinkResolver, final Session session, - final DownloadFilterOptions options) { - super(symlinkResolver, session, options); + public SkipFilter(final SymlinkResolver symlinkResolver, final Session session, final DownloadFilterOptions options) { + this(symlinkResolver, session, session.getFeature(AttributesFinder.class), options); + } + + public SkipFilter(final SymlinkResolver symlinkResolver, final Session session, final AttributesFinder attribute, final DownloadFilterOptions options) { + super(symlinkResolver, session, attribute, options); } @Override - public boolean accept(final Path file, final Local local, final TransferStatus parent) throws BackgroundException { + public boolean accept(final Path file, final Local local, final TransferStatus parent, final ProgressListener progress) throws BackgroundException { if(local.isFile()) { if(local.exists()) { log.info("Skip file {}", file); return false; } } - return super.accept(file, local, parent); + return super.accept(file, local, parent, progress); } } diff --git a/core/src/main/java/ch/cyberduck/core/transfer/download/TrashFilter.java b/core/src/main/java/ch/cyberduck/core/transfer/download/TrashFilter.java index 1b658a598af..610499aab49 100644 --- a/core/src/main/java/ch/cyberduck/core/transfer/download/TrashFilter.java +++ b/core/src/main/java/ch/cyberduck/core/transfer/download/TrashFilter.java @@ -23,6 +23,7 @@ import ch.cyberduck.core.Session; import ch.cyberduck.core.exception.AccessDeniedException; import ch.cyberduck.core.exception.BackgroundException; +import ch.cyberduck.core.features.AttributesFinder; import ch.cyberduck.core.local.LocalTrashFactory; import ch.cyberduck.core.local.features.Trash; import ch.cyberduck.core.transfer.TransferStatus; @@ -38,12 +39,15 @@ public class TrashFilter extends AbstractDownloadFilter { = LocalTrashFactory.get(); public TrashFilter(final SymlinkResolver symlinkResolver, final Session session) { - super(symlinkResolver, session, new DownloadFilterOptions(session.getHost())); + this(symlinkResolver, session, new DownloadFilterOptions(session.getHost())); } - public TrashFilter(final SymlinkResolver symlinkResolver, final Session session, - final DownloadFilterOptions options) { - super(symlinkResolver, session, options); + public TrashFilter(final SymlinkResolver symlinkResolver, final Session session, final DownloadFilterOptions options) { + this(symlinkResolver, session, session.getFeature(AttributesFinder.class), options); + } + + public TrashFilter(final SymlinkResolver symlinkResolver, final Session session, final AttributesFinder attribute, final DownloadFilterOptions options) { + super(symlinkResolver, session, attribute, options); } @Override diff --git a/core/src/main/java/ch/cyberduck/core/transfer/synchronisation/SynchronizationPathFilter.java b/core/src/main/java/ch/cyberduck/core/transfer/synchronisation/SynchronizationPathFilter.java index d69698c6bc1..eb0fc7e0c82 100644 --- a/core/src/main/java/ch/cyberduck/core/transfer/synchronisation/SynchronizationPathFilter.java +++ b/core/src/main/java/ch/cyberduck/core/transfer/synchronisation/SynchronizationPathFilter.java @@ -23,8 +23,6 @@ import ch.cyberduck.core.Path; import ch.cyberduck.core.ProgressListener; import ch.cyberduck.core.exception.BackgroundException; -import ch.cyberduck.core.features.AttributesFinder; -import ch.cyberduck.core.features.Find; import ch.cyberduck.core.synchronization.ComparePathFilter; import ch.cyberduck.core.synchronization.Comparison; import ch.cyberduck.core.transfer.TransferAction; @@ -78,7 +76,7 @@ public TransferStatus prepare(final Path file, final Local local, final Transfer } @Override - public boolean accept(final Path file, final Local local, final TransferStatus parent) throws BackgroundException { + public boolean accept(final Path file, final Local local, final TransferStatus parent, final ProgressListener progress) throws BackgroundException { switch(comparison.compare(file, local, new DisabledProgressListener())) { case equal: return file.isDirectory(); @@ -88,14 +86,14 @@ public boolean accept(final Path file, final Local local, final TransferStatus p return false; } // Include for mirror and download. Ask the download delegate for inclusion - return downloadFilter.accept(file, local, parent); + return downloadFilter.accept(file, local, parent, progress); case local: if(action.equals(TransferAction.download)) { log.info("Skip file {} with comparison result {} because action is {}", file, Comparison.local, action); return false; } // Include for mirror and download. Ask the upload delegate for inclusion - return uploadFilter.accept(file, local, parent); + return uploadFilter.accept(file, local, parent, progress); } // Not equal return false; @@ -125,18 +123,4 @@ public void complete(final Path file, final Local local, final TransferStatus st uploadFilter.complete(file, local, status, listener); } } - - @Override - public TransferPathFilter withFinder(final Find finder) { - downloadFilter.withFinder(finder); - uploadFilter.withFinder(finder); - return this; - } - - @Override - public TransferPathFilter withAttributes(final AttributesFinder attributes) { - downloadFilter.withAttributes(attributes); - uploadFilter.withAttributes(attributes); - return null; - } } 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 018b6a87f9c..c742a645a6f 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 @@ -71,39 +71,25 @@ public abstract class AbstractUploadFilter implements TransferPathFilter { private final SymlinkResolver symlinkResolver; private final Filter hidden = SearchFilterFactory.HIDDEN_FILTER; - protected Find find; - protected AttributesFinder attribute; - protected UploadFilterOptions options; + protected final Find find; + protected final AttributesFinder attribute; + protected final UploadFilterOptions options; - public AbstractUploadFilter(final SymlinkResolver symlinkResolver, final Session session, - final UploadFilterOptions options) { - this.symlinkResolver = symlinkResolver; - this.session = session; - this.options = options; - this.find = session.getFeature(Find.class); - this.attribute = session.getFeature(AttributesFinder.class); - this.preferences = new HostPreferences(session.getHost()); - } - - @Override - public AbstractUploadFilter withFinder(final Find finder) { - this.find = finder; - return this; - } - - @Override - public AbstractUploadFilter withAttributes(final AttributesFinder attributes) { - this.attribute = attributes; - return this; + public AbstractUploadFilter(final SymlinkResolver symlinkResolver, final Session session, final UploadFilterOptions options) { + this(symlinkResolver, session, session.getFeature(Find.class), session.getFeature(AttributesFinder.class), options); } - public AbstractUploadFilter withOptions(final UploadFilterOptions options) { + public AbstractUploadFilter(final SymlinkResolver symlinkResolver, final Session session, final Find find, final AttributesFinder attribute, final UploadFilterOptions options) { + this.session = session; + this.symlinkResolver = symlinkResolver; + this.find = find; + this.attribute = attribute; this.options = options; - return this; + this.preferences = new HostPreferences(session.getHost()); } @Override - public boolean accept(final Path file, final Local local, final TransferStatus parent) throws BackgroundException { + public boolean accept(final Path file, final Local local, final TransferStatus parent, final ProgressListener progress) throws BackgroundException { if(!local.exists()) { // Local file is no more here throw new LocalNotfoundException(local.getAbsolute()); @@ -183,7 +169,13 @@ public TransferStatus prepare(final Path file, final Local local, final Transfer status.setPermission(status.getRemote().getPermission()); } else { - status.setPermission(feature.getDefault(local)); + if(new HostPreferences(session.getHost()).getBoolean("queue.upload.permissions.default")) { + status.setPermission(feature.getDefault(file.getType())); + } + else { + // Read permissions from local file + status.setPermission(local.attributes().getPermission()); + } } } else { diff --git a/core/src/main/java/ch/cyberduck/core/transfer/upload/CompareFilter.java b/core/src/main/java/ch/cyberduck/core/transfer/upload/CompareFilter.java index b9bad690611..9fe1479128b 100644 --- a/core/src/main/java/ch/cyberduck/core/transfer/upload/CompareFilter.java +++ b/core/src/main/java/ch/cyberduck/core/transfer/upload/CompareFilter.java @@ -24,7 +24,9 @@ import ch.cyberduck.core.exception.BackgroundException; import ch.cyberduck.core.features.AttributesFinder; import ch.cyberduck.core.features.Find; +import ch.cyberduck.core.synchronization.ComparePathFilter; import ch.cyberduck.core.synchronization.Comparison; +import ch.cyberduck.core.synchronization.ComparisonService; import ch.cyberduck.core.synchronization.DefaultComparePathFilter; import ch.cyberduck.core.transfer.TransferStatus; import ch.cyberduck.core.transfer.symlink.SymlinkResolver; @@ -35,44 +37,34 @@ public class CompareFilter extends AbstractUploadFilter { private static final Logger log = LogManager.getLogger(CompareFilter.class); - private final ProgressListener listener; - private final DefaultComparePathFilter comparisonService; + private final ComparePathFilter comparisonService; - public CompareFilter(final SymlinkResolver symlinkResolver, final Session session, - final ProgressListener listener) { - this(symlinkResolver, session, new UploadFilterOptions(session.getHost()), listener); + public CompareFilter(final SymlinkResolver symlinkResolver, final Session session) { + this(symlinkResolver, session, new UploadFilterOptions(session.getHost())); } - public CompareFilter(final SymlinkResolver symlinkResolver, final Session session, - final UploadFilterOptions options, - final ProgressListener listener) { - this(symlinkResolver, session, options, listener, new DefaultComparePathFilter(session)); + public CompareFilter(final SymlinkResolver symlinkResolver, final Session session, final UploadFilterOptions options) { + this(symlinkResolver, session, new DefaultComparePathFilter(session), options); } public CompareFilter(final SymlinkResolver symlinkResolver, final Session session, - final UploadFilterOptions options, final ProgressListener listener, - final DefaultComparePathFilter comparisonService) { - super(symlinkResolver, session, options); - this.listener = listener; - this.comparisonService = comparisonService; + final DefaultComparePathFilter comparisonService, final UploadFilterOptions options) { + this(symlinkResolver, session, session.getFeature(Find.class), session.getFeature(AttributesFinder.class), comparisonService, options); } - @Override - public AbstractUploadFilter withFinder(final Find finder) { - comparisonService.withFinder(finder); - return super.withFinder(finder); + public CompareFilter(final SymlinkResolver symlinkResolver, final Session session, final Find find, final AttributesFinder attribute, final UploadFilterOptions options) { + this(symlinkResolver, session, find, attribute, new DefaultComparePathFilter(find, attribute, session.getFeature(ComparisonService.class)), options); } - @Override - public AbstractUploadFilter withAttributes(final AttributesFinder attributes) { - comparisonService.withAttributes(attributes); - return super.withAttributes(attributes); + public CompareFilter(final SymlinkResolver symlinkResolver, final Session session, final Find find, final AttributesFinder attribute, final DefaultComparePathFilter comparisonService, final UploadFilterOptions options) { + super(symlinkResolver, session, find, attribute, options); + this.comparisonService = comparisonService; } @Override - public boolean accept(final Path file, final Local local, final TransferStatus parent) throws BackgroundException { - if(super.accept(file, local, parent)) { - final Comparison comparison = comparisonService.compare(file, local, listener); + public boolean accept(final Path file, final Local local, final TransferStatus parent, final ProgressListener progress) throws BackgroundException { + if(super.accept(file, local, parent, progress)) { + final Comparison comparison = comparisonService.compare(file, local, progress); switch(comparison) { case local: return true; diff --git a/core/src/main/java/ch/cyberduck/core/transfer/upload/OverwriteFilter.java b/core/src/main/java/ch/cyberduck/core/transfer/upload/OverwriteFilter.java index 12ab5f99abe..224d4ded50d 100644 --- a/core/src/main/java/ch/cyberduck/core/transfer/upload/OverwriteFilter.java +++ b/core/src/main/java/ch/cyberduck/core/transfer/upload/OverwriteFilter.java @@ -19,6 +19,8 @@ import ch.cyberduck.core.Local; import ch.cyberduck.core.Session; +import ch.cyberduck.core.features.AttributesFinder; +import ch.cyberduck.core.features.Find; import ch.cyberduck.core.transfer.symlink.SymlinkResolver; public class OverwriteFilter extends AbstractUploadFilter { @@ -31,4 +33,9 @@ public OverwriteFilter(final SymlinkResolver symlinkResolver, final Sessi final UploadFilterOptions options) { super(symlinkResolver, session, options); } + + public OverwriteFilter(final SymlinkResolver symlinkResolver, final Session session, + final Find find, final AttributesFinder attribute, final UploadFilterOptions options) { + super(symlinkResolver, session, find, attribute, options); + } } diff --git a/core/src/main/java/ch/cyberduck/core/transfer/upload/RenameExistingFilter.java b/core/src/main/java/ch/cyberduck/core/transfer/upload/RenameExistingFilter.java index fa9ac96f989..3c320f74a19 100755 --- a/core/src/main/java/ch/cyberduck/core/transfer/upload/RenameExistingFilter.java +++ b/core/src/main/java/ch/cyberduck/core/transfer/upload/RenameExistingFilter.java @@ -24,7 +24,9 @@ import ch.cyberduck.core.Session; import ch.cyberduck.core.UserDateFormatterFactory; import ch.cyberduck.core.exception.BackgroundException; +import ch.cyberduck.core.features.AttributesFinder; import ch.cyberduck.core.features.Delete; +import ch.cyberduck.core.features.Find; import ch.cyberduck.core.features.Move; import ch.cyberduck.core.preferences.PreferencesFactory; import ch.cyberduck.core.transfer.TransferStatus; @@ -46,10 +48,18 @@ public RenameExistingFilter(final SymlinkResolver symlinkResolver, final this(symlinkResolver, session, new UploadFilterOptions(session.getHost())); } + public RenameExistingFilter(final SymlinkResolver symlinkResolver, final Session session, final UploadFilterOptions options) { + this(symlinkResolver, session, session.getFeature(Find.class), session.getFeature(AttributesFinder.class), session.getFeature(Move.class), options); + } + + public RenameExistingFilter(final SymlinkResolver symlinkResolver, final Session session, final Find find, final AttributesFinder attribute, final UploadFilterOptions options) { + this(symlinkResolver, session, find, attribute, session.getFeature(Move.class), options); + } + public RenameExistingFilter(final SymlinkResolver symlinkResolver, final Session session, - final UploadFilterOptions options) { - super(symlinkResolver, session, options); - this.move = session.getFeature(Move.class); + final Find find, final AttributesFinder attribute, final Move move, final UploadFilterOptions options) { + super(symlinkResolver, session, find, attribute, options); + this.move = move; } /** @@ -63,9 +73,9 @@ public void apply(final Path file, final Local local, final TransferStatus statu Path rename; do { final String proposal = MessageFormat.format(PreferencesFactory.get().getProperty("queue.upload.file.rename.format"), - FilenameUtils.getBaseName(file.getName()), - UserDateFormatterFactory.get().getMediumFormat(System.currentTimeMillis(), false).replace(Path.DELIMITER, '-').replace(':', '-'), - StringUtils.isNotBlank(file.getExtension()) ? String.format(".%s", file.getExtension()) : StringUtils.EMPTY); + FilenameUtils.getBaseName(file.getName()), + UserDateFormatterFactory.get().getMediumFormat(System.currentTimeMillis(), false).replace(Path.DELIMITER, '-').replace(':', '-'), + StringUtils.isNotBlank(file.getExtension()) ? String.format(".%s", file.getExtension()) : StringUtils.EMPTY); rename = new Path(file.getParent(), proposal, file.getType()); } while(find.find(rename)); diff --git a/core/src/main/java/ch/cyberduck/core/transfer/upload/RenameFilter.java b/core/src/main/java/ch/cyberduck/core/transfer/upload/RenameFilter.java index 3df5f644ff6..1b9aad9597d 100644 --- a/core/src/main/java/ch/cyberduck/core/transfer/upload/RenameFilter.java +++ b/core/src/main/java/ch/cyberduck/core/transfer/upload/RenameFilter.java @@ -22,6 +22,8 @@ import ch.cyberduck.core.ProgressListener; import ch.cyberduck.core.Session; import ch.cyberduck.core.exception.BackgroundException; +import ch.cyberduck.core.features.AttributesFinder; +import ch.cyberduck.core.features.Find; import ch.cyberduck.core.transfer.TransferStatus; import ch.cyberduck.core.transfer.symlink.SymlinkResolver; @@ -33,16 +35,20 @@ public class RenameFilter extends AbstractUploadFilter { private static final Logger log = LogManager.getLogger(RenameFilter.class); - private final UploadFilterOptions options; - public RenameFilter(final SymlinkResolver symlinkResolver, final Session session) { this(symlinkResolver, session, new UploadFilterOptions(session.getHost())); } - public RenameFilter(final SymlinkResolver symlinkResolver, final Session session, - final UploadFilterOptions options) { - super(symlinkResolver, session, options); - this.options = options; + public RenameFilter(final SymlinkResolver symlinkResolver, final Session session, final UploadFilterOptions options) { + this(symlinkResolver, session, session.getFeature(Find.class), session.getFeature(AttributesFinder.class), options); + } + + public RenameFilter(final SymlinkResolver symlinkResolver, final Session session, final Find find, final AttributesFinder attribute) { + this(symlinkResolver, session, find, attribute, new UploadFilterOptions(session.getHost())); + } + + public RenameFilter(final SymlinkResolver symlinkResolver, final Session session, final Find find, final AttributesFinder attribute, final UploadFilterOptions options) { + super(symlinkResolver, session, find, attribute, options); } @Override diff --git a/core/src/main/java/ch/cyberduck/core/transfer/upload/ResumeFilter.java b/core/src/main/java/ch/cyberduck/core/transfer/upload/ResumeFilter.java index 321c5aa9054..ee1287bab5e 100644 --- a/core/src/main/java/ch/cyberduck/core/transfer/upload/ResumeFilter.java +++ b/core/src/main/java/ch/cyberduck/core/transfer/upload/ResumeFilter.java @@ -23,6 +23,8 @@ import ch.cyberduck.core.ProgressListener; import ch.cyberduck.core.Session; import ch.cyberduck.core.exception.BackgroundException; +import ch.cyberduck.core.features.AttributesFinder; +import ch.cyberduck.core.features.Find; import ch.cyberduck.core.features.Upload; import ch.cyberduck.core.features.Write; import ch.cyberduck.core.io.Checksum; @@ -43,20 +45,26 @@ public ResumeFilter(final SymlinkResolver symlinkResolver, final Session< this(symlinkResolver, session, new UploadFilterOptions(session.getHost())); } - public ResumeFilter(final SymlinkResolver symlinkResolver, final Session session, - final UploadFilterOptions options) { - this(symlinkResolver, session, options, session.getFeature(Upload.class)); + public ResumeFilter(final SymlinkResolver symlinkResolver, final Session session, final UploadFilterOptions options) { + this(symlinkResolver, session, session.getFeature(Find.class), session.getFeature(AttributesFinder.class), session.getFeature(Upload.class), options); } - public ResumeFilter(final SymlinkResolver symlinkResolver, final Session session, - final UploadFilterOptions options, final Upload upload) { - super(symlinkResolver, session, options); + public ResumeFilter(final SymlinkResolver symlinkResolver, final Session session, final Find find, final AttributesFinder attribute, final UploadFilterOptions options) { + this(symlinkResolver, session, find, attribute, session.getFeature(Upload.class), options); + } + + public ResumeFilter(final SymlinkResolver symlinkResolver, final Session session, final Upload upload, final UploadFilterOptions options) { + this(symlinkResolver, session, session.getFeature(Find.class), session.getFeature(AttributesFinder.class), upload, options); + } + + public ResumeFilter(final SymlinkResolver symlinkResolver, final Session session, final Find find, final AttributesFinder attribute, final Upload upload, final UploadFilterOptions options) { + super(symlinkResolver, session, find, attribute, options); this.upload = upload; } @Override - public boolean accept(final Path file, final Local local, final TransferStatus parent) throws BackgroundException { - if(super.accept(file, local, parent)) { + public boolean accept(final Path file, final Local local, final TransferStatus parent, final ProgressListener progress) throws BackgroundException { + if(super.accept(file, local, parent, progress)) { if(local.isFile()) { if(parent.isExists()) { if(find.find(file)) { diff --git a/core/src/main/java/ch/cyberduck/core/transfer/upload/SkipFilter.java b/core/src/main/java/ch/cyberduck/core/transfer/upload/SkipFilter.java index 94806df0b4f..d726399ac5b 100644 --- a/core/src/main/java/ch/cyberduck/core/transfer/upload/SkipFilter.java +++ b/core/src/main/java/ch/cyberduck/core/transfer/upload/SkipFilter.java @@ -19,8 +19,11 @@ 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.AttributesFinder; +import ch.cyberduck.core.features.Find; import ch.cyberduck.core.transfer.TransferStatus; import ch.cyberduck.core.transfer.symlink.SymlinkResolver; @@ -36,14 +39,19 @@ public SkipFilter(final SymlinkResolver symlinkResolver, final Session public SkipFilter(final SymlinkResolver symlinkResolver, final Session session, final UploadFilterOptions options) { - super(symlinkResolver, session, options); + this(symlinkResolver, session, session.getFeature(Find.class), session.getFeature(AttributesFinder.class), options); + } + + public SkipFilter(final SymlinkResolver symlinkResolver, final Session session, + final Find find, final AttributesFinder attribute, final UploadFilterOptions options) { + super(symlinkResolver, session, find, attribute, options); } /** * Skip files that already exist on the server. */ @Override - public boolean accept(final Path file, final Local local, final TransferStatus parent) throws BackgroundException { + public boolean accept(final Path file, final Local local, final TransferStatus parent, final ProgressListener progress) throws BackgroundException { if(parent.isExists()) { if(local.isFile()) { if(find.find(file)) { @@ -52,6 +60,6 @@ public boolean accept(final Path file, final Local local, final TransferStatus p } } } - return super.accept(file, local, parent); + return super.accept(file, local, parent, progress); } } diff --git a/core/src/main/java/ch/cyberduck/core/vault/registry/VaultRegistryUnixPermissionFeature.java b/core/src/main/java/ch/cyberduck/core/vault/registry/VaultRegistryUnixPermissionFeature.java index c526e076381..f9a304a6322 100644 --- a/core/src/main/java/ch/cyberduck/core/vault/registry/VaultRegistryUnixPermissionFeature.java +++ b/core/src/main/java/ch/cyberduck/core/vault/registry/VaultRegistryUnixPermissionFeature.java @@ -15,7 +15,6 @@ * GNU General Public License for more details. */ -import ch.cyberduck.core.Local; import ch.cyberduck.core.Path; import ch.cyberduck.core.Permission; import ch.cyberduck.core.Session; @@ -58,11 +57,6 @@ public void setUnixPermission(final Path file, final TransferStatus status) thro registry.find(session, file).getFeature(session, UnixPermission.class, proxy).setUnixPermission(file, status); } - @Override - public Permission getDefault(final Local file) { - return proxy.getDefault(file); - } - @Override public Permission getDefault(final EnumSet type) { return proxy.getDefault(type); diff --git a/core/src/main/java/ch/cyberduck/core/worker/AbstractTransferWorker.java b/core/src/main/java/ch/cyberduck/core/worker/AbstractTransferWorker.java index 2f182faf695..864c9ba14f9 100644 --- a/core/src/main/java/ch/cyberduck/core/worker/AbstractTransferWorker.java +++ b/core/src/main/java/ch/cyberduck/core/worker/AbstractTransferWorker.java @@ -246,7 +246,7 @@ public TransferStatus call() throws BackgroundException { // Determine transfer filter implementation from selected overwrite action final TransferPathFilter filter = transfer.filter(source, destination, action, progress); // Only prepare the path it will be actually transferred - if(!filter.accept(file, local, parent)) { + if(!filter.accept(file, local, parent, progress)) { log.info("Skip file {} by filter {} for transfer {}", file, filter, this); transfer.addSize(0L); transfer.addTransferred(0L); @@ -403,7 +403,7 @@ private void transferSegment(final TransferStatus segment) throws BackgroundExce log.debug("Ask filter {} to accept retry for segment {} of {}", resume, segment, item); if(resume.accept( segment.getRename().remote != null ? segment.getRename().remote : item.remote, - segment.getRename().local != null ? segment.getRename().local : item.local, new TransferStatus().exists(true))) { + segment.getRename().local != null ? segment.getRename().local : item.local, new TransferStatus().exists(true), progress)) { log.debug("Determine status for retry of {}", segment); final TransferStatus retry; if(segment.isSegment()) { diff --git a/core/src/main/java/ch/cyberduck/core/worker/TransferPromptFilterWorker.java b/core/src/main/java/ch/cyberduck/core/worker/TransferPromptFilterWorker.java index 3d8e7130de5..d881f0eee74 100644 --- a/core/src/main/java/ch/cyberduck/core/worker/TransferPromptFilterWorker.java +++ b/core/src/main/java/ch/cyberduck/core/worker/TransferPromptFilterWorker.java @@ -73,7 +73,7 @@ public Map run(final Session session) throws Ba if(this.isCanceled()) { throw new ConnectionCanceledException(); } - final boolean accept = filter.accept(file.remote, file.local, new TransferStatus().exists(true)); + final boolean accept = filter.accept(file.remote, file.local, new TransferStatus().exists(true), listener); status.put(file, filter.prepare(file.remote, file.local, new TransferStatus().exists(true), listener) .reject(!accept)); } diff --git a/core/src/test/java/ch/cyberduck/core/NullAttributesFinder.java b/core/src/test/java/ch/cyberduck/core/NullAttributesFinder.java new file mode 100644 index 00000000000..93b734adf75 --- /dev/null +++ b/core/src/test/java/ch/cyberduck/core/NullAttributesFinder.java @@ -0,0 +1,32 @@ +package ch.cyberduck.core; + +/* + * Copyright (c) 2002-2024 iterate GmbH. All rights reserved. + * https://cyberduck.io/ + * + * 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 3 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. + */ + +import ch.cyberduck.core.exception.BackgroundException; +import ch.cyberduck.core.features.AttributesFinder; + +public class NullAttributesFinder implements AttributesFinder { + + @Override + public PathAttributes find(final Path file) throws BackgroundException { + return file.attributes(); + } + + @Override + public PathAttributes find(final Path file, final ListProgressListener listener) throws BackgroundException { + return file.attributes(); + } +} diff --git a/core/src/test/java/ch/cyberduck/core/NullSession.java b/core/src/test/java/ch/cyberduck/core/NullSession.java index 8db56c41a37..0f135a58c82 100644 --- a/core/src/test/java/ch/cyberduck/core/NullSession.java +++ b/core/src/test/java/ch/cyberduck/core/NullSession.java @@ -2,6 +2,7 @@ import ch.cyberduck.core.exception.BackgroundException; import ch.cyberduck.core.exception.LoginCanceledException; +import ch.cyberduck.core.features.AttributesFinder; import ch.cyberduck.core.features.Delete; import ch.cyberduck.core.features.Directory; import ch.cyberduck.core.features.Move; @@ -67,6 +68,9 @@ public T _getFeature(Class type) { if(type == Directory.class) { return (T) new NullDirectoryFeature(); } + if(type == AttributesFinder.class) { + return (T) new NullAttributesFinder(); + } return super._getFeature(type); } diff --git a/core/src/test/java/ch/cyberduck/core/synchronization/DefaultComparePathFilterTest.java b/core/src/test/java/ch/cyberduck/core/synchronization/DefaultComparePathFilterTest.java index 6bc5ad7ec9f..5edaaaedd56 100644 --- a/core/src/test/java/ch/cyberduck/core/synchronization/DefaultComparePathFilterTest.java +++ b/core/src/test/java/ch/cyberduck/core/synchronization/DefaultComparePathFilterTest.java @@ -51,12 +51,12 @@ public boolean find(final Path file, final ListProgressListener listener) { return true; } }; - ComparePathFilter s = new DefaultComparePathFilter(new NullSession(new Host(new TestProtocol()))) { + ComparePathFilter s = new DefaultComparePathFilter(new NullSession(new Host(new TestProtocol())), find, attributes) { @Override protected Checksum checksum(final HashAlgorithm algorithm, final Local local) { return new Checksum(HashAlgorithm.md5, "a"); } - }.withFinder(find).withAttributes(attributes); + }; final String path = new AlphanumericRandomStringService().random(); assertEquals(Comparison.equal, s.compare(new Path(path, EnumSet.of(Path.Type.file)), new NullLocal(path) { @Override @@ -83,8 +83,12 @@ public boolean find(final Path file, final ListProgressListener listener) { return true; } }; - ComparePathFilter s = new DefaultComparePathFilter(new NullSession(new Host(new TestProtocol())) { - }).withFinder(find); + ComparePathFilter s = new DefaultComparePathFilter(new NullSession(new Host(new TestProtocol())), find, new AttributesFinder() { + @Override + public PathAttributes find(final Path file, final ListProgressListener listener) { + return file.attributes(); + } + }); assertEquals(Comparison.equal, s.compare(new Path("t", EnumSet.of(Path.Type.directory)), new NullLocal("t") { @Override public boolean exists() { @@ -104,8 +108,12 @@ public boolean find(final Path file, final ListProgressListener listener) { return false; } }; - ComparePathFilter s = new DefaultComparePathFilter(new NullSession(new Host(new TestProtocol())) { - }).withFinder(find); + ComparePathFilter s = new DefaultComparePathFilter(new NullSession(new Host(new TestProtocol())), find, new AttributesFinder() { + @Override + public PathAttributes find(final Path file, final ListProgressListener listener) { + return file.attributes(); + } + }); assertEquals(Comparison.local, s.compare(new Path("t", EnumSet.of(Path.Type.directory)), new NullLocal("t") { @Override public boolean exists() { @@ -125,8 +133,12 @@ public boolean find(final Path file, final ListProgressListener listener) { return true; } }; - ComparePathFilter s = new DefaultComparePathFilter(new NullSession(new Host(new TestProtocol())) { - }).withFinder(find); + ComparePathFilter s = new DefaultComparePathFilter(new NullSession(new Host(new TestProtocol())), find, new AttributesFinder() { + @Override + public PathAttributes find(final Path file, final ListProgressListener listener) { + return file.attributes(); + } + }); assertEquals(Comparison.remote, s.compare(new Path("t", EnumSet.of(Path.Type.directory)), new NullLocal("t") { @Override public boolean exists() { @@ -174,12 +186,12 @@ public long getModificationDate() { }; } }; - ComparePathFilter s = new DefaultComparePathFilter(new NullSession(new Host(new TestProtocol()))) { + ComparePathFilter s = new DefaultComparePathFilter(new NullSession(new Host(new TestProtocol())), find, attributes) { @Override protected Checksum checksum(final HashAlgorithm algorithm, final Local local) { return new Checksum(HashAlgorithm.md5, "a"); } - }.withFinder(find).withAttributes(attributes); + }; assertEquals(Comparison.local, s.compare(new Path("t", EnumSet.of(Path.Type.file)), new NullLocal("t") { @Override public LocalAttributes attributes() { diff --git a/core/src/test/java/ch/cyberduck/core/transfer/DownloadTransferTest.java b/core/src/test/java/ch/cyberduck/core/transfer/DownloadTransferTest.java index 9c72a22c7b4..63fca81c432 100755 --- a/core/src/test/java/ch/cyberduck/core/transfer/DownloadTransferTest.java +++ b/core/src/test/java/ch/cyberduck/core/transfer/DownloadTransferTest.java @@ -179,12 +179,12 @@ public void testPrepareDownloadResumeFilter() throws Exception { @Override public AbstractDownloadFilter filter(final Session source, final Session d, final TransferAction action, final ProgressListener listener) { return new ResumeFilter(new DownloadSymlinkResolver(Collections.singletonList(new TransferItem(test))), - new NullTransferSession(new Host(new TestProtocol())), new DownloadFilterOptions(host), new DefaultDownloadFeature(source.getFeature(Read.class)) { + new NullTransferSession(new Host(new TestProtocol())), new DefaultDownloadFeature(source.getFeature(Read.class)) { @Override public boolean offset(final Path file) { return true; } - }); + }, new DownloadFilterOptions(host)); } }; final SingleTransferWorker worker = new SingleTransferWorker(session, null, transfer, new TransferOptions(), diff --git a/core/src/test/java/ch/cyberduck/core/transfer/SyncTransferTest.java b/core/src/test/java/ch/cyberduck/core/transfer/SyncTransferTest.java index 5da14f6428a..6637992b927 100644 --- a/core/src/test/java/ch/cyberduck/core/transfer/SyncTransferTest.java +++ b/core/src/test/java/ch/cyberduck/core/transfer/SyncTransferTest.java @@ -86,7 +86,7 @@ public AttributedList list(final Path file, final ListProgressListener lis final TransferPathFilter filter = t.filter(session, null, TransferAction.download, new DisabledProgressListener()); final Path test = new Path(p, "a", EnumSet.of(Path.Type.file)); assertFalse(filter.accept(test, new NullLocal(System.getProperty("java.io.tmpdir"), "a"), - new TransferStatus().exists(true))); + new TransferStatus().exists(true), new DisabledProgressListener())); } @Test @@ -112,7 +112,7 @@ public long getSize() { }; } }, - new TransferStatus().exists(true))); + new TransferStatus().exists(true), new DisabledProgressListener())); } @Test @@ -141,7 +141,7 @@ public long getSize() { } }; } - }, new TransferStatus().exists(true))); + }, new TransferStatus().exists(true), new DisabledProgressListener())); assertTrue(filter.accept(b, new NullLocal(System.getProperty("java.io.tmpdir"), "b") { @Override public boolean exists() { @@ -157,7 +157,7 @@ public long getSize() { } }; } - }, new TransferStatus().exists(true))); + }, new TransferStatus().exists(true), new DisabledProgressListener())); assertEquals(Comparison.local, t.compare(new TransferItem(a, new NullLocal(System.getProperty("java.io.tmpdir"), "a")))); assertEquals(Comparison.remote, t.compare(new TransferItem(b, new NullLocal(System.getProperty("java.io.tmpdir"), "b")))); } @@ -225,9 +225,9 @@ public boolean exists() { return true; } }; - assertFalse(t.filter(session, null, TransferAction.download, new DisabledProgressListener()).accept(root, local, new TransferStatus().exists(true))); - assertTrue(t.filter(session, null, TransferAction.upload, new DisabledProgressListener()).accept(root, local, new TransferStatus().exists(true))); - assertTrue(t.filter(session, null, TransferAction.mirror, new DisabledProgressListener()).accept(root, local, new TransferStatus().exists(true))); + assertFalse(t.filter(session, null, TransferAction.download, new DisabledProgressListener()).accept(root, local, new TransferStatus().exists(true), new DisabledProgressListener())); + assertTrue(t.filter(session, null, TransferAction.upload, new DisabledProgressListener()).accept(root, local, new TransferStatus().exists(true), new DisabledProgressListener())); + assertTrue(t.filter(session, null, TransferAction.mirror, new DisabledProgressListener()).accept(root, local, new TransferStatus().exists(true), new DisabledProgressListener())); } @Test @@ -263,12 +263,12 @@ public boolean exists() { return false; } }; - assertTrue(t.filter(session, null, TransferAction.download, new DisabledProgressListener()).accept(root, directory, new TransferStatus().exists(true))); - assertTrue(t.filter(session, null, TransferAction.upload, new DisabledProgressListener()).accept(root, directory, new TransferStatus().exists(true))); - assertTrue(t.filter(session, null, TransferAction.mirror, new DisabledProgressListener()).accept(root, directory, new TransferStatus().exists(true))); - assertTrue(t.filter(session, null, TransferAction.download, new DisabledProgressListener()).accept(a, local, new TransferStatus().exists(true))); + assertTrue(t.filter(session, null, TransferAction.download, new DisabledProgressListener()).accept(root, directory, new TransferStatus().exists(true), new DisabledProgressListener())); + assertTrue(t.filter(session, null, TransferAction.upload, new DisabledProgressListener()).accept(root, directory, new TransferStatus().exists(true), new DisabledProgressListener())); + assertTrue(t.filter(session, null, TransferAction.mirror, new DisabledProgressListener()).accept(root, directory, new TransferStatus().exists(true), new DisabledProgressListener())); + assertTrue(t.filter(session, null, TransferAction.download, new DisabledProgressListener()).accept(a, local, new TransferStatus().exists(true), new DisabledProgressListener())); // Because root is directory - assertTrue(t.filter(session, null, TransferAction.upload, new DisabledProgressListener()).accept(root, directory, new TransferStatus().exists(true))); - assertFalse(t.filter(session, null, TransferAction.upload, new DisabledProgressListener()).accept(a, local, new TransferStatus().exists(true))); + assertTrue(t.filter(session, null, TransferAction.upload, new DisabledProgressListener()).accept(root, directory, new TransferStatus().exists(true), new DisabledProgressListener())); + assertFalse(t.filter(session, null, TransferAction.upload, new DisabledProgressListener()).accept(a, local, new TransferStatus().exists(true), new DisabledProgressListener())); } } diff --git a/core/src/test/java/ch/cyberduck/core/transfer/UploadTransferTest.java b/core/src/test/java/ch/cyberduck/core/transfer/UploadTransferTest.java index f796e9a9844..9f07d311f65 100755 --- a/core/src/test/java/ch/cyberduck/core/transfer/UploadTransferTest.java +++ b/core/src/test/java/ch/cyberduck/core/transfer/UploadTransferTest.java @@ -419,12 +419,7 @@ public void transfer(final Session source, final Session destination, fina segment.setComplete(); set.set(true); } - - @Override - public AbstractUploadFilter filter(final Session source, final Session destination, final TransferAction action, final ProgressListener listener) { - return super.filter(source, destination, action, listener).withOptions(new UploadFilterOptions(host).withTemporary(true)); - } - }; + }.withOptions(new UploadFilterOptions(host).withTemporary(true)); final SingleTransferWorker worker = new SingleTransferWorker(session, null, transfer, new TransferOptions(), new TransferSpeedometer(transfer), new DisabledTransferPrompt() { @Override diff --git a/core/src/test/java/ch/cyberduck/core/transfer/copy/OverwriteFilterTest.java b/core/src/test/java/ch/cyberduck/core/transfer/copy/OverwriteFilterTest.java index ec9ae9e96df..971b3d6f992 100644 --- a/core/src/test/java/ch/cyberduck/core/transfer/copy/OverwriteFilterTest.java +++ b/core/src/test/java/ch/cyberduck/core/transfer/copy/OverwriteFilterTest.java @@ -32,7 +32,7 @@ public void testAcceptDirectoryNew() throws Exception { files.put(source, new Path("a", EnumSet.of(Path.Type.directory))); AbstractCopyFilter f = new OverwriteFilter(new NullSession(new Host(new TestProtocol())), new NullSession(new Host(new TestProtocol())), files); - assertTrue(f.accept(source, null, new TransferStatus())); + assertTrue(f.accept(source, null, new TransferStatus(), new DisabledProgressListener())); } @Test @@ -56,7 +56,7 @@ public T _getFeature(final Class type) { return super._getFeature(type); } }, files); - assertTrue(f.accept(source, null, new TransferStatus().exists(true))); + assertTrue(f.accept(source, null, new TransferStatus().exists(true), new DisabledProgressListener())); final TransferStatus status = f.prepare(source, null, new TransferStatus().exists(true), new DisabledProgressListener()); assertTrue(status.isExists()); } diff --git a/core/src/test/java/ch/cyberduck/core/transfer/download/CompareFilterTest.java b/core/src/test/java/ch/cyberduck/core/transfer/download/CompareFilterTest.java index 8c20ce3f783..5ed3bf4946c 100755 --- a/core/src/test/java/ch/cyberduck/core/transfer/download/CompareFilterTest.java +++ b/core/src/test/java/ch/cyberduck/core/transfer/download/CompareFilterTest.java @@ -42,34 +42,35 @@ public class CompareFilterTest { @Test public void testAcceptEqual() throws Exception { final CompareFilter filter = new CompareFilter(new DisabledDownloadSymlinkResolver(), - new NullSession(new Host(new TestProtocol())), new DownloadFilterOptions(new Host(new TestProtocol())), new DisabledProgressListener(), - new DefaultComparePathFilter( - new NullSession(new Host(new TestProtocol()))) { - @Override - public Comparison compare(final Path file, final Local local, final ProgressListener listener) { - return Comparison.equal; - } - } + new NullSession(new Host(new TestProtocol())), + new DefaultComparePathFilter( + new NullSession(new Host(new TestProtocol()))) { + @Override + public Comparison compare(final Path file, final Local local, final ProgressListener listener) { + return Comparison.equal; + } + }, new DownloadFilterOptions(new Host(new TestProtocol())) ); final Path file = new Path("/f", EnumSet.of(Path.Type.file)); final Local local = new NullLocal(System.getProperty("java.io.tmpdir"), "f"); - assertFalse(filter.accept(file, local, new TransferStatus().exists(true))); + assertFalse(filter.accept(file, local, new TransferStatus().exists(true), new DisabledProgressListener())); } @Test public void testAcceptDirectory() throws Exception { final CompareFilter filter = new CompareFilter(new DisabledDownloadSymlinkResolver(), - new NullSession(new Host(new TestProtocol())), new DownloadFilterOptions(new Host(new TestProtocol())), new DisabledProgressListener(), - new DefaultComparePathFilter( - new NullSession(new Host(new TestProtocol()))) { - @Override - public Comparison compare(final Path file, final Local local, final ProgressListener listener) { - return Comparison.equal; - } - }); + new NullSession(new Host(new TestProtocol())), + new DefaultComparePathFilter( + new NullSession(new Host(new TestProtocol()))) { + @Override + public Comparison compare(final Path file, final Local local, final ProgressListener listener) { + return Comparison.equal; + } + }, new DownloadFilterOptions(new Host(new TestProtocol())) + ); assertTrue( filter.accept(new Path("/n", EnumSet.of(Path.Type.directory)), new NullLocal("/n"), - new TransferStatus().exists(true))); + new TransferStatus().exists(true), new DisabledProgressListener())); } } diff --git a/core/src/test/java/ch/cyberduck/core/transfer/download/OverwriteFilterTest.java b/core/src/test/java/ch/cyberduck/core/transfer/download/OverwriteFilterTest.java index 7994905cbe5..9c08579cb0e 100755 --- a/core/src/test/java/ch/cyberduck/core/transfer/download/OverwriteFilterTest.java +++ b/core/src/test/java/ch/cyberduck/core/transfer/download/OverwriteFilterTest.java @@ -28,7 +28,7 @@ public void testAccept() throws Exception { OverwriteFilter f = new OverwriteFilter(new DisabledDownloadSymlinkResolver(), new NullSession(new Host(new TestProtocol()))); final Path p = new Path("a", EnumSet.of(Path.Type.file)); p.attributes().setSize(8L); - assertTrue(f.accept(p, new NullLocal("a"), new TransferStatus())); + assertTrue(f.accept(p, new NullLocal("a"), new TransferStatus(), new DisabledProgressListener())); } @Test @@ -39,13 +39,13 @@ public void testAcceptDirectory() throws Exception { public boolean exists() { return false; } - }, new TransferStatus())); + }, new TransferStatus(), new DisabledProgressListener())); assertTrue(f.accept(new Path("a", EnumSet.of(Path.Type.directory)), new NullLocal(System.getProperty("java.io.tmpdir"), "a") { @Override public boolean exists() { return true; } - }, new TransferStatus())); + }, new TransferStatus(), new DisabledProgressListener())); } @Test diff --git a/core/src/test/java/ch/cyberduck/core/transfer/download/ResumeFilterTest.java b/core/src/test/java/ch/cyberduck/core/transfer/download/ResumeFilterTest.java index e7c79b13570..a3bdec4e9c1 100644 --- a/core/src/test/java/ch/cyberduck/core/transfer/download/ResumeFilterTest.java +++ b/core/src/test/java/ch/cyberduck/core/transfer/download/ResumeFilterTest.java @@ -35,7 +35,7 @@ public boolean isDirectory() { public boolean isFile() { return false; } - }, new TransferStatus())); + }, new TransferStatus(), new DisabledProgressListener())); } @Test @@ -48,7 +48,7 @@ public void testAcceptExistsFalse() throws Exception { public boolean exists() { return false; } - }, new TransferStatus())); + }, new TransferStatus(), new DisabledProgressListener())); } @Test @@ -56,12 +56,12 @@ public void testPrepareFile() throws Exception { final Host host = new Host(new TestProtocol()); final NullSession session = new NullTransferSession(host); ResumeFilter f = new ResumeFilter(new DisabledDownloadSymlinkResolver(), session, - new DownloadFilterOptions(host), new DefaultDownloadFeature(session.getFeature(Read.class)) { - @Override - public boolean offset(final Path file) { - return true; - } - }); + new DefaultDownloadFeature(session.getFeature(Read.class)) { + @Override + public boolean offset(final Path file) { + return true; + } + }, new DownloadFilterOptions(host)); Path p = new Path("a", EnumSet.of(Path.Type.file)); final NullLocal local = new NullLocal("~/Downloads", "a") { @Override @@ -96,12 +96,12 @@ public void testPrepareDirectoryExists() throws Exception { final Host host = new Host(new TestProtocol()); final NullSession session = new NullTransferSession(host); ResumeFilter f = new ResumeFilter(new DisabledDownloadSymlinkResolver(), session, - new DownloadFilterOptions(host), new DefaultDownloadFeature(session.getFeature(Read.class)) { - @Override - public boolean offset(final Path file) { - return true; - } - }); + new DefaultDownloadFeature(session.getFeature(Read.class)) { + @Override + public boolean offset(final Path file) { + return true; + } + }, new DownloadFilterOptions(host)); Path p = new Path("a", EnumSet.of(Path.Type.directory)); final NullLocal local = new NullLocal("a") { @Override @@ -128,12 +128,12 @@ public void testPrepareDirectoryExistsFalse() throws Exception { final Host host = new Host(new TestProtocol()); final NullSession session = new NullTransferSession(host); ResumeFilter f = new ResumeFilter(new DisabledDownloadSymlinkResolver(), session, - new DownloadFilterOptions(host), new DefaultDownloadFeature(session.getFeature(Read.class)) { - @Override - public boolean offset(final Path file) { - return true; - } - }); + new DefaultDownloadFeature(session.getFeature(Read.class)) { + @Override + public boolean offset(final Path file) { + return true; + } + }, new DownloadFilterOptions(host)); Path p = new Path("a", EnumSet.of(Path.Type.directory)); final NullLocal local = new NullLocal("a") { @Override diff --git a/core/src/test/java/ch/cyberduck/core/transfer/download/SkipFilterTest.java b/core/src/test/java/ch/cyberduck/core/transfer/download/SkipFilterTest.java index df021a93c67..6c9ba62ac28 100644 --- a/core/src/test/java/ch/cyberduck/core/transfer/download/SkipFilterTest.java +++ b/core/src/test/java/ch/cyberduck/core/transfer/download/SkipFilterTest.java @@ -1,5 +1,6 @@ package ch.cyberduck.core.transfer.download; +import ch.cyberduck.core.DisabledProgressListener; import ch.cyberduck.core.Host; import ch.cyberduck.core.NullLocal; import ch.cyberduck.core.NullSession; @@ -26,8 +27,8 @@ public void testAccept() throws Exception { public boolean exists() { return false; } - }, new TransferStatus().exists(true) - ) + }, new TransferStatus().exists(true), + new DisabledProgressListener()) ); assertFalse(f.accept(new Path("a", EnumSet.of(Path.Type.file)) { }, new NullLocal("a", "b") { @@ -35,8 +36,8 @@ public boolean exists() { public boolean exists() { return true; } - }, new TransferStatus().exists(true) - ) + }, new TransferStatus().exists(true), + new DisabledProgressListener()) ); } @@ -59,8 +60,8 @@ public boolean isDirectory() { public boolean exists() { return true; } - }, new TransferStatus().exists(true) - ) + }, new TransferStatus().exists(true), + new DisabledProgressListener()) ); } } diff --git a/core/src/test/java/ch/cyberduck/core/transfer/synchronisation/SynchronizationPathFilterTest.java b/core/src/test/java/ch/cyberduck/core/transfer/synchronisation/SynchronizationPathFilterTest.java index bb9cdfc8fb8..c45cb4f3697 100644 --- a/core/src/test/java/ch/cyberduck/core/transfer/synchronisation/SynchronizationPathFilterTest.java +++ b/core/src/test/java/ch/cyberduck/core/transfer/synchronisation/SynchronizationPathFilterTest.java @@ -64,7 +64,7 @@ public boolean exists() { new OverwriteFilter(new DownloadSymlinkResolver(Collections.emptyList()), session), new ch.cyberduck.core.transfer.upload.OverwriteFilter(new UploadSymlinkResolver(null, Collections.emptyList()), session), TransferAction.mirror); - assertTrue(mirror.accept(test, local, new TransferStatus().exists(true))); + assertTrue(mirror.accept(test, local, new TransferStatus().exists(true), new DisabledProgressListener())); final TransferStatus status = mirror.prepare(test, local, new TransferStatus().exists(true), new DisabledProgressListener()); assertNotNull(status); assertEquals(1L, status.getLength()); @@ -73,13 +73,13 @@ public boolean exists() { new OverwriteFilter(new DownloadSymlinkResolver(Collections.emptyList()), session), new ch.cyberduck.core.transfer.upload.OverwriteFilter(new UploadSymlinkResolver(null, Collections.emptyList()), session), TransferAction.download); - assertFalse(download.accept(test, local, new TransferStatus().exists(true))); + assertFalse(download.accept(test, local, new TransferStatus().exists(true), new DisabledProgressListener())); final SynchronizationPathFilter upload = new SynchronizationPathFilter( new DefaultComparePathFilter(session), new OverwriteFilter(new DownloadSymlinkResolver(Collections.emptyList()), session), new ch.cyberduck.core.transfer.upload.OverwriteFilter(new UploadSymlinkResolver(null, Collections.emptyList()), session), TransferAction.upload); - assertTrue(upload.accept(test, local, new TransferStatus().exists(true))); + assertTrue(upload.accept(test, local, new TransferStatus().exists(true), new DisabledProgressListener())); } @Test @@ -94,6 +94,6 @@ public Comparison compare(Path file, Local local, final ProgressListener listene new ch.cyberduck.core.transfer.upload.OverwriteFilter(new UploadSymlinkResolver(null, Collections.emptyList()), session), TransferAction.mirror ); - assertTrue(mirror.accept(new Path("/p", EnumSet.of(Path.Type.directory)), null, new TransferStatus().exists(true))); + assertTrue(mirror.accept(new Path("/p", EnumSet.of(Path.Type.directory)), null, new TransferStatus().exists(true), new DisabledProgressListener())); } } diff --git a/core/src/test/java/ch/cyberduck/core/transfer/upload/CompareFilterTest.java b/core/src/test/java/ch/cyberduck/core/transfer/upload/CompareFilterTest.java index 860a7ba7737..abf9eb78b17 100644 --- a/core/src/test/java/ch/cyberduck/core/transfer/upload/CompareFilterTest.java +++ b/core/src/test/java/ch/cyberduck/core/transfer/upload/CompareFilterTest.java @@ -43,13 +43,12 @@ public class CompareFilterTest { public void testAcceptEqual() throws Exception { final Host host = new Host(new TestProtocol()); final CompareFilter filter = new CompareFilter(new DisabledUploadSymlinkResolver(), - new NullSession(host), new UploadFilterOptions(host), new DisabledProgressListener(), - new DefaultComparePathFilter(new NullSession(host)) { - @Override - public Comparison compare(final Path file, final Local local, final ProgressListener listener) { - return Comparison.equal; - } + new NullSession(host), new DefaultComparePathFilter(new NullSession(host)) { + @Override + public Comparison compare(final Path file, final Local local, final ProgressListener listener) { + return Comparison.equal; } + }, new UploadFilterOptions(host) ); final Path file = new Path("/", EnumSet.of(Path.Type.file)); assertFalse(filter.accept(file, new NullLocal("t") { @@ -57,20 +56,20 @@ public Comparison compare(final Path file, final Local local, final ProgressList public boolean exists() { return true; } - }, new TransferStatus().exists(true))); + }, new TransferStatus().exists(true), new DisabledProgressListener())); } @Test public void testAcceptDirectory() throws Exception { final Host host = new Host(new TestProtocol()); final CompareFilter filter = new CompareFilter(new DisabledUploadSymlinkResolver(), - new NullSession(host), new UploadFilterOptions(host), new DisabledProgressListener(), - new DefaultComparePathFilter(new NullSession(host)) { - @Override - public Comparison compare(final Path file, final Local local, final ProgressListener listener) { - return Comparison.equal; - } - }); + new NullSession(host), new DefaultComparePathFilter(new NullSession(host)) { + @Override + public Comparison compare(final Path file, final Local local, final ProgressListener listener) { + return Comparison.equal; + } + }, new UploadFilterOptions(host) + ); assertTrue( filter.accept(new Path("/n", EnumSet.of(Path.Type.directory)), new NullLocal("/n") { @Override @@ -78,6 +77,6 @@ public boolean exists() { return true; } }, - new TransferStatus().exists(true))); + new TransferStatus().exists(true), new DisabledProgressListener())); } } diff --git a/core/src/test/java/ch/cyberduck/core/transfer/upload/OverwriteFilterTest.java b/core/src/test/java/ch/cyberduck/core/transfer/upload/OverwriteFilterTest.java index 6808ac5e526..f145c9fc122 100644 --- a/core/src/test/java/ch/cyberduck/core/transfer/upload/OverwriteFilterTest.java +++ b/core/src/test/java/ch/cyberduck/core/transfer/upload/OverwriteFilterTest.java @@ -12,6 +12,7 @@ import ch.cyberduck.core.Permission; import ch.cyberduck.core.TestProtocol; import ch.cyberduck.core.exception.AccessDeniedException; +import ch.cyberduck.core.exception.BackgroundException; import ch.cyberduck.core.exception.NotfoundException; import ch.cyberduck.core.features.AttributesFinder; import ch.cyberduck.core.features.Find; @@ -37,8 +38,8 @@ public void testAcceptNotFoundFile() throws Exception { public boolean exists() { return false; } - }, new TransferStatus() - )); + }, new TransferStatus(), + new DisabledProgressListener())); } @Test(expected = NotfoundException.class) @@ -51,8 +52,8 @@ public void testAcceptNotFoundDirectory() throws Exception { public boolean exists() { return false; } - }, new TransferStatus() - )); + }, new TransferStatus(), + new DisabledProgressListener())); } @Test @@ -66,7 +67,7 @@ public boolean exists() { return true; } - }, new TransferStatus())); + }, new TransferStatus(), new DisabledProgressListener())); assertTrue(f.accept(new Path("a", EnumSet.of(Path.Type.directory)) { }, new NullLocal("t") { @@ -75,8 +76,8 @@ public boolean exists() { return true; } - }, new TransferStatus() - )); + }, new TransferStatus(), + new DisabledProgressListener())); } @Test @@ -156,9 +157,8 @@ public boolean find(final Path f, final ListProgressListener listener) { return false; } }; - final OverwriteFilter f = new OverwriteFilter(new DisabledUploadSymlinkResolver(), new NullSession(host), + final OverwriteFilter f = new OverwriteFilter(new DisabledUploadSymlinkResolver(), new NullSession(host), find, attributes, new UploadFilterOptions(host).withTemporary(true)); - f.withFinder(find).withAttributes(attributes); final TransferStatus status = f.prepare(file, new NullLocal("t"), new TransferStatus().exists(true), new DisabledProgressListener()); assertTrue(found.get()); f.apply(file, new NullLocal("t"), status, new DisabledProgressListener()); @@ -173,32 +173,46 @@ public boolean find(final Path f, final ListProgressListener listener) { @Test(expected = AccessDeniedException.class) public void testOverrideDirectoryWithFile() throws Exception { - final AbstractUploadFilter f = new OverwriteFilter(new DisabledUploadSymlinkResolver(), new NullSession(new Host(new TestProtocol()))).withFinder( - new Find() { - @Override - public boolean find(final Path file, final ListProgressListener listener) { - if(file.getType().contains(Path.Type.file)) { - return false; + final AbstractUploadFilter f = new OverwriteFilter(new DisabledUploadSymlinkResolver(), new NullSession(new Host(new TestProtocol())), + new Find() { + @Override + public boolean find(final Path file, final ListProgressListener listener) { + if(file.getType().contains(Path.Type.file)) { + return false; + } + return true; } - return true; - } - } + }, + new AttributesFinder() { + @Override + public PathAttributes find(final Path file, final ListProgressListener listener) throws BackgroundException { + return file.attributes(); + } + }, + new UploadFilterOptions(new Host(new TestProtocol())) ); f.prepare(new Path("a", EnumSet.of(Path.Type.file)), new NullLocal(System.getProperty("java.io.tmpdir"), "f"), new TransferStatus().exists(true), new DisabledProgressListener()); } @Test(expected = AccessDeniedException.class) public void testOverrideFileWithDirectory() throws Exception { - final AbstractUploadFilter f = new OverwriteFilter(new DisabledUploadSymlinkResolver(), new NullSession(new Host(new TestProtocol()))).withFinder( - new Find() { - @Override - public boolean find(final Path file, final ListProgressListener listener) { - if(file.getType().contains(Path.Type.file)) { - return true; + final AbstractUploadFilter f = new OverwriteFilter(new DisabledUploadSymlinkResolver(), new NullSession(new Host(new TestProtocol())), + new Find() { + @Override + public boolean find(final Path file, final ListProgressListener listener) { + if(file.getType().contains(Path.Type.file)) { + return true; + } + return false; } - return false; - } - } + }, + new AttributesFinder() { + @Override + public PathAttributes find(final Path file, final ListProgressListener listener) throws BackgroundException { + return file.attributes(); + } + }, + new UploadFilterOptions(new Host(new TestProtocol())) ); f.prepare(new Path("a", EnumSet.of(Path.Type.directory)), new NullLocal(System.getProperty("java.io.tmpdir")), new TransferStatus().exists(true), new DisabledProgressListener()); } diff --git a/core/src/test/java/ch/cyberduck/core/transfer/upload/RenameExistingFilterTest.java b/core/src/test/java/ch/cyberduck/core/transfer/upload/RenameExistingFilterTest.java index 5129f124f9a..8346c378856 100755 --- a/core/src/test/java/ch/cyberduck/core/transfer/upload/RenameExistingFilterTest.java +++ b/core/src/test/java/ch/cyberduck/core/transfer/upload/RenameExistingFilterTest.java @@ -40,7 +40,7 @@ public boolean exists() { return true; } - }, new TransferStatus().exists(true))); + }, new TransferStatus().exists(true), new DisabledProgressListener())); } @Test @@ -152,9 +152,8 @@ public StatusOutputStream write(final Path file, final TransferStatus status, fi } }; final UploadFilterOptions options = new UploadFilterOptions(host).withTemporary(true); - final RenameExistingFilter f = new RenameExistingFilter(new DisabledUploadSymlinkResolver(), session, + final RenameExistingFilter f = new RenameExistingFilter(new DisabledUploadSymlinkResolver(), session, find, attributes, options); - f.withFinder(find).withAttributes(attributes); assertTrue(options.temporary); final TransferStatus status = f.prepare(file, new NullLocal("t"), new TransferStatus().exists(true), new DisabledProgressListener()); f.apply(file, new NullLocal("t"), status, new DisabledProgressListener()); @@ -227,9 +226,8 @@ public StatusOutputStream write(final Path file, final TransferStatus status, fi return null; } }; - final RenameExistingFilter f = new RenameExistingFilter(new DisabledUploadSymlinkResolver(), session, + final RenameExistingFilter f = new RenameExistingFilter(new DisabledUploadSymlinkResolver(), session, find, attributes, new UploadFilterOptions(host).withTemporary(true)); - f.withFinder(find).withAttributes(attributes); final TransferStatus status = f.prepare(file, new NullLocal("/t") { @Override public boolean isDirectory() { diff --git a/core/src/test/java/ch/cyberduck/core/transfer/upload/RenameFilterTest.java b/core/src/test/java/ch/cyberduck/core/transfer/upload/RenameFilterTest.java index 71aa9357d33..41e659c2632 100644 --- a/core/src/test/java/ch/cyberduck/core/transfer/upload/RenameFilterTest.java +++ b/core/src/test/java/ch/cyberduck/core/transfer/upload/RenameFilterTest.java @@ -51,8 +51,9 @@ public boolean find(final Path f, final ListProgressListener listener) { } }; final NullSession session = new NullSession(new Host(new TestProtocol())); - final RenameFilter f = new RenameFilter(new DisabledUploadSymlinkResolver(), session, new UploadFilterOptions(session.getHost()).withTemporary(true)); - f.withFinder(find).withAttributes(attributes); + final RenameFilter f = new RenameFilter(new DisabledUploadSymlinkResolver(), session, + find, attributes, + new UploadFilterOptions(session.getHost()).withTemporary(true)); final TransferStatus status = f.prepare(file, new NullLocal("t/f"), new TransferStatus().exists(true), new DisabledProgressListener()); assertTrue(found.get()); assertFalse(status.isExists()); @@ -91,8 +92,7 @@ public boolean find(final Path f, final ListProgressListener listener) { } }; final NullSession session = new NullSession(new Host(new TestProtocol())); - final RenameFilter f = new RenameFilter(new DisabledUploadSymlinkResolver(), session); - f.withFinder(find).withAttributes(attributes); + final RenameFilter f = new RenameFilter(new DisabledUploadSymlinkResolver(), session, find, attributes); final TransferStatus directoryStatus = f.prepare(directory, new NullLocal("t"), new TransferStatus().exists(true), new DisabledProgressListener()); assertTrue(found.get()); assertFalse(directoryStatus.isExists()); 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 5866b039683..3b86e7d8556 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 @@ -14,6 +14,8 @@ import ch.cyberduck.core.TestProtocol; import ch.cyberduck.core.exception.BackgroundException; import ch.cyberduck.core.features.Find; +import ch.cyberduck.core.shared.DefaultAttributesFinderFeature; +import ch.cyberduck.core.shared.DefaultFindFeature; import ch.cyberduck.core.shared.DefaultUploadFeature; import ch.cyberduck.core.transfer.TransferStatus; import ch.cyberduck.core.transfer.symlink.DisabledUploadSymlinkResolver; @@ -45,7 +47,7 @@ public long getSize() { } }; } - }, new TransferStatus().exists(true))); + }, new TransferStatus().exists(true), new DisabledProgressListener())); } @Test @@ -88,14 +90,14 @@ public long getSize() { }; } - }, new TransferStatus().exists(true))); + }, new TransferStatus().exists(true), new DisabledProgressListener())); } @Test public void testPrepareNoAppend() throws Exception { final Host host = new Host(new TestProtocol()); final ResumeFilter f = new ResumeFilter(new DisabledUploadSymlinkResolver(), new NullSession(host), - new UploadFilterOptions(host).withTemporary(true)); + new UploadFilterOptions(host).withTemporary(true)); final Path t = new Path("t", EnumSet.of(Path.Type.file)); t.attributes().setSize(7L); final TransferStatus status = f.prepare(t, new NullLocal("t"), new TransferStatus().exists(true), new DisabledProgressListener()); @@ -108,14 +110,16 @@ public void testPrepareNoAppend() throws Exception { @Test public void testPrepareAppend() throws Exception { final Host host = new Host(new TestProtocol()); - final ResumeFilter f = new ResumeFilter(new DisabledUploadSymlinkResolver(), new NullSession(host) { + final NullSession session = new NullSession(host) { @Override public AttributedList list(final Path file, final ListProgressListener listener) { final Path f = new Path("t", EnumSet.of(Path.Type.file)); f.attributes().setSize(7L); return new AttributedList<>(Collections.singletonList(f)); } - }, new UploadFilterOptions(host).withTemporary(true)); + }; + final ResumeFilter f = new ResumeFilter(new DisabledUploadSymlinkResolver(), session, new DefaultFindFeature(session), + new DefaultAttributesFinderFeature(session), new UploadFilterOptions(host).withTemporary(true)); final Path t = new Path("t", EnumSet.of(Path.Type.file)); final TransferStatus status = f.prepare(t, new NullLocal("t") { @Override @@ -152,8 +156,8 @@ public AttributedList list(final Path folder, final ListProgressListener l return list; } }; - final ResumeFilter f = new ResumeFilter(new DisabledUploadSymlinkResolver(), session, - new UploadFilterOptions(host).withTemporary(true), new NullUploadFeature()); + final ResumeFilter f = new ResumeFilter(new DisabledUploadSymlinkResolver(), session, new DefaultFindFeature(session), + new DefaultAttributesFinderFeature(session), new NullUploadFeature(), new UploadFilterOptions(host).withTemporary(true)); final long size = 3L; final Path t = new Path("t", EnumSet.of(Path.Type.file)); assertFalse(f.accept(t, new NullLocal("t") { @@ -176,7 +180,7 @@ public boolean isFile() { public boolean exists() { return true; } - }, new TransferStatus().exists(true))); + }, new TransferStatus().exists(true), new DisabledProgressListener())); } @Test @@ -186,13 +190,14 @@ public void testAppendSmallerSize() throws Exception { @Override public AttributedList list(final Path folder, final ListProgressListener listener) throws BackgroundException { final AttributedList list = new AttributedList<>(Collections.singletonList(new Path(folder, "t", EnumSet.of(Path.Type.file)) - .withAttributes(new PathAttributes().withSize(2L)))); + .withAttributes(new PathAttributes().withSize(2L)))); listener.chunk(folder, list); return list; } }; - final ResumeFilter f = new ResumeFilter(new DisabledUploadSymlinkResolver(), session, - new UploadFilterOptions(host).withTemporary(true), new NullUploadFeature()); + final ResumeFilter f = new ResumeFilter(new DisabledUploadSymlinkResolver(), session, new DefaultFindFeature(session), + new DefaultAttributesFinderFeature(session), + new NullUploadFeature(), 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") { @@ -216,7 +221,7 @@ public boolean exists() { return true; } }; - assertTrue(f.accept(t, l, new TransferStatus().exists(true))); + assertTrue(f.accept(t, l, new TransferStatus().exists(true), new DisabledProgressListener())); // Remaining length to transfer is 1 assertEquals(1L, f.prepare(t, l, new TransferStatus().exists(true), new DisabledProgressListener()).getLength()); // Skip first 2 bytes @@ -230,13 +235,13 @@ public void testAppendLargerSize() throws Exception { @Override public AttributedList list(final Path folder, final ListProgressListener listener) throws BackgroundException { final AttributedList list = new AttributedList<>(Collections.singletonList(new Path(folder, "t", EnumSet.of(Path.Type.file)) - .withAttributes(new PathAttributes().withSize(4L)))); + .withAttributes(new PathAttributes().withSize(4L)))); listener.chunk(folder, list); return list; } }; final ResumeFilter f = new ResumeFilter(new DisabledUploadSymlinkResolver(), session, - new UploadFilterOptions(host).withTemporary(true), new DefaultUploadFeature<>(new NullWriteFeature())); + new DefaultUploadFeature<>(new NullWriteFeature()), 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") { @@ -260,7 +265,7 @@ public boolean isFile() { return true; } }; - assertTrue(f.accept(t, l, new TransferStatus().exists(true))); + assertTrue(f.accept(t, l, new TransferStatus().exists(true), new DisabledProgressListener())); assertFalse(f.prepare(t, l, new TransferStatus().exists(true), new DisabledProgressListener()).isAppend()); } } diff --git a/core/src/test/java/ch/cyberduck/core/transfer/upload/SkipFilterTest.java b/core/src/test/java/ch/cyberduck/core/transfer/upload/SkipFilterTest.java index db775c55833..65efc2c3fc9 100644 --- a/core/src/test/java/ch/cyberduck/core/transfer/upload/SkipFilterTest.java +++ b/core/src/test/java/ch/cyberduck/core/transfer/upload/SkipFilterTest.java @@ -1,6 +1,7 @@ package ch.cyberduck.core.transfer.upload; import ch.cyberduck.core.AttributedList; +import ch.cyberduck.core.DisabledProgressListener; import ch.cyberduck.core.Host; import ch.cyberduck.core.ListProgressListener; import ch.cyberduck.core.NullLocal; @@ -46,7 +47,7 @@ public boolean find(Path file, final ListProgressListener listener) { public boolean exists() { return true; } - }, new TransferStatus().exists(true))); + }, new TransferStatus().exists(true), new DisabledProgressListener())); } @Test @@ -56,19 +57,23 @@ public void testAcceptDirectory() throws Exception { public AttributedList list(final Path file, final ListProgressListener listener) { return AttributedList.emptyList(); } - }); - f.withAttributes(new AttributesFinder() { + }, new Find() { + @Override + public boolean find(final Path file, final ListProgressListener listener) { + return false; + } + }, new AttributesFinder() { @Override public PathAttributes find(final Path file, final ListProgressListener listener) { return file.attributes(); } - }); + }, new UploadFilterOptions(new Host(new TestProtocol()))); assertTrue(f.accept(new Path("a", EnumSet.of(Path.Type.directory)), new NullLocal("a") { @Override public boolean exists() { return true; } - }, new TransferStatus().exists(true))); + }, new TransferStatus().exists(true), new DisabledProgressListener())); } @Test(expected = NotfoundException.class) @@ -78,18 +83,22 @@ public void testNotFound() throws Exception { public AttributedList list(final Path file, final ListProgressListener listener) { return AttributedList.emptyList(); } - }); - f.withAttributes(new AttributesFinder() { + }, new Find() { + @Override + public boolean find(final Path file, final ListProgressListener listener) { + return false; + } + }, new AttributesFinder() { @Override public PathAttributes find(final Path file, final ListProgressListener listener) { return file.attributes(); } - }); + }, new UploadFilterOptions(new Host(new TestProtocol()))); assertFalse(f.accept(new Path("a", EnumSet.of(Path.Type.file)), new NullLocal("a") { @Override public boolean exists() { return false; } - }, new TransferStatus().exists(true))); + }, new TransferStatus().exists(true), new DisabledProgressListener())); } } diff --git a/core/src/test/java/ch/cyberduck/core/worker/ConcurrentTransferWorkerTest.java b/core/src/test/java/ch/cyberduck/core/worker/ConcurrentTransferWorkerTest.java index f24fb7159c6..557078f8fa0 100644 --- a/core/src/test/java/ch/cyberduck/core/worker/ConcurrentTransferWorkerTest.java +++ b/core/src/test/java/ch/cyberduck/core/worker/ConcurrentTransferWorkerTest.java @@ -163,7 +163,7 @@ public void transfer(final Session source, final Session destination, fina public AbstractDownloadFilter filter(final Session source, final Session destination, final TransferAction action, final ProgressListener listener) { return new AbstractDownloadFilter(new DisabledDownloadSymlinkResolver(), source, null) { @Override - public boolean accept(final Path file, final Local local, final TransferStatus parent) { + public boolean accept(final Path file, final Local local, final TransferStatus parent, final ProgressListener progress) { assertFalse(transferred.contains(file)); return true; } diff --git a/core/src/test/java/ch/cyberduck/core/worker/SingleTransferWorkerTest.java b/core/src/test/java/ch/cyberduck/core/worker/SingleTransferWorkerTest.java index 10655f0522f..ae819adec8a 100644 --- a/core/src/test/java/ch/cyberduck/core/worker/SingleTransferWorkerTest.java +++ b/core/src/test/java/ch/cyberduck/core/worker/SingleTransferWorkerTest.java @@ -10,13 +10,12 @@ import ch.cyberduck.core.NullLocal; import ch.cyberduck.core.NullSession; import ch.cyberduck.core.Path; -import ch.cyberduck.core.PathAttributes; +import ch.cyberduck.core.PathCache; import ch.cyberduck.core.ProgressListener; import ch.cyberduck.core.Session; import ch.cyberduck.core.TestProtocol; import ch.cyberduck.core.exception.BackgroundException; import ch.cyberduck.core.exception.NotfoundException; -import ch.cyberduck.core.features.AttributesFinder; import ch.cyberduck.core.io.DisabledStreamListener; import ch.cyberduck.core.io.StreamListener; import ch.cyberduck.core.notification.DisabledNotificationService; @@ -30,7 +29,6 @@ import ch.cyberduck.core.transfer.TransferSpeedometer; import ch.cyberduck.core.transfer.TransferStatus; import ch.cyberduck.core.transfer.UploadTransfer; -import ch.cyberduck.core.transfer.download.AbstractDownloadFilter; import org.junit.Test; @@ -196,6 +194,9 @@ public AttributedList list() { return AttributedList.emptyList(); } }; + final PathCache cache = new PathCache(2); + cache.put(root.getParent(), new AttributedList<>(Collections.singletonList(root))); + cache.put(root, new AttributedList<>(Collections.singletonList(child))); final Transfer t = new DownloadTransfer(new Host(new TestProtocol()), root, local) { @Override public void transfer(final Session source, final Session destination, final Path file, Local local, @@ -209,25 +210,8 @@ public void transfer(final Session source, final Session destination, fina assertFalse(segment.isExists()); } } - - @Override - public AbstractDownloadFilter filter(final Session source, final Session destination, final TransferAction action, final ProgressListener listener) { - return super.filter(source, destination, action, listener).withAttributes(new AttributesFinder() { - @Override - public PathAttributes find(final Path file, final ListProgressListener listener) { - return file.attributes(); - } - }); - } - }; - final NullSession session = new NullSession(new Host(new TestProtocol())) { - @Override - public AttributedList list(final Path file, final ListProgressListener listener) { - final AttributedList children = new AttributedList<>(); - children.add(child); - return children; - } - }; + }.withCache(cache); + final NullSession session = new NullSession(new Host(new TestProtocol())); final SingleTransferWorker worker = new SingleTransferWorker(session, session, t, new TransferOptions(), new TransferSpeedometer(t), new DisabledTransferPrompt() { @Override public TransferAction prompt(final TransferItem file) { diff --git a/cryptomator/src/main/java/ch/cyberduck/core/cryptomator/features/CryptoUnixPermission.java b/cryptomator/src/main/java/ch/cyberduck/core/cryptomator/features/CryptoUnixPermission.java index 671e5c4b532..1a86c0711c5 100644 --- a/cryptomator/src/main/java/ch/cyberduck/core/cryptomator/features/CryptoUnixPermission.java +++ b/cryptomator/src/main/java/ch/cyberduck/core/cryptomator/features/CryptoUnixPermission.java @@ -15,7 +15,6 @@ * GNU General Public License for more details. */ -import ch.cyberduck.core.Local; import ch.cyberduck.core.Path; import ch.cyberduck.core.Permission; import ch.cyberduck.core.Session; @@ -43,11 +42,6 @@ public void setUnixOwner(final Path file, final String owner) throws BackgroundE delegate.setUnixOwner(cryptomator.encrypt(session, file), owner); } - @Override - public Permission getDefault(final Local file) { - return delegate.getDefault(file); - } - @Override public Permission getDefault(final EnumSet type) { return delegate.getDefault(type);