diff --git a/core/src/main/java/ch/cyberduck/core/features/Scheduler.java b/core/src/main/java/ch/cyberduck/core/features/Scheduler.java index b5bec51ab7d..07b2de906e4 100644 --- a/core/src/main/java/ch/cyberduck/core/features/Scheduler.java +++ b/core/src/main/java/ch/cyberduck/core/features/Scheduler.java @@ -16,12 +16,23 @@ */ import ch.cyberduck.core.PasswordCallback; -import ch.cyberduck.core.pool.SessionPool; + +import java.util.concurrent.Future; @Optional public interface Scheduler { - R repeat(SessionPool pool, PasswordCallback callback); + /** + * Repeated execution on background thread + */ + Future repeat(PasswordCallback callback); - void shutdown(); + /** + * Single execution on background thread with no delay + */ + Future execute(PasswordCallback callback); + /** + * Shutdown thread pool + */ + void shutdown(); } diff --git a/core/src/main/java/ch/cyberduck/core/shared/AbstractSchedulerFeature.java b/core/src/main/java/ch/cyberduck/core/shared/AbstractSchedulerFeature.java deleted file mode 100644 index d997e4a79b6..00000000000 --- a/core/src/main/java/ch/cyberduck/core/shared/AbstractSchedulerFeature.java +++ /dev/null @@ -1,122 +0,0 @@ -package ch.cyberduck.core.shared; - -/* - * Copyright (c) 2002-2017 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.PasswordCallback; -import ch.cyberduck.core.Path; -import ch.cyberduck.core.Session; -import ch.cyberduck.core.exception.BackgroundException; -import ch.cyberduck.core.exception.ConnectionCanceledException; -import ch.cyberduck.core.exception.LoginFailureException; -import ch.cyberduck.core.features.Scheduler; -import ch.cyberduck.core.pool.SessionPool; -import ch.cyberduck.core.threading.BackgroundActionState; -import ch.cyberduck.core.threading.ScheduledThreadPool; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import java.util.concurrent.TimeUnit; - -public abstract class AbstractSchedulerFeature implements Scheduler { - private static final Logger log = LogManager.getLogger(AbstractSchedulerFeature.class); - - private final long period; - private final ScheduledThreadPool scheduler = new ScheduledThreadPool(); - - public AbstractSchedulerFeature(final long period) { - this.period = period; - } - - @Override - public Void repeat(final SessionPool pool, final PasswordCallback callback) { - scheduler.repeat(new PoolOperator(pool, callback), period, TimeUnit.MILLISECONDS); - return null; - } - - public Void single(final Session session, final PasswordCallback callback, final Path file) { - scheduler.schedule(new SessionOperator(session, callback, file), 0L, TimeUnit.MILLISECONDS); - return null; - } - - protected abstract R operate(Session session, PasswordCallback callback, Path file) throws BackgroundException; - - @Override - public void shutdown() { - log.debug("Shutting down scheduler thread pool"); - scheduler.shutdown(); - } - - private class PoolOperator implements Runnable { - private final SessionPool pool; - private final PasswordCallback callback; - - public PoolOperator(final SessionPool pool, final PasswordCallback callback) { - this.pool = pool; - this.callback = callback; - } - - @Override - public void run() { - try { - final Session session = pool.borrow(BackgroundActionState.running); - try { - AbstractSchedulerFeature.this.operate(session, callback, null); - } - finally { - pool.release(session, null); - } - } - catch(LoginFailureException | ConnectionCanceledException e) { - log.warn("Cancel processing scheduled task after failure {}", e.getMessage()); - AbstractSchedulerFeature.this.shutdown(); - } - catch(BackgroundException e) { - log.warn("Failure processing scheduled task. {}", e.getMessage(), e); - } - catch(Exception e) { - log.error("Failure processing scheduled task {}", e.getMessage(), e); - AbstractSchedulerFeature.this.shutdown(); - } - } - } - - private class SessionOperator implements Runnable { - private final Session session; - private final PasswordCallback callback; - private final Path file; - - public SessionOperator(final Session session, final PasswordCallback callback, final Path file) { - this.session = session; - this.callback = callback; - this.file = file; - } - - @Override - public void run() { - try { - AbstractSchedulerFeature.this.operate(session, callback, file); - } - catch(BackgroundException e) { - log.warn("Failure processing scheduled task. {}", e.getMessage(), e); - } - catch(Exception e) { - log.error("Failure processing scheduled task {}", e.getMessage(), e); - AbstractSchedulerFeature.this.shutdown(); - } - } - } -} diff --git a/core/src/main/java/ch/cyberduck/core/shared/DelegatingSchedulerFeature.java b/core/src/main/java/ch/cyberduck/core/shared/DelegatingSchedulerFeature.java index 9b31c336658..7a3551ab9a8 100644 --- a/core/src/main/java/ch/cyberduck/core/shared/DelegatingSchedulerFeature.java +++ b/core/src/main/java/ch/cyberduck/core/shared/DelegatingSchedulerFeature.java @@ -17,7 +17,8 @@ import ch.cyberduck.core.PasswordCallback; import ch.cyberduck.core.features.Scheduler; -import ch.cyberduck.core.pool.SessionPool; + +import java.util.concurrent.Future; public class DelegatingSchedulerFeature implements Scheduler { @@ -28,9 +29,17 @@ public DelegatingSchedulerFeature(final Scheduler... features) { } @Override - public Void repeat(final SessionPool pool, final PasswordCallback callback) { + public Future repeat(final PasswordCallback callback) { + for(Scheduler scheduler : features) { + scheduler.repeat(callback); + } + return null; + } + + @Override + public Future execute(final PasswordCallback callback) { for(Scheduler scheduler : features) { - scheduler.repeat(pool, callback); + scheduler.execute(callback); } return null; } diff --git a/core/src/main/java/ch/cyberduck/core/shared/OneTimeSchedulerFeature.java b/core/src/main/java/ch/cyberduck/core/shared/OneTimeSchedulerFeature.java index 659dc43ae8c..e6090f3c898 100644 --- a/core/src/main/java/ch/cyberduck/core/shared/OneTimeSchedulerFeature.java +++ b/core/src/main/java/ch/cyberduck/core/shared/OneTimeSchedulerFeature.java @@ -16,40 +16,18 @@ */ import ch.cyberduck.core.PasswordCallback; -import ch.cyberduck.core.Path; -import ch.cyberduck.core.exception.BackgroundException; -import ch.cyberduck.core.features.Scheduler; -import ch.cyberduck.core.pool.SessionPool; -import ch.cyberduck.core.threading.ThreadPool; -import ch.cyberduck.core.threading.ThreadPoolFactory; -import java.util.concurrent.Callable; import java.util.concurrent.Future; -public abstract class OneTimeSchedulerFeature implements Scheduler> { +public abstract class OneTimeSchedulerFeature extends ThreadPoolSchedulerFeature { - private final Path file; - - private final ThreadPool scheduler = ThreadPoolFactory.get("scheduler", 1); - - public OneTimeSchedulerFeature(final Path file) { - this.file = file; - } - - protected abstract R operate(PasswordCallback callback, Path file) throws BackgroundException; - - @Override - public Future repeat(final SessionPool pool, final PasswordCallback callback) { - return scheduler.execute(new Callable() { - @Override - public R call() throws Exception { - return operate(callback, file); - } - }); + public OneTimeSchedulerFeature() { + super(Long.MAX_VALUE); } @Override - public void shutdown() { - scheduler.shutdown(false); + public Future repeat(final PasswordCallback callback) { + // No repeat + return this.execute(callback); } } diff --git a/core/src/main/java/ch/cyberduck/core/shared/ThreadPoolSchedulerFeature.java b/core/src/main/java/ch/cyberduck/core/shared/ThreadPoolSchedulerFeature.java new file mode 100644 index 00000000000..29f9b9fabf0 --- /dev/null +++ b/core/src/main/java/ch/cyberduck/core/shared/ThreadPoolSchedulerFeature.java @@ -0,0 +1,79 @@ +package ch.cyberduck.core.shared; + +/* + * Copyright (c) 2002-2017 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.PasswordCallback; +import ch.cyberduck.core.exception.BackgroundException; +import ch.cyberduck.core.features.Scheduler; +import ch.cyberduck.core.threading.ScheduledThreadPool; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import java.util.concurrent.Future; +import java.util.concurrent.ScheduledFuture; +import java.util.concurrent.TimeUnit; + +public abstract class ThreadPoolSchedulerFeature implements Scheduler { + private static final Logger log = LogManager.getLogger(ThreadPoolSchedulerFeature.class); + + private final long period; + private final ScheduledThreadPool scheduler = new ScheduledThreadPool(); + + public ThreadPoolSchedulerFeature(final long period) { + this.period = period; + } + + @Override + public Future repeat(final PasswordCallback callback) { + return (ScheduledFuture) scheduler.repeat(new FailureAwareRunnable(callback), period, TimeUnit.MILLISECONDS); + } + + @Override + public Future execute(final PasswordCallback callback) { + return (ScheduledFuture) scheduler.schedule(new FailureAwareRunnable(callback), 0L, TimeUnit.MILLISECONDS); + } + + protected abstract R operate(PasswordCallback callback) throws BackgroundException; + + @Override + public void shutdown() { + log.debug("Shutting down scheduler thread pool"); + scheduler.shutdown(); + } + + private final class FailureAwareRunnable implements Runnable { + private final PasswordCallback callback; + + public FailureAwareRunnable(final PasswordCallback callback) { + this.callback = callback; + } + + @Override + public void run() { + try { + ThreadPoolSchedulerFeature.this.operate(callback); + } + catch(BackgroundException e) { + log.warn("Failure processing scheduled task. {}", e.getMessage(), e); + } + catch(Exception e) { + log.error("Failure processing scheduled task {}", e.getMessage(), e); + ThreadPoolSchedulerFeature.this.shutdown(); + } + } + } +} diff --git a/dracoon/src/main/java/ch/cyberduck/core/sds/SDSEncryptionBulkFeature.java b/dracoon/src/main/java/ch/cyberduck/core/sds/SDSEncryptionBulkFeature.java index f1c309014db..29629416b6b 100644 --- a/dracoon/src/main/java/ch/cyberduck/core/sds/SDSEncryptionBulkFeature.java +++ b/dracoon/src/main/java/ch/cyberduck/core/sds/SDSEncryptionBulkFeature.java @@ -21,6 +21,7 @@ import ch.cyberduck.core.exception.BackgroundException; import ch.cyberduck.core.features.Bulk; import ch.cyberduck.core.features.Delete; +import ch.cyberduck.core.features.Scheduler; import ch.cyberduck.core.preferences.HostPreferences; import ch.cyberduck.core.transfer.Transfer; import ch.cyberduck.core.transfer.TransferItem; @@ -91,7 +92,7 @@ public void post(final Transfer.Type type, final Map rooms = this.getRoomEncryptionStatus(files); for(Map.Entry entry : files.entrySet()) { final Path file = entry.getKey().remote; @@ -99,7 +100,7 @@ public void post(final Transfer.Type type, final Map> { +public class SDSMissingFileKeysSchedulerFeature extends ThreadPoolSchedulerFeature> { private static final Logger log = LogManager.getLogger(SDSMissingFileKeysSchedulerFeature.class); - public SDSMissingFileKeysSchedulerFeature() { - this(PreferencesFactory.get().getLong("sds.encryption.missingkeys.scheduler.period")); + private final SDSSession session; + private final SDSNodeIdProvider nodeid; + private final Path file; + + public SDSMissingFileKeysSchedulerFeature(final SDSSession session, final SDSNodeIdProvider nodeid) { + this(session, nodeid, null); + } + + public SDSMissingFileKeysSchedulerFeature(final SDSSession session, final SDSNodeIdProvider nodeid, final Path file) { + this(session, nodeid, file, PreferencesFactory.get().getLong("sds.encryption.missingkeys.scheduler.period")); } - public SDSMissingFileKeysSchedulerFeature(final long period) { + public SDSMissingFileKeysSchedulerFeature(final SDSSession session, final SDSNodeIdProvider nodeid, final Path file, final long period) { super(period); + this.file = file; + this.session = session; + this.nodeid = nodeid; } @Override - public List operate(final Session client, final PasswordCallback callback, final Path file) throws BackgroundException { - final SDSSession session = (SDSSession) client; - final SDSNodeIdProvider nodeid = (SDSNodeIdProvider) session._getFeature(VersionIdProvider.class); + protected List operate(final PasswordCallback callback) throws BackgroundException { try { final UserAccountWrapper account = session.userAccount(); if(!account.isEncryptionEnabled()) { diff --git a/dracoon/src/main/java/ch/cyberduck/core/sds/SDSProtocol.java b/dracoon/src/main/java/ch/cyberduck/core/sds/SDSProtocol.java index bad81b01684..06c9d4b7012 100644 --- a/dracoon/src/main/java/ch/cyberduck/core/sds/SDSProtocol.java +++ b/dracoon/src/main/java/ch/cyberduck/core/sds/SDSProtocol.java @@ -18,7 +18,6 @@ import ch.cyberduck.core.AbstractProtocol; import ch.cyberduck.core.Scheme; import ch.cyberduck.core.features.Pairing; -import ch.cyberduck.core.features.Scheduler; import ch.cyberduck.core.sds.triplecrypt.TripleCryptCleanupFeature; import ch.cyberduck.core.shared.CredentialsCleanupService; import ch.cyberduck.core.shared.DelegatingPairingFeature; @@ -119,9 +118,6 @@ public enum Authorization { @Override @SuppressWarnings("unchecked") public T getFeature(final Class type) { - if(type == Scheduler.class) { - return (T) new SDSMissingFileKeysSchedulerFeature(); - } if(type == Pairing.class) { return (T) new DelegatingPairingFeature(new CredentialsCleanupService(), new TripleCryptCleanupFeature()); } diff --git a/dracoon/src/main/java/ch/cyberduck/core/sds/SDSSession.java b/dracoon/src/main/java/ch/cyberduck/core/sds/SDSSession.java index ecd7452c97e..ba0373dbeec 100644 --- a/dracoon/src/main/java/ch/cyberduck/core/sds/SDSSession.java +++ b/dracoon/src/main/java/ch/cyberduck/core/sds/SDSSession.java @@ -594,6 +594,9 @@ public T _getFeature(final Class type) { if(type == Encryptor.class) { return (T) new SDSTripleCryptEncryptorFeature(this, nodeid); } + if(type == Scheduler.class) { + return (T) new SDSMissingFileKeysSchedulerFeature(this, nodeid); + } return super._getFeature(type); } } diff --git a/dracoon/src/test/java/ch/cyberduck/core/sds/SDSMissingFileKeysSchedulerFeatureTest.java b/dracoon/src/test/java/ch/cyberduck/core/sds/SDSMissingFileKeysSchedulerFeatureTest.java index 65f2983c269..7b497aaf03c 100644 --- a/dracoon/src/test/java/ch/cyberduck/core/sds/SDSMissingFileKeysSchedulerFeatureTest.java +++ b/dracoon/src/test/java/ch/cyberduck/core/sds/SDSMissingFileKeysSchedulerFeatureTest.java @@ -93,13 +93,13 @@ public void testMissingKeys() throws Exception { new StreamCopier(status, status).transfer(new ByteArrayInputStream(content), out); assertTrue(new DefaultFindFeature(session).find(test)); assertEquals(content.length, new SDSAttributesFinderFeature(session, nodeid).find(test).getSize()); - final SDSMissingFileKeysSchedulerFeature background = new SDSMissingFileKeysSchedulerFeature(); - final List processed = background.operate(session, new DisabledPasswordCallback() { + final SDSMissingFileKeysSchedulerFeature background = new SDSMissingFileKeysSchedulerFeature(session, nodeid, test); + final List processed = background.operate(new DisabledPasswordCallback() { @Override public Credentials prompt(final Host bookmark, final String title, final String reason, final LoginOptions options) { return new VaultCredentials("eth[oh8uv4Eesij"); } - }, test); + }); assertTrue(processed.stream().filter(userFileKeySetRequest -> userFileKeySetRequest.getFileId().equals(Long.parseLong(test.attributes().getVersionId()))).findAny().isPresent()); new SDSDeleteFeature(session, nodeid).delete(Collections.singletonList(room), new DisabledLoginCallback(), new Delete.DisabledCallback()); } @@ -160,13 +160,13 @@ public Credentials prompt(final Host bookmark, final String title, final String final FileKey key = new NodesApi(session.getClient()).requestUserFileKey(Long.parseLong(test.attributes().getVersionId()), null, null); final EncryptedFileKey encFileKey = TripleCryptConverter.toCryptoEncryptedFileKey(key); assertEquals(EncryptedFileKey.Version.RSA2048_AES256GCM, encFileKey.getVersion()); - final SDSMissingFileKeysSchedulerFeature background = new SDSMissingFileKeysSchedulerFeature(); - final List processed = background.operate(session, new DisabledPasswordCallback() { + final SDSMissingFileKeysSchedulerFeature background = new SDSMissingFileKeysSchedulerFeature(session, nodeid); + final List processed = background.operate(new DisabledPasswordCallback() { @Override public Credentials prompt(final Host bookmark, final String title, final String reason, final LoginOptions options) { return new VaultCredentials("eth[oh8uv4Eesij"); } - }, null); + }); assertFalse(processed.isEmpty()); boolean found = false; for(UserFileKeySetRequest p : processed) { @@ -176,12 +176,12 @@ public Credentials prompt(final Host bookmark, final String title, final String } } assertTrue(found); - final List empty = new SDSMissingFileKeysSchedulerFeature().operate(session, new DisabledPasswordCallback() { + final List empty = new SDSMissingFileKeysSchedulerFeature(session, nodeid).operate(new DisabledPasswordCallback() { @Override public Credentials prompt(final Host bookmark, final String title, final String reason, final LoginOptions options) { return new VaultCredentials("eth[oh8uv4Eesij"); } - }, null); + }); assertTrue(empty.isEmpty()); assertEquals(2, userApi.requestUserKeyPairs(null, null).size()); new SDSDeleteFeature(session, nodeid).delete(Collections.singletonList(room), new DisabledLoginCallback(), new Delete.DisabledCallback()); @@ -208,9 +208,9 @@ public void testWrongPassword() throws Exception { new StreamCopier(status, status).transfer(new ByteArrayInputStream(content), out); assertTrue(new DefaultFindFeature(session).find(test)); assertEquals(content.length, new SDSAttributesFinderFeature(session, nodeid).find(test).getSize()); - final SDSMissingFileKeysSchedulerFeature background = new SDSMissingFileKeysSchedulerFeature(); + final SDSMissingFileKeysSchedulerFeature background = new SDSMissingFileKeysSchedulerFeature(session, nodeid); final AtomicBoolean prompt = new AtomicBoolean(); - final List processed = background.operate(session, new DisabledPasswordCallback() { + final List processed = background.operate(new DisabledPasswordCallback() { @Override public Credentials prompt(final Host bookmark, final String title, final String reason, final LoginOptions options) throws LoginCanceledException { if(prompt.get()) { @@ -219,7 +219,7 @@ public Credentials prompt(final Host bookmark, final String title, final String prompt.set(true); return new VaultCredentials("n"); } - }, null); + }); assertTrue(prompt.get()); } } diff --git a/openstack/src/main/java/ch/cyberduck/core/openstack/SwiftAccountLoader.java b/openstack/src/main/java/ch/cyberduck/core/openstack/SwiftAccountLoader.java index 09c0b05e9ea..e9d4e93eaad 100644 --- a/openstack/src/main/java/ch/cyberduck/core/openstack/SwiftAccountLoader.java +++ b/openstack/src/main/java/ch/cyberduck/core/openstack/SwiftAccountLoader.java @@ -18,7 +18,6 @@ import ch.cyberduck.core.AsciiRandomStringService; import ch.cyberduck.core.DefaultIOExceptionMappingService; import ch.cyberduck.core.PasswordCallback; -import ch.cyberduck.core.Path; import ch.cyberduck.core.exception.BackgroundException; import ch.cyberduck.core.shared.OneTimeSchedulerFeature; @@ -29,7 +28,6 @@ import java.io.IOException; import java.util.Collections; -import java.util.EnumSet; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; @@ -43,12 +41,11 @@ public class SwiftAccountLoader extends OneTimeSchedulerFeature operate(final PasswordCallback callback, final Path file) throws BackgroundException { + protected Map operate(final PasswordCallback callback) throws BackgroundException { final Map accounts = new ConcurrentHashMap<>(); for(Region region : session.getClient().getRegions()) { try { diff --git a/openstack/src/main/java/ch/cyberduck/core/openstack/SwiftContainerSizeLoader.java b/openstack/src/main/java/ch/cyberduck/core/openstack/SwiftContainerSizeLoader.java index 22211141c85..45acd8743c2 100644 --- a/openstack/src/main/java/ch/cyberduck/core/openstack/SwiftContainerSizeLoader.java +++ b/openstack/src/main/java/ch/cyberduck/core/openstack/SwiftContainerSizeLoader.java @@ -36,15 +36,16 @@ public class SwiftContainerSizeLoader extends OneTimeSchedulerFeature { private final SwiftSession session; private final SwiftRegionService regionService; + private final Path container; public SwiftContainerSizeLoader(final SwiftSession session, final SwiftRegionService regionService, final Path container) { - super(container); this.session = session; this.regionService = regionService; + this.container = container; } @Override - protected Long operate(final PasswordCallback callback, final Path container) throws BackgroundException { + protected Long operate(final PasswordCallback callback) throws BackgroundException { try { return session.getClient().getContainerInfo(regionService.lookup(container), container.getName()).getTotalSize(); } diff --git a/openstack/src/main/java/ch/cyberduck/core/openstack/SwiftDistributionConfigurationLoader.java b/openstack/src/main/java/ch/cyberduck/core/openstack/SwiftDistributionConfigurationLoader.java index 6ce72347edb..eb3ffe00eae 100644 --- a/openstack/src/main/java/ch/cyberduck/core/openstack/SwiftDistributionConfigurationLoader.java +++ b/openstack/src/main/java/ch/cyberduck/core/openstack/SwiftDistributionConfigurationLoader.java @@ -23,13 +23,13 @@ import ch.cyberduck.core.cdn.Distribution; import ch.cyberduck.core.cdn.DistributionConfiguration; import ch.cyberduck.core.exception.BackgroundException; +import ch.cyberduck.core.features.Home; import ch.cyberduck.core.shared.OneTimeSchedulerFeature; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import java.util.Collections; -import java.util.EnumSet; import java.util.LinkedHashSet; import java.util.Set; @@ -42,18 +42,17 @@ public class SwiftDistributionConfigurationLoader extends OneTimeSchedulerFeatur private final SwiftSession session; public SwiftDistributionConfigurationLoader(final SwiftSession session) { - super(new Path(String.valueOf(Path.DELIMITER), EnumSet.of(Path.Type.volume, Path.Type.directory))); this.session = session; } @Override - protected Set operate(final PasswordCallback callback, final Path file) throws BackgroundException { + protected Set operate(final PasswordCallback callback) throws BackgroundException { final DistributionConfiguration feature = session.getFeature(DistributionConfiguration.class); if(null == feature) { return Collections.emptySet(); } - final AttributedList containers = new SwiftContainerListService(session, new SwiftLocationFeature.SwiftRegion(session.getHost().getRegion())) - .list(file, new DisabledListProgressListener()); + final AttributedList containers = new SwiftContainerListService(session, + new SwiftLocationFeature.SwiftRegion(session.getHost().getRegion())).list(Home.ROOT, new DisabledListProgressListener()); final Set distributions = new LinkedHashSet<>(); for(Path container : containers) { for(Distribution.Method method : feature.getMethods(container)) { diff --git a/openstack/src/main/java/ch/cyberduck/core/openstack/SwiftSession.java b/openstack/src/main/java/ch/cyberduck/core/openstack/SwiftSession.java index 7fd889e1098..30735d3850d 100644 --- a/openstack/src/main/java/ch/cyberduck/core/openstack/SwiftSession.java +++ b/openstack/src/main/java/ch/cyberduck/core/openstack/SwiftSession.java @@ -201,8 +201,8 @@ public Distribution read(final Path container, final Distribution.Method method, return (T) new DelegatingSchedulerFeature( new SwiftAccountLoader(this) { @Override - public Map operate(final PasswordCallback callback, final Path container) throws BackgroundException { - final Map result = super.operate(callback, container); + protected Map operate(final PasswordCallback callback) throws BackgroundException { + final Map result = super.operate(callback); // Only executed single time accounts.putAll(result); return result; diff --git a/openstack/src/test/java/ch/cyberduck/core/openstack/SwiftAccountLoaderTest.java b/openstack/src/test/java/ch/cyberduck/core/openstack/SwiftAccountLoaderTest.java index 36bf287e486..c65773fb3f4 100644 --- a/openstack/src/test/java/ch/cyberduck/core/openstack/SwiftAccountLoaderTest.java +++ b/openstack/src/test/java/ch/cyberduck/core/openstack/SwiftAccountLoaderTest.java @@ -15,7 +15,7 @@ * GNU General Public License for more details. */ -import ch.cyberduck.core.DisabledLoginCallback; +import ch.cyberduck.core.DisabledPasswordCallback; import ch.cyberduck.core.Path; import ch.cyberduck.test.IntegrationTest; @@ -32,6 +32,6 @@ public class SwiftAccountLoaderTest extends AbstractSwiftTest { @Test public void testOperate() throws Exception { final Path container = new Path("test.cyberduck.ch", EnumSet.of(Path.Type.directory, Path.Type.volume)); - assertFalse(new SwiftAccountLoader(session).operate(new DisabledLoginCallback(), container).isEmpty()); + assertFalse(new SwiftAccountLoader(session).operate(new DisabledPasswordCallback()).isEmpty()); } } diff --git a/openstack/src/test/java/ch/cyberduck/core/openstack/SwiftUrlProviderTest.java b/openstack/src/test/java/ch/cyberduck/core/openstack/SwiftUrlProviderTest.java index dd82219dafc..9c5ee654f67 100644 --- a/openstack/src/test/java/ch/cyberduck/core/openstack/SwiftUrlProviderTest.java +++ b/openstack/src/test/java/ch/cyberduck/core/openstack/SwiftUrlProviderTest.java @@ -47,16 +47,14 @@ public class SwiftUrlProviderTest extends AbstractSwiftTest { public void testGet() throws Exception { final Path container = new Path("test.cyberduck.ch", EnumSet.of(Path.Type.directory, Path.Type.volume)); container.attributes().setRegion("IAD"); - final Map accounts = new SwiftAccountLoader(session).operate(new DisabledPasswordCallback(), - new Path(String.valueOf(Path.DELIMITER), EnumSet.of(Path.Type.volume, Path.Type.directory))); + final Map accounts = new SwiftAccountLoader(session).operate(new DisabledPasswordCallback()); assertEquals("https://storage101.iad3.clouddrive.com/v1/MossoCloudFS_59113590-c679-46c3-bf62-9d7c3d5176ee/test.cyberduck.ch/f", new SwiftUrlProvider(session, accounts).toUrl(new Path(container, "f", EnumSet.of(Path.Type.file))).find(DescriptiveUrl.Type.provider).getUrl()); } @Test public void testSigned() throws Exception { - final Map accounts = new SwiftAccountLoader(session).operate(new DisabledPasswordCallback(), - new Path(String.valueOf(Path.DELIMITER), EnumSet.of(Path.Type.volume, Path.Type.directory))); + final Map accounts = new SwiftAccountLoader(session).operate(new DisabledPasswordCallback()); final UrlProvider provider = new SwiftUrlProvider(session, accounts); final Path container = new Path("test.cyberduck.ch", EnumSet.of(Path.Type.directory, Path.Type.volume)); container.attributes().setRegion("IAD"); diff --git a/osx/src/main/java/ch/cyberduck/ui/cocoa/controller/BrowserController.java b/osx/src/main/java/ch/cyberduck/ui/cocoa/controller/BrowserController.java index bc333c64f8c..1d00460194c 100644 --- a/osx/src/main/java/ch/cyberduck/ui/cocoa/controller/BrowserController.java +++ b/osx/src/main/java/ch/cyberduck/ui/cocoa/controller/BrowserController.java @@ -3333,7 +3333,7 @@ public void cleanup(final Path workdir) { securityLabel.setEnabled(pool.getFeature(X509TrustManager.class) != null); scheduler = pool.getFeature(Scheduler.class); if(scheduler != null) { - scheduler.repeat(pool, PasswordCallbackFactory.get(BrowserController.this)); + scheduler.repeat(PasswordCallbackFactory.get(BrowserController.this)); } } } diff --git a/s3/src/main/java/ch/cyberduck/core/cloudfront/CloudFrontDistributionConfigurationPreloader.java b/s3/src/main/java/ch/cyberduck/core/cloudfront/CloudFrontDistributionConfigurationPreloader.java index 7974d6d61b1..bb0535014f9 100644 --- a/s3/src/main/java/ch/cyberduck/core/cloudfront/CloudFrontDistributionConfigurationPreloader.java +++ b/s3/src/main/java/ch/cyberduck/core/cloudfront/CloudFrontDistributionConfigurationPreloader.java @@ -23,8 +23,8 @@ import ch.cyberduck.core.cdn.Distribution; import ch.cyberduck.core.cdn.DistributionConfiguration; import ch.cyberduck.core.exception.BackgroundException; +import ch.cyberduck.core.features.Home; import ch.cyberduck.core.s3.S3BucketListService; -import ch.cyberduck.core.s3.S3LocationFeature; import ch.cyberduck.core.s3.S3Session; import ch.cyberduck.core.shared.OneTimeSchedulerFeature; @@ -32,7 +32,6 @@ import org.apache.logging.log4j.Logger; import java.util.Collections; -import java.util.EnumSet; import java.util.LinkedHashSet; import java.util.Set; @@ -42,18 +41,16 @@ public class CloudFrontDistributionConfigurationPreloader extends OneTimeSchedul private final S3Session session; public CloudFrontDistributionConfigurationPreloader(final S3Session session) { - super(new Path(String.valueOf(Path.DELIMITER), EnumSet.of(Path.Type.volume, Path.Type.directory))); this.session = session; } @Override - protected Set operate(final PasswordCallback callback, final Path file) throws BackgroundException { + protected Set operate(final PasswordCallback callback) throws BackgroundException { final DistributionConfiguration feature = session.getFeature(DistributionConfiguration.class); if(null == feature) { return Collections.emptySet(); } - final AttributedList containers = new S3BucketListService(session) - .list(file, new DisabledListProgressListener()); + final AttributedList containers = new S3BucketListService(session).list(Home.ROOT, new DisabledListProgressListener()); final Set distributions = new LinkedHashSet<>(); for(Path container : containers) { for(Distribution.Method method : feature.getMethods(container)) {