diff --git a/azure/src/main/java/ch/cyberduck/core/azure/AzureCopyFeature.java b/azure/src/main/java/ch/cyberduck/core/azure/AzureCopyFeature.java index d929d64755d..81472b140a2 100644 --- a/azure/src/main/java/ch/cyberduck/core/azure/AzureCopyFeature.java +++ b/azure/src/main/java/ch/cyberduck/core/azure/AzureCopyFeature.java @@ -70,11 +70,11 @@ public Path copy(final Path source, final Path copy, final TransferStatus status } @Override - public void preflight(final Path source, final Path target) throws BackgroundException { + public void preflight(final Path source, final Path directory, final String filename) throws BackgroundException { if(containerService.isContainer(source)) { throw new UnsupportedException(MessageFormat.format(LocaleFactory.localizedString("Cannot copy {0}", "Error"), source.getName())).withFile(source); } - if(containerService.isContainer(target)) { + if(containerService.isContainer(directory)) { throw new UnsupportedException(MessageFormat.format(LocaleFactory.localizedString("Cannot copy {0}", "Error"), source.getName())).withFile(source); } } diff --git a/azure/src/main/java/ch/cyberduck/core/azure/AzureMoveFeature.java b/azure/src/main/java/ch/cyberduck/core/azure/AzureMoveFeature.java index f92bc89da76..299a993136a 100644 --- a/azure/src/main/java/ch/cyberduck/core/azure/AzureMoveFeature.java +++ b/azure/src/main/java/ch/cyberduck/core/azure/AzureMoveFeature.java @@ -41,8 +41,8 @@ public AzureMoveFeature(final AzureSession session) { } @Override - public void preflight(final Path source, final Path target) throws BackgroundException { - proxy.preflight(source, target); + public void preflight(final Path source, final Path directory, final String filename) throws BackgroundException { + proxy.preflight(source, directory, filename); delete.preflight(source); } diff --git a/azure/src/test/java/ch/cyberduck/core/azure/AzureCopyFeatureTest.java b/azure/src/test/java/ch/cyberduck/core/azure/AzureCopyFeatureTest.java index 64eae9170b1..3f2e9d38c5b 100644 --- a/azure/src/test/java/ch/cyberduck/core/azure/AzureCopyFeatureTest.java +++ b/azure/src/test/java/ch/cyberduck/core/azure/AzureCopyFeatureTest.java @@ -43,9 +43,9 @@ public void testCopy() throws Exception { final Path test = new AzureTouchFeature(session).touch( new Path(container, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)), new TransferStatus()); final AzureCopyFeature feature = new AzureCopyFeature(session); - assertThrows(UnsupportedException.class, () -> feature.preflight(container, test)); + assertThrows(UnsupportedException.class, () -> feature.preflight(container, container, test.getName())); try { - feature.preflight(container, test); + feature.preflight(container, container, test.getName()); } catch(UnsupportedException e) { assertEquals("Unsupported", e.getMessage()); diff --git a/azure/src/test/java/ch/cyberduck/core/azure/AzureMoveFeatureTest.java b/azure/src/test/java/ch/cyberduck/core/azure/AzureMoveFeatureTest.java index 8d8a0dc28f1..d4b8e9cde5c 100644 --- a/azure/src/test/java/ch/cyberduck/core/azure/AzureMoveFeatureTest.java +++ b/azure/src/test/java/ch/cyberduck/core/azure/AzureMoveFeatureTest.java @@ -39,8 +39,8 @@ public void testMove() throws Exception { @Test public void testSupport() { final Path c = new Path("/c", EnumSet.of(Path.Type.directory)); - assertFalse(new AzureMoveFeature(session).isSupported(c, c)); + assertFalse(new AzureMoveFeature(session).isSupported(c, c.getParent(), c.getName())); final Path cf = new Path("/c/f", EnumSet.of(Path.Type.directory)); - assertTrue(new AzureMoveFeature(session).isSupported(cf, cf)); + assertTrue(new AzureMoveFeature(session).isSupported(cf, cf.getParent(), cf.getName())); } } diff --git a/backblaze/src/main/java/ch/cyberduck/core/b2/B2CopyFeature.java b/backblaze/src/main/java/ch/cyberduck/core/b2/B2CopyFeature.java index ac7dc8fd387..e35b63c4340 100644 --- a/backblaze/src/main/java/ch/cyberduck/core/b2/B2CopyFeature.java +++ b/backblaze/src/main/java/ch/cyberduck/core/b2/B2CopyFeature.java @@ -65,17 +65,17 @@ public Path copy(final Path source, final Path target, final TransferStatus stat } @Override - public void preflight(final Path source, final Path target) throws BackgroundException { + public void preflight(final Path source, final Path directory, final String filename) throws BackgroundException { if(source.getType().contains(Path.Type.upload)) { throw new UnsupportedException(MessageFormat.format(LocaleFactory.localizedString("Cannot copy {0}", "Error"), source.getName())).withFile(source); } if(containerService.isContainer(source)) { throw new UnsupportedException(MessageFormat.format(LocaleFactory.localizedString("Cannot copy {0}", "Error"), source.getName())).withFile(source); } - if(containerService.isContainer(target)) { + if(directory.isRoot()) { throw new UnsupportedException(MessageFormat.format(LocaleFactory.localizedString("Cannot copy {0}", "Error"), source.getName())).withFile(source); } - if(!new SimplePathPredicate(containerService.getContainer(source)).test(containerService.getContainer(target))) { + if(!new SimplePathPredicate(containerService.getContainer(source)).test(containerService.getContainer(directory))) { throw new UnsupportedException(MessageFormat.format(LocaleFactory.localizedString("Cannot copy {0}", "Error"), source.getName())).withFile(source); } } diff --git a/backblaze/src/main/java/ch/cyberduck/core/b2/B2MoveFeature.java b/backblaze/src/main/java/ch/cyberduck/core/b2/B2MoveFeature.java index 5d6cc881647..481817097e2 100644 --- a/backblaze/src/main/java/ch/cyberduck/core/b2/B2MoveFeature.java +++ b/backblaze/src/main/java/ch/cyberduck/core/b2/B2MoveFeature.java @@ -34,7 +34,7 @@ public class B2MoveFeature implements Move { private final PathContainerService containerService - = new B2PathContainerService(); + = new B2PathContainerService(); private final B2Session session; private final B2VersionIdProvider fileid; @@ -54,11 +54,11 @@ public Path move(final Path source, final Path target, final TransferStatus stat } @Override - public void preflight(final Path source, final Path target) throws BackgroundException { + public void preflight(final Path source, final Path directory, final String filename) throws BackgroundException { if(containerService.isContainer(source)) { throw new UnsupportedException(MessageFormat.format(LocaleFactory.localizedString("Cannot rename {0}", "Error"), source.getName())).withFile(source); } - proxy.preflight(source, target); + proxy.preflight(source, directory, filename); } @Override diff --git a/backblaze/src/main/java/ch/cyberduck/core/b2/B2ThresholdCopyFeature.java b/backblaze/src/main/java/ch/cyberduck/core/b2/B2ThresholdCopyFeature.java index 73cf73e076a..42569bafa13 100644 --- a/backblaze/src/main/java/ch/cyberduck/core/b2/B2ThresholdCopyFeature.java +++ b/backblaze/src/main/java/ch/cyberduck/core/b2/B2ThresholdCopyFeature.java @@ -56,8 +56,8 @@ public Path copy(final Path source, final Path target, final TransferStatus stat } @Override - public void preflight(final Path source, final Path target) throws BackgroundException { - new B2CopyFeature(session, fileid).preflight(source, target); + public void preflight(final Path source, final Path directory, final String filename) throws BackgroundException { + new B2CopyFeature(session, fileid).preflight(source, directory, filename); } @Override diff --git a/backblaze/src/test/java/ch/cyberduck/core/b2/B2CopyFeatureTest.java b/backblaze/src/test/java/ch/cyberduck/core/b2/B2CopyFeatureTest.java index 92440db969a..f135f590fd5 100644 --- a/backblaze/src/test/java/ch/cyberduck/core/b2/B2CopyFeatureTest.java +++ b/backblaze/src/test/java/ch/cyberduck/core/b2/B2CopyFeatureTest.java @@ -46,9 +46,9 @@ public void testCopy() throws Exception { final Path test = new B2TouchFeature(session, fileid).touch(new Path(container, name, EnumSet.of(Path.Type.file)), new TransferStatus()); assertTrue(new B2FindFeature(session, fileid).find(test)); final B2CopyFeature feature = new B2CopyFeature(session, fileid); - assertThrows(UnsupportedException.class, () -> feature.preflight(container, test)); + assertThrows(UnsupportedException.class, () -> feature.preflight(container, test.getParent(), test.getName())); try { - feature.preflight(container, test); + feature.preflight(container, test.getParent(), test.getName()); } catch(UnsupportedException e) { assertEquals("Unsupported", e.getMessage()); diff --git a/box/src/main/java/ch/cyberduck/core/box/BoxCopyFeature.java b/box/src/main/java/ch/cyberduck/core/box/BoxCopyFeature.java index 8ad6e33db7a..916503a5436 100644 --- a/box/src/main/java/ch/cyberduck/core/box/BoxCopyFeature.java +++ b/box/src/main/java/ch/cyberduck/core/box/BoxCopyFeature.java @@ -87,9 +87,9 @@ public EnumSet features(final Path source, final Path target) { } @Override - public void preflight(final Path source, final Path target) throws BackgroundException { - if(!BoxTouchFeature.validate(target.getName())) { - throw new InvalidFilenameException(MessageFormat.format(LocaleFactory.localizedString("Cannot create {0}", "Error"), target.getName())); + public void preflight(final Path source, final Path directory, final String filename) throws BackgroundException { + if(!BoxTouchFeature.validate(filename)) { + throw new InvalidFilenameException(MessageFormat.format(LocaleFactory.localizedString("Cannot create {0}", "Error"), filename)); } } } diff --git a/box/src/main/java/ch/cyberduck/core/box/BoxMoveFeature.java b/box/src/main/java/ch/cyberduck/core/box/BoxMoveFeature.java index 7abf03c14c6..59fc0842738 100644 --- a/box/src/main/java/ch/cyberduck/core/box/BoxMoveFeature.java +++ b/box/src/main/java/ch/cyberduck/core/box/BoxMoveFeature.java @@ -93,9 +93,9 @@ public EnumSet features(final Path source, final Path target) { } @Override - public void preflight(final Path source, final Path target) throws BackgroundException { - if(!BoxTouchFeature.validate(target.getName())) { - throw new InvalidFilenameException(MessageFormat.format(LocaleFactory.localizedString("Cannot create {0}", "Error"), target.getName())); + public void preflight(final Path source, final Path directory, final String filename) throws BackgroundException { + if(!BoxTouchFeature.validate(filename)) { + throw new InvalidFilenameException(MessageFormat.format(LocaleFactory.localizedString("Cannot create {0}", "Error"), filename)); } } } diff --git a/core/src/main/java/ch/cyberduck/core/features/Copy.java b/core/src/main/java/ch/cyberduck/core/features/Copy.java index 8b470875a52..15e864d67d4 100644 --- a/core/src/main/java/ch/cyberduck/core/features/Copy.java +++ b/core/src/main/java/ch/cyberduck/core/features/Copy.java @@ -55,12 +55,13 @@ default boolean isRecursive(final Path source, final Path target) { /** * @param source Source file or folder - * @param target Target file or folder + * @param folder Target folder + * @param filename Target filename * @return False if not supported for given files */ - default boolean isSupported(final Path source, final Path target) { + default boolean isSupported(final Path source, final Path folder, final String filename) { try { - this.preflight(source, target); + this.preflight(source, folder, filename); return true; } catch(BackgroundException e) { @@ -77,12 +78,15 @@ default Copy withTarget(final Session session) { } /** + * @param source Existing file or folder + * @param directory Target directory + * @param filename Target filename * @throws AccessDeniedException Permission failure to create target directory * @throws UnsupportedException Copy operation not supported for source * @throws InvalidFilenameException Target filename not supported */ - default void preflight(final Path source, final Path target) throws BackgroundException { - if(!target.getParent().attributes().getPermission().isWritable()) { + default void preflight(final Path source, final Path directory, final String filename) throws BackgroundException { + if(!directory.getParent().attributes().getPermission().isWritable()) { throw new UnsupportedException(MessageFormat.format(LocaleFactory.localizedString("Cannot copy {0}", "Error"), source.getName())).withFile(source); } diff --git a/core/src/main/java/ch/cyberduck/core/features/Move.java b/core/src/main/java/ch/cyberduck/core/features/Move.java index 8c39eb1e215..f9fc86c4fba 100644 --- a/core/src/main/java/ch/cyberduck/core/features/Move.java +++ b/core/src/main/java/ch/cyberduck/core/features/Move.java @@ -53,13 +53,14 @@ default boolean isRecursive(final Path source, final Path target) { } /** - * @param source Source file or folder - * @param target Target file or folder + * @param source Source file or folder + * @param directory Target directory + * @param filename Target filename * @return False if not supported for given files */ - default boolean isSupported(final Path source, final Path target) { + default boolean isSupported(final Path source, final Path directory, final String filename) { try { - this.preflight(source, target); + this.preflight(source, directory, filename); return true; } catch(BackgroundException e) { @@ -76,12 +77,15 @@ default Move withTarget(Session session) { } /** + * @param source Existing file or folder + * @param directory Target directory + * @param filename Target filename * @throws AccessDeniedException Permission failure for target parent directory * @throws UnsupportedException Move operation not supported for source * @throws InvalidFilenameException Target filename not supported */ - default void preflight(final Path source, final Path target) throws BackgroundException { - if(!target.getParent().attributes().getPermission().isWritable()) { + default void preflight(final Path source, final Path directory, final String filename) throws BackgroundException { + if(!directory.getParent().attributes().getPermission().isWritable()) { throw new AccessDeniedException(MessageFormat.format(LocaleFactory.localizedString("Cannot rename {0}", "Error"), source.getName())).withFile(source); } @@ -91,9 +95,9 @@ default void preflight(final Path source, final Path target) throws BackgroundEx /** * @return Supported features */ - default EnumSet features(Path source, Path target) { - return EnumSet.noneOf(Flags.class); - } + default EnumSet features(Path source, Path target) { + return EnumSet.noneOf(Flags.class); + } /** * Feature flags diff --git a/core/src/main/java/ch/cyberduck/core/shared/DefaultCopyFeature.java b/core/src/main/java/ch/cyberduck/core/shared/DefaultCopyFeature.java index 4275189032f..afb1af90c02 100644 --- a/core/src/main/java/ch/cyberduck/core/shared/DefaultCopyFeature.java +++ b/core/src/main/java/ch/cyberduck/core/shared/DefaultCopyFeature.java @@ -72,7 +72,7 @@ public Path copy(final Path source, final Path target, final TransferStatus stat } @Override - public void preflight(final Path source, final Path target) throws BackgroundException { + public void preflight(final Path source, final Path directory, final String filename) throws BackgroundException { switch(from.getHost().getProtocol().getType()) { case ftp: case irods: diff --git a/core/src/main/java/ch/cyberduck/core/shared/DefaultVersioningFeature.java b/core/src/main/java/ch/cyberduck/core/shared/DefaultVersioningFeature.java index a063d7f0640..333c0f8fa33 100644 --- a/core/src/main/java/ch/cyberduck/core/shared/DefaultVersioningFeature.java +++ b/core/src/main/java/ch/cyberduck/core/shared/DefaultVersioningFeature.java @@ -98,7 +98,7 @@ public void setConfiguration(final Path container, final PasswordCallback prompt public boolean save(final Path file) throws BackgroundException { final Path version = new Path(provider.provide(file), formatter.toVersion(file.getName()), file.getType()); final Move feature = session.getFeature(Move.class); - if(!feature.isSupported(file, version)) { + if(!feature.isSupported(file, version.getParent(), version.getName())) { log.warn(String.format("Skip saving version for %s", file)); return false; } diff --git a/core/src/main/java/ch/cyberduck/core/shared/DisabledMoveFeature.java b/core/src/main/java/ch/cyberduck/core/shared/DisabledMoveFeature.java index 87c6dff8d74..92600afb69d 100644 --- a/core/src/main/java/ch/cyberduck/core/shared/DisabledMoveFeature.java +++ b/core/src/main/java/ch/cyberduck/core/shared/DisabledMoveFeature.java @@ -36,7 +36,7 @@ public Path move(final Path file, final Path renamed, final TransferStatus statu } @Override - public void preflight(final Path source, final Path target) throws BackgroundException { + public void preflight(final Path source, final Path directory, final String filename) throws BackgroundException { throw new AccessDeniedException(LocaleFactory.localizedString("Unsupported", "Error")); } } 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 15427522aaf..0b735b12725 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 @@ -157,15 +157,14 @@ public TransferStatus prepare(final Path file, final Local local, final Transfer } if(options.temporary) { final Move feature = session.getFeature(Move.class); - final Path renamed = new Path(file.getParent(), - MessageFormat.format(preferences.getProperty("queue.upload.file.temporary.format"), - file.getName(), new AlphanumericRandomStringService().random()), file.getType()); - if(feature.isSupported(file, renamed)) { + final String renamed = MessageFormat.format(preferences.getProperty("queue.upload.file.temporary.format"), + file.getName(), new AlphanumericRandomStringService().random()); + if(feature.isSupported(file, file.getParent(), renamed)) { if(log.isDebugEnabled()) { log.debug(String.format("Set temporary filename %s", renamed)); } // Set target name after transfer - status.withRename(renamed).withDisplayname(file); + status.withRename(new Path(file.getParent(), renamed, file.getType())).withDisplayname(file); // Remember status of target file for later rename status.getDisplayname().exists(status.isExists()); // Keep exist flag for subclasses to determine additional rename strategy diff --git a/core/src/main/java/ch/cyberduck/core/vault/registry/VaultRegistryCopyFeature.java b/core/src/main/java/ch/cyberduck/core/vault/registry/VaultRegistryCopyFeature.java index 34ef759df50..a5ad5622ff1 100644 --- a/core/src/main/java/ch/cyberduck/core/vault/registry/VaultRegistryCopyFeature.java +++ b/core/src/main/java/ch/cyberduck/core/vault/registry/VaultRegistryCopyFeature.java @@ -74,20 +74,20 @@ else if(registry.find(session, copy, false).equals(Vault.DISABLED)) { } @Override - public void preflight(final Path source, final Path copy) throws BackgroundException { + public void preflight(final Path source, final Path copy, final String filename) throws BackgroundException { try { if(registry.find(session, source, false).equals(Vault.DISABLED)) { - registry.find(session, copy, false).getFeature(session, Copy.class, proxy).withTarget(destination).preflight(source, copy); + registry.find(session, copy, false).getFeature(session, Copy.class, proxy).withTarget(destination).preflight(source, copy, filename); } else if(registry.find(session, copy, false).equals(Vault.DISABLED)) { - registry.find(session, source, false).getFeature(session, Copy.class, proxy).withTarget(destination).preflight(source, copy); + registry.find(session, source, false).getFeature(session, Copy.class, proxy).withTarget(destination).preflight(source, copy, filename); } else { - registry.find(session, copy, false).getFeature(session, Copy.class, proxy).withTarget(destination).preflight(source, copy); + registry.find(session, copy, false).getFeature(session, Copy.class, proxy).withTarget(destination).preflight(source, copy, filename); } } catch(VaultUnlockCancelException e) { - proxy.preflight(source, copy); + proxy.preflight(source, copy, filename); } } diff --git a/core/src/main/java/ch/cyberduck/core/vault/registry/VaultRegistryMoveFeature.java b/core/src/main/java/ch/cyberduck/core/vault/registry/VaultRegistryMoveFeature.java index 882aef42303..fe1c401c9c4 100644 --- a/core/src/main/java/ch/cyberduck/core/vault/registry/VaultRegistryMoveFeature.java +++ b/core/src/main/java/ch/cyberduck/core/vault/registry/VaultRegistryMoveFeature.java @@ -85,17 +85,17 @@ public EnumSet features(final Path source, final Path target) { } @Override - public void preflight(final Path source, final Path target) throws BackgroundException { + public void preflight(final Path source, final Path directory, final String filename) throws BackgroundException { try { - if(registry.find(session, source, false).equals(registry.find(session, target, false))) { - registry.find(session, source, false).getFeature(session, Move.class, proxy).preflight(source, target); + if(registry.find(session, source, false).equals(registry.find(session, directory, false))) { + registry.find(session, source, false).getFeature(session, Move.class, proxy).preflight(source, directory, filename); } else { - session.getFeature(Copy.class).preflight(source, target); + session.getFeature(Copy.class).preflight(source, directory, filename); } } catch(VaultUnlockCancelException e) { - proxy.preflight(source, target); + proxy.preflight(source, directory, filename); } } diff --git a/core/src/test/java/ch/cyberduck/core/NullMoveFeature.java b/core/src/test/java/ch/cyberduck/core/NullMoveFeature.java index 68ec9281408..c8b33b553cc 100644 --- a/core/src/test/java/ch/cyberduck/core/NullMoveFeature.java +++ b/core/src/test/java/ch/cyberduck/core/NullMoveFeature.java @@ -21,7 +21,7 @@ public class NullMoveFeature extends DisabledMoveFeature { @Override - public void preflight(final Path source, final Path target) throws BackgroundException { + public void preflight(final Path source, final Path directory, final String filename) throws BackgroundException { // } } 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..ea6ee6da716 100755 --- a/core/src/test/java/ch/cyberduck/core/transfer/UploadTransferTest.java +++ b/core/src/test/java/ch/cyberduck/core/transfer/UploadTransferTest.java @@ -378,7 +378,7 @@ public Path move(final Path file, final Path renamed, final TransferStatus statu } @Override - public void preflight(final Path source, final Path target) throws BackgroundException { + public void preflight(final Path source, final Path directory, final String filename) throws BackgroundException { // } diff --git a/cryptomator/src/main/java/ch/cyberduck/core/cryptomator/features/CryptoCopyFeature.java b/cryptomator/src/main/java/ch/cyberduck/core/cryptomator/features/CryptoCopyFeature.java index 5cbb40a94e9..5bd56e77e15 100644 --- a/cryptomator/src/main/java/ch/cyberduck/core/cryptomator/features/CryptoCopyFeature.java +++ b/cryptomator/src/main/java/ch/cyberduck/core/cryptomator/features/CryptoCopyFeature.java @@ -90,12 +90,12 @@ public EnumSet features(final Path source, final Path target) { } @Override - public void preflight(final Path source, final Path copy) throws BackgroundException { + public void preflight(final Path source, final Path copy, final String filename) throws BackgroundException { if(vault.contains(source) && vault.contains(copy)) { - proxy.withTarget(target).preflight(source, copy); + proxy.withTarget(target).preflight(source, copy, filename); } else { - new DefaultCopyFeature(session).withTarget(target).preflight(source, copy); + new DefaultCopyFeature(session).withTarget(target).preflight(source, copy, filename); } } diff --git a/cryptomator/src/main/java/ch/cyberduck/core/cryptomator/features/CryptoMoveV6Feature.java b/cryptomator/src/main/java/ch/cyberduck/core/cryptomator/features/CryptoMoveV6Feature.java index 20612ca011b..8aa5597b748 100644 --- a/cryptomator/src/main/java/ch/cyberduck/core/cryptomator/features/CryptoMoveV6Feature.java +++ b/cryptomator/src/main/java/ch/cyberduck/core/cryptomator/features/CryptoMoveV6Feature.java @@ -63,11 +63,11 @@ public EnumSet features(final Path source, final Path target) { } @Override - public void preflight(final Path source, final Path target) throws BackgroundException { - if(!vault.getFilenameProvider().isValid(target.getName())) { - throw new InvalidFilenameException(MessageFormat.format(LocaleFactory.localizedString("Cannot create {0}", "Error"), target.getName())); + public void preflight(final Path source, final Path directory, final String filename) throws BackgroundException { + if(!vault.getFilenameProvider().isValid(filename)) { + throw new InvalidFilenameException(MessageFormat.format(LocaleFactory.localizedString("Cannot create {0}", "Error"), filename)); } - proxy.preflight(source, target); + proxy.preflight(source, directory, filename); } @Override diff --git a/cryptomator/src/main/java/ch/cyberduck/core/cryptomator/features/CryptoMoveV7Feature.java b/cryptomator/src/main/java/ch/cyberduck/core/cryptomator/features/CryptoMoveV7Feature.java index 433e6b9c152..ecf01c7acd6 100644 --- a/cryptomator/src/main/java/ch/cyberduck/core/cryptomator/features/CryptoMoveV7Feature.java +++ b/cryptomator/src/main/java/ch/cyberduck/core/cryptomator/features/CryptoMoveV7Feature.java @@ -69,11 +69,11 @@ public EnumSet features(final Path source, final Path target) { } @Override - public void preflight(final Path source, final Path target) throws BackgroundException { - if(!vault.getFilenameProvider().isValid(target.getName())) { - throw new InvalidFilenameException(MessageFormat.format(LocaleFactory.localizedString("Cannot create {0}", "Error"), target.getName())); + public void preflight(final Path source, final Path directory, final String filename) throws BackgroundException { + if(!vault.getFilenameProvider().isValid(filename)) { + throw new InvalidFilenameException(MessageFormat.format(LocaleFactory.localizedString("Cannot create {0}", "Error"), filename)); } - proxy.preflight(source, target); + proxy.preflight(source, directory, filename); } @Override diff --git a/ctera/src/main/java/ch/cyberduck/core/ctera/CteraCopyFeature.java b/ctera/src/main/java/ch/cyberduck/core/ctera/CteraCopyFeature.java index 98f23c2fb1f..ae8921ce287 100644 --- a/ctera/src/main/java/ch/cyberduck/core/ctera/CteraCopyFeature.java +++ b/ctera/src/main/java/ch/cyberduck/core/ctera/CteraCopyFeature.java @@ -36,12 +36,12 @@ public CteraCopyFeature(final CteraSession session) { } @Override - public void preflight(final Path source, final Path target) throws BackgroundException { + public void preflight(final Path source, final Path directory, final String filename) throws BackgroundException { // defaults to Acl.EMPTY (disabling role checking) if target does not exist - assumeRole(target, WRITEPERMISSION); + assumeRole(directory, WRITEPERMISSION); // no createfilespermission required for now if(source.isDirectory()) { - assumeRole(target.getParent(), target.getName(), CREATEDIRECTORIESPERMISSION); + assumeRole(directory.getParent(), directory.getName(), CREATEDIRECTORIESPERMISSION); } } } diff --git a/ctera/src/main/java/ch/cyberduck/core/ctera/CteraMoveFeature.java b/ctera/src/main/java/ch/cyberduck/core/ctera/CteraMoveFeature.java index ec1d3b6cffb..0470a53348a 100644 --- a/ctera/src/main/java/ch/cyberduck/core/ctera/CteraMoveFeature.java +++ b/ctera/src/main/java/ch/cyberduck/core/ctera/CteraMoveFeature.java @@ -40,16 +40,16 @@ public CteraMoveFeature(final CteraSession session, final CteraAttributesFinderF } @Override - public void preflight(final Path source, final Path target) throws BackgroundException { - if(!CteraTouchFeature.validate(target.getName())) { + public void preflight(final Path source, final Path directory, final String filename) throws BackgroundException { + if(!CteraTouchFeature.validate(filename)) { throw new InvalidFilenameException(MessageFormat.format(LocaleFactory.localizedString("Cannot rename {0}", "Error"), source.getName())).withFile(source); } assumeRole(source, DELETEPERMISSION); // defaults to Acl.EMPTY (disabling role checking) if target does not exist - assumeRole(target, WRITEPERMISSION); + assumeRole(directory, WRITEPERMISSION); // no createfilespermission required for now if(source.isDirectory()) { - assumeRole(target.getParent(), target.getName(), CREATEDIRECTORIESPERMISSION); + assumeRole(directory, filename, CREATEDIRECTORIESPERMISSION); } } } diff --git a/ctera/src/test/java/ch/cyberduck/core/ctera/CteraCopyFeatureTest.java b/ctera/src/test/java/ch/cyberduck/core/ctera/CteraCopyFeatureTest.java index 4be96d6d2eb..4c77b09e515 100644 --- a/ctera/src/test/java/ch/cyberduck/core/ctera/CteraCopyFeatureTest.java +++ b/ctera/src/test/java/ch/cyberduck/core/ctera/CteraCopyFeatureTest.java @@ -44,7 +44,7 @@ public void testPreflightDirectoryMissingCustomProps() throws Exception { source.setAttributes(source.attributes().withAcl(Acl.EMPTY)); final Path target = new Path(new DefaultHomeFinderService(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)); target.getParent().setAttributes(target.getParent().attributes().withAcl(Acl.EMPTY)); - new CteraCopyFeature(session).preflight(source, target); + new CteraCopyFeature(session).preflight(source, target.getParent(), target.getName()); } @Test @@ -53,7 +53,7 @@ public void testPreflightFileMissingCustomProps() throws Exception { source.setAttributes(source.attributes().withAcl(Acl.EMPTY)); final Path target = new Path(new DefaultHomeFinderService(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)); target.getParent().setAttributes(target.getParent().attributes().withAcl(Acl.EMPTY)); - new CteraCopyFeature(session).preflight(source, target); + new CteraCopyFeature(session).preflight(source, target.getParent(), target.getName()); } @Test @@ -63,7 +63,7 @@ public void testPreflightDirectoryAccessDeniedTargetNoCreatedirectoriesPermissio final Path target = new Path(new DefaultHomeFinderService(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)); // target's parent without createdirectories permission target.getParent().setAttributes(target.getParent().attributes().withAcl(new Acl(new Acl.CanonicalUser()))); - final AccessDeniedException accessDeniedException = assertThrows(AccessDeniedException.class, () -> new CteraCopyFeature(session).preflight(source, target)); + final AccessDeniedException accessDeniedException = assertThrows(AccessDeniedException.class, () -> new CteraCopyFeature(session).preflight(source, target.getParent(), target.getName())); assertTrue(accessDeniedException.getDetail().contains(MessageFormat.format(LocaleFactory.localizedString("Cannot create folder {0}", "Error"), target.getName()))); } @@ -77,7 +77,7 @@ public void testPreflightDirectoryAccessDeniedTargetExistsNotWritablePermissionC final CteraAttributesFinderFeature mock = mock(CteraAttributesFinderFeature.class); // target exists and not writable when(mock.find(eq(target))).thenReturn(new PathAttributes().withAcl(new Acl(new Acl.CanonicalUser()))); - final AccessDeniedException accessDeniedException = assertThrows(AccessDeniedException.class, () -> new CteraCopyFeature(session, mock).preflight(source, target)); + final AccessDeniedException accessDeniedException = assertThrows(AccessDeniedException.class, () -> new CteraCopyFeature(session, mock).preflight(source, target.getParent(), target.getName())); assertTrue(accessDeniedException.getDetail().contains(MessageFormat.format(LocaleFactory.localizedString("Upload {0} failed", "Error"), target.getName()))); } @@ -92,7 +92,7 @@ public void testPreflightFileAccessDeniedTargetExistsNotWritableCustomProps() th final CteraAttributesFinderFeature mock = mock(CteraAttributesFinderFeature.class); // target exists and not writable when(mock.find(eq(target))).thenReturn(new PathAttributes().withAcl(new Acl(new Acl.CanonicalUser()))); - final AccessDeniedException accessDeniedException = assertThrows(AccessDeniedException.class, () -> new CteraCopyFeature(session, mock).preflight(source, target)); + final AccessDeniedException accessDeniedException = assertThrows(AccessDeniedException.class, () -> new CteraCopyFeature(session, mock).preflight(source, target.getParent(), target.getName())); assertTrue(accessDeniedException.getDetail().contains(MessageFormat.format(LocaleFactory.localizedString("Upload {0} failed", "Error"), target.getName()))); } @@ -102,7 +102,7 @@ public void testPreflightDirectoryAccessGrantedCustomProps() throws Exception { source.setAttributes(source.attributes().withAcl(new Acl(new Acl.CanonicalUser(), CteraAttributesFinderFeature.DELETEPERMISSION))); final Path target = new Path(new DefaultHomeFinderService(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)); target.getParent().setAttributes(target.getParent().attributes().withAcl(new Acl(new Acl.CanonicalUser(), CteraAttributesFinderFeature.CREATEDIRECTORIESPERMISSION))); - new CteraCopyFeature(session).preflight(source, target); + new CteraCopyFeature(session).preflight(source, target.getParent(), target.getName()); // assert no fail } @@ -113,7 +113,7 @@ public void testPreflightFileAccessGrantedCustomProps() throws Exception { final Path target = new Path(new DefaultHomeFinderService(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)); // no createfilespermission required for now target.getParent().setAttributes(target.getParent().attributes().withAcl(new Acl(new Acl.CanonicalUser()))); - new CteraCopyFeature(session).preflight(source, target); + new CteraCopyFeature(session).preflight(source, target.getParent(), target.getName()); // assert no fail } } \ No newline at end of file diff --git a/ctera/src/test/java/ch/cyberduck/core/ctera/CteraMoveFeatureTest.java b/ctera/src/test/java/ch/cyberduck/core/ctera/CteraMoveFeatureTest.java index 1b20f9905a4..2cb736a9e1a 100644 --- a/ctera/src/test/java/ch/cyberduck/core/ctera/CteraMoveFeatureTest.java +++ b/ctera/src/test/java/ch/cyberduck/core/ctera/CteraMoveFeatureTest.java @@ -123,7 +123,7 @@ public void testPreflightDirectoryMissingCustomProps() throws Exception { source.setAttributes(source.attributes().withAcl(Acl.EMPTY)); final Path target = new Path(new DefaultHomeFinderService(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)); target.setAttributes(target.attributes().withAcl(Acl.EMPTY)); - new CteraMoveFeature(session).preflight(source, target); + new CteraMoveFeature(session).preflight(source, target.getParent(), target.getName()); } @Test @@ -132,7 +132,7 @@ public void testPreflightFileMissingCustomProps() throws Exception { source.setAttributes(source.attributes().withAcl(Acl.EMPTY)); final Path target = new Path(new DefaultHomeFinderService(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)); target.setAttributes(target.attributes().withAcl(Acl.EMPTY)); - new CteraMoveFeature(session).preflight(source, target); + new CteraMoveFeature(session).preflight(source, target.getParent(), target.getName()); } @Test @@ -142,7 +142,7 @@ public void testPreflightDirectoryAccessDeniedSourceNoDeletePermissionCustomProp source.setAttributes(source.attributes().withAcl(new Acl(new Acl.CanonicalUser()))); final Path target = new Path(new DefaultHomeFinderService(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)); target.getParent().setAttributes(target.getParent().attributes().withAcl(new Acl(new Acl.CanonicalUser()))); - final AccessDeniedException accessDeniedException = assertThrows(AccessDeniedException.class, () -> new CteraMoveFeature(session).preflight(source, target)); + final AccessDeniedException accessDeniedException = assertThrows(AccessDeniedException.class, () -> new CteraMoveFeature(session).preflight(source, target.getParent(), target.getName())); assertTrue(accessDeniedException.getDetail().contains(MessageFormat.format(LocaleFactory.localizedString("Cannot delete {0}", "Error"), source.getName()))); } @@ -153,7 +153,7 @@ public void testPreflightDirectoryAccessDeniedTargetNoCreatedirectoriesPermissio final Path target = new Path(new DefaultHomeFinderService(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)); // target's parent without createdirectories permission target.getParent().setAttributes(target.getParent().attributes().withAcl(new Acl(new Acl.CanonicalUser()))); - final AccessDeniedException accessDeniedException = assertThrows(AccessDeniedException.class, () -> new CteraMoveFeature(session).preflight(source, target)); + final AccessDeniedException accessDeniedException = assertThrows(AccessDeniedException.class, () -> new CteraMoveFeature(session).preflight(source, target.getParent(), target.getName())); assertTrue(accessDeniedException.getDetail().contains(MessageFormat.format(LocaleFactory.localizedString("Cannot create folder {0}", "Error"), target.getName()))); } @@ -167,7 +167,7 @@ public void testPreflightDirectoryAccessDeniedTargetExistsNotWritablePermissionC final CteraAttributesFinderFeature mock = mock(CteraAttributesFinderFeature.class); // target exists and not writable when(mock.find(eq(target))).thenReturn(new PathAttributes().withAcl(new Acl(new Acl.CanonicalUser()))); - final AccessDeniedException accessDeniedException = assertThrows(AccessDeniedException.class, () -> new CteraMoveFeature(session, mock).preflight(source, target)); + final AccessDeniedException accessDeniedException = assertThrows(AccessDeniedException.class, () -> new CteraMoveFeature(session, mock).preflight(source, target.getParent(), target.getName())); assertTrue(accessDeniedException.getDetail().contains(MessageFormat.format(LocaleFactory.localizedString("Upload {0} failed", "Error"), target.getName()))); } @@ -178,7 +178,7 @@ public void testPreflightFileAccessDeniedSourceNoDeletePermissionCustomProps() t source.setAttributes(source.attributes().withAcl(new Acl(new Acl.CanonicalUser()))); final Path target = new Path(new DefaultHomeFinderService(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)); target.getParent().setAttributes(target.getParent().attributes().withAcl(new Acl(new Acl.CanonicalUser()))); - final AccessDeniedException accessDeniedException = assertThrows(AccessDeniedException.class, () -> new CteraMoveFeature(session).preflight(source, target)); + final AccessDeniedException accessDeniedException = assertThrows(AccessDeniedException.class, () -> new CteraMoveFeature(session).preflight(source, target.getParent(), target.getName())); assertTrue(accessDeniedException.getDetail().contains(MessageFormat.format(LocaleFactory.localizedString("Cannot delete {0}", "Error"), source.getName()))); } @@ -193,7 +193,7 @@ public void testPreflightFileAccessDeniedTargetExistsNotWritableCustomProps() th final CteraAttributesFinderFeature mock = mock(CteraAttributesFinderFeature.class); // target exists and not writable when(mock.find(eq(target))).thenReturn(new PathAttributes().withAcl(new Acl(new Acl.CanonicalUser()))); - final AccessDeniedException accessDeniedException = assertThrows(AccessDeniedException.class, () -> new CteraMoveFeature(session, mock).preflight(source, target)); + final AccessDeniedException accessDeniedException = assertThrows(AccessDeniedException.class, () -> new CteraMoveFeature(session, mock).preflight(source, target.getParent(), target.getName())); assertTrue(accessDeniedException.getDetail().contains(MessageFormat.format(LocaleFactory.localizedString("Upload {0} failed", "Error"), target.getName()))); } @@ -204,7 +204,7 @@ public void testPreflightDirectoryAccessGrantedCustomProps() throws Exception { final Path target = new Path(new DefaultHomeFinderService(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)); target.setAttributes(target.attributes().withAcl(new Acl(new Acl.CanonicalUser(), CteraAttributesFinderFeature.WRITEPERMISSION))); source.getParent().setAttributes(source.getParent().attributes().withAcl(new Acl(new Acl.CanonicalUser(), CteraAttributesFinderFeature.CREATEDIRECTORIESPERMISSION))); - new CteraMoveFeature(session).preflight(source, target); + new CteraMoveFeature(session).preflight(source, target.getParent(), target.getName()); // assert no fail } @@ -214,7 +214,7 @@ public void testPreflightFileAccessGrantedCustomProps() throws Exception { source.setAttributes(source.attributes().withAcl(new Acl(new Acl.CanonicalUser(), CteraAttributesFinderFeature.DELETEPERMISSION))); final Path target = new Path(new DefaultHomeFinderService(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)); target.setAttributes(target.attributes().withAcl(new Acl(new Acl.CanonicalUser(), CteraAttributesFinderFeature.WRITEPERMISSION))); - new CteraMoveFeature(session).preflight(source, target); + new CteraMoveFeature(session).preflight(source, target.getParent(), target.getName()); // assert no fail } } diff --git a/dracoon/src/main/java/ch/cyberduck/core/sds/SDSCopyFeature.java b/dracoon/src/main/java/ch/cyberduck/core/sds/SDSCopyFeature.java index 881c69fd105..115e4d62d3d 100644 --- a/dracoon/src/main/java/ch/cyberduck/core/sds/SDSCopyFeature.java +++ b/dracoon/src/main/java/ch/cyberduck/core/sds/SDSCopyFeature.java @@ -81,25 +81,25 @@ public EnumSet features(final Path source, final Path target) { } @Override - public void preflight(final Path source, final Path target) throws BackgroundException { + public void preflight(final Path source, final Path directory, final String filename) throws BackgroundException { if(containerService.isContainer(source)) { // Rooms cannot be copied throw new UnsupportedException(MessageFormat.format(LocaleFactory.localizedString("Cannot copy {0}", "Error"), source.getName())).withFile(source); } - if(SDSAttributesAdapter.isEncrypted(source.attributes()) ^ SDSAttributesAdapter.isEncrypted(containerService.getContainer(target).attributes())) { + if(SDSAttributesAdapter.isEncrypted(source.attributes()) ^ SDSAttributesAdapter.isEncrypted(containerService.getContainer(directory).attributes())) { // If source xor target is encrypted data room we cannot use server side copy log.warn(String.format("Cannot use server side copy with source container %s and target container %s", - containerService.getContainer(source), containerService.getContainer(target))); + containerService.getContainer(source), containerService.getContainer(directory))); throw new UnsupportedException(MessageFormat.format(LocaleFactory.localizedString("Cannot copy {0}", "Error"), source.getName())).withFile(source); } - if(!StringUtils.equals(source.getName(), target.getName())) { + if(!StringUtils.equals(source.getName(), filename)) { // Cannot rename node to be copied at the same time - log.warn(String.format("Deny copy of %s for changed name %s", source, target.getName())); + log.warn(String.format("Deny copy of %s for changed name %s", source, filename)); throw new UnsupportedException(MessageFormat.format(LocaleFactory.localizedString("Cannot copy {0}", "Error"), source.getName())).withFile(source); } - if(Objects.equals(source.getParent(), target.getParent())) { + if(Objects.equals(source.getParent(), directory)) { // Nodes must not have the same parent - log.warn(String.format("Deny copy of %s to %s", source, target)); + log.warn(String.format("Deny copy of %s to %s", source, directory)); throw new UnsupportedException(MessageFormat.format(LocaleFactory.localizedString("Cannot copy {0}", "Error"), source.getName())).withFile(source); } } diff --git a/dracoon/src/main/java/ch/cyberduck/core/sds/SDSDelegatingCopyFeature.java b/dracoon/src/main/java/ch/cyberduck/core/sds/SDSDelegatingCopyFeature.java index b3f7b7732f1..80381753251 100644 --- a/dracoon/src/main/java/ch/cyberduck/core/sds/SDSDelegatingCopyFeature.java +++ b/dracoon/src/main/java/ch/cyberduck/core/sds/SDSDelegatingCopyFeature.java @@ -43,7 +43,7 @@ public SDSDelegatingCopyFeature(final SDSSession session, final SDSNodeIdProvide @Override public Path copy(final Path source, final Path target, final TransferStatus status, final ConnectionCallback callback, final StreamListener listener) throws BackgroundException { - if(proxy.isSupported(source, target)) { + if(proxy.isSupported(source, target.getParent(), target.getName())) { return proxy.copy(source, target, status, callback, listener); } // Copy between encrypted and unencrypted data room @@ -57,10 +57,10 @@ public Path copy(final Path source, final Path target, final TransferStatus stat } @Override - public void preflight(final Path source, final Path target) throws BackgroundException { - if(proxy.isSupported(source, target)) { - proxy.preflight(source, target); + public void preflight(final Path source, final Path directory, final String filename) throws BackgroundException { + if(proxy.isSupported(source, directory, filename)) { + proxy.preflight(source, directory, filename); } - copy.preflight(source, target); + copy.preflight(source, directory, filename); } } diff --git a/dracoon/src/main/java/ch/cyberduck/core/sds/SDSDelegatingMoveFeature.java b/dracoon/src/main/java/ch/cyberduck/core/sds/SDSDelegatingMoveFeature.java index f89d4922257..5d519253cf3 100644 --- a/dracoon/src/main/java/ch/cyberduck/core/sds/SDSDelegatingMoveFeature.java +++ b/dracoon/src/main/java/ch/cyberduck/core/sds/SDSDelegatingMoveFeature.java @@ -88,12 +88,12 @@ public EnumSet features(final Path source, final Path target) { } @Override - public void preflight(final Path source, final Path target) throws BackgroundException { - if(SDSAttributesAdapter.isEncrypted(source.attributes()) ^ SDSAttributesAdapter.isEncrypted(containerService.getContainer(target).attributes())) { - session.getFeature(Copy.class).preflight(source, target); + public void preflight(final Path source, final Path directory, final String filename) throws BackgroundException { + if(SDSAttributesAdapter.isEncrypted(source.attributes()) ^ SDSAttributesAdapter.isEncrypted(containerService.getContainer(directory).attributes())) { + session.getFeature(Copy.class).preflight(source, directory, filename); } else { - proxy.preflight(source, target); + proxy.preflight(source, directory, filename); } } diff --git a/dracoon/src/main/java/ch/cyberduck/core/sds/SDSMoveFeature.java b/dracoon/src/main/java/ch/cyberduck/core/sds/SDSMoveFeature.java index 2cd09a50915..5dee752a3b6 100644 --- a/dracoon/src/main/java/ch/cyberduck/core/sds/SDSMoveFeature.java +++ b/dracoon/src/main/java/ch/cyberduck/core/sds/SDSMoveFeature.java @@ -116,45 +116,45 @@ public EnumSet features(final Path source, final Path target) { } @Override - public void preflight(final Path source, final Path target) throws BackgroundException { + public void preflight(final Path source, final Path directory, final String filename) throws BackgroundException { if(containerService.isContainer(source)) { - if(!new SimplePathPredicate(source.getParent()).test(target.getParent())) { + if(!new SimplePathPredicate(source.getParent()).test(directory)) { // Cannot move data room but only rename log.warn(String.format("Deny moving data room %s", source)); throw new UnsupportedException(MessageFormat.format(LocaleFactory.localizedString("Cannot rename {0}", "Error"), source.getName())).withFile(source); } } - if(target.getParent().isRoot() && !source.getParent().isRoot()) { + if(directory.isRoot() && !source.getParent().isRoot()) { // Cannot move file or directory to root but only rename data rooms log.warn(String.format("Deny moving file %s to root", source)); throw new UnsupportedException(MessageFormat.format(LocaleFactory.localizedString("Cannot rename {0}", "Error"), source.getName())).withFile(source); } - if(!SDSTouchFeature.validate(target.getName())) { - log.warn(String.format("Validation failed for target name %s", target)); - throw new InvalidFilenameException(MessageFormat.format(LocaleFactory.localizedString("Cannot rename {0}", "Error"), source.getName())).withFile(target); + if(!SDSTouchFeature.validate(filename)) { + log.warn(String.format("Validation failed for target name %s", filename)); + throw new InvalidFilenameException(MessageFormat.format(LocaleFactory.localizedString("Cannot rename {0}", "Error"), source.getName())).withFile(directory); } final SDSPermissionsFeature acl = new SDSPermissionsFeature(session, nodeid); - if(!new SimplePathPredicate(source.getParent()).test(target.getParent())) { + if(!new SimplePathPredicate(source.getParent()).test(directory)) { // Change parent node if(!acl.containsRole(containerService.getContainer(source), SDSPermissionsFeature.CHANGE_ROLE)) { log.warn(String.format("Deny move of %s to %s changing parent node with missing role %s on data room %s", - source, target, SDSPermissionsFeature.CHANGE_ROLE, containerService.getContainer(source))); + source, directory, SDSPermissionsFeature.CHANGE_ROLE, containerService.getContainer(source))); throw new AccessDeniedException(MessageFormat.format(LocaleFactory.localizedString("Cannot rename {0}", "Error"), source.getName())).withFile(source); } if(!acl.containsRole(containerService.getContainer(source), SDSPermissionsFeature.DELETE_ROLE)) { log.warn(String.format("Deny move of %s to %s changing parent node with missing role %s on data room %s", - source, target, SDSPermissionsFeature.DELETE_ROLE, containerService.getContainer(source))); + source, directory, SDSPermissionsFeature.DELETE_ROLE, containerService.getContainer(source))); throw new AccessDeniedException(MessageFormat.format(LocaleFactory.localizedString("Cannot rename {0}", "Error"), source.getName())).withFile(source); } - if(!acl.containsRole(containerService.getContainer(target), SDSPermissionsFeature.CREATE_ROLE)) { + if(!acl.containsRole(containerService.getContainer(directory), SDSPermissionsFeature.CREATE_ROLE)) { log.warn(String.format("Deny move of %s to %s changing parent node with missing role %s on data room %s", - source, target, SDSPermissionsFeature.CREATE_ROLE, containerService.getContainer(target))); + source, directory, SDSPermissionsFeature.CREATE_ROLE, containerService.getContainer(directory))); throw new AccessDeniedException(MessageFormat.format(LocaleFactory.localizedString("Cannot rename {0}", "Error"), source.getName())).withFile(source); } } if(!acl.containsRole(containerService.getContainer(source), SDSPermissionsFeature.CHANGE_ROLE)) { log.warn(String.format("Deny move of %s to %s with missing permissions for user with missing role %s on data room %s", - source, target, SDSPermissionsFeature.CHANGE_ROLE, containerService.getContainer(source))); + source, directory, SDSPermissionsFeature.CHANGE_ROLE, containerService.getContainer(source))); throw new AccessDeniedException(MessageFormat.format(LocaleFactory.localizedString("Cannot rename {0}", "Error"), source.getName())).withFile(source); } } diff --git a/dracoon/src/test/java/ch/cyberduck/core/sds/SDSDelegatingCopyFeatureTest.java b/dracoon/src/test/java/ch/cyberduck/core/sds/SDSDelegatingCopyFeatureTest.java index 6ee5a9a7365..60ec63f0912 100644 --- a/dracoon/src/test/java/ch/cyberduck/core/sds/SDSDelegatingCopyFeatureTest.java +++ b/dracoon/src/test/java/ch/cyberduck/core/sds/SDSDelegatingCopyFeatureTest.java @@ -70,16 +70,16 @@ public void testCopyFileServerSide() throws Exception { final Path copy = new Path(new SDSDirectoryFeature(session, nodeid).mkdir(new Path(room, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)), new TransferStatus()), test.getName(), EnumSet.of(Path.Type.file)); new SDSTouchFeature(session, nodeid).touch(copy, new TransferStatus()); final SDSCopyFeature proxy = new SDSCopyFeature(session, nodeid); - assertThrows(UnsupportedException.class, () -> proxy.preflight(room, test)); + assertThrows(UnsupportedException.class, () -> proxy.preflight(room, test.getParent(), test.getName())); try { - proxy.preflight(room, test); + proxy.preflight(room, test.getParent(), test.getName()); } catch(UnsupportedException e) { assertEquals("Unsupported", e.getMessage()); assertEquals(String.format("Cannot copy %s.", room.getName()), e.getDetail(false)); } final SDSDelegatingCopyFeature feature = new SDSDelegatingCopyFeature(session, nodeid, proxy); - assertTrue(feature.isSupported(test, copy)); + assertTrue(feature.isSupported(test, copy.getParent(), copy.getName())); final Path target = feature.copy(test, copy, new TransferStatus(), new DisabledConnectionCallback(), new DisabledStreamListener()); assertNotEquals(test.attributes().getVersionId(), target.attributes().getVersionId()); assertEquals(target.attributes().getVersionId(), new SDSAttributesFinderFeature(session, nodeid).find(target).getVersionId()); @@ -97,8 +97,8 @@ public void testCopyFileWithRename() throws Exception { final Path copy = new Path(new SDSDirectoryFeature(session, nodeid).mkdir(new Path(room, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)), new TransferStatus()), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)); final SDSCopyFeature proxy = new SDSCopyFeature(session, nodeid); final SDSDelegatingCopyFeature feature = new SDSDelegatingCopyFeature(session, nodeid, proxy); - assertFalse(proxy.isSupported(test, copy)); - assertTrue(feature.isSupported(test, copy)); + assertFalse(proxy.isSupported(test, copy.getParent(), copy.getName())); + assertTrue(feature.isSupported(test, copy.getParent(), copy.getName())); final Path target = feature.copy(test, copy, new TransferStatus(), new DisabledConnectionCallback(), new DisabledStreamListener()); assertNotEquals(test.attributes().getVersionId(), target.attributes().getVersionId()); assertEquals(target.attributes().getVersionId(), new SDSAttributesFinderFeature(session, nodeid).find(target).getVersionId()); @@ -121,7 +121,7 @@ public void testCopyServerSideToExistingFile() throws Exception { final Path copy = new Path(targetFolder, test.getName(), EnumSet.of(Path.Type.file)); new SDSTouchFeature(session, nodeid).touch(copy, new TransferStatus()); final SDSDelegatingCopyFeature feature = new SDSDelegatingCopyFeature(session, nodeid, new SDSCopyFeature(session, nodeid)); - assertTrue(feature.isSupported(test, copy)); + assertTrue(feature.isSupported(test, copy.getParent(), copy.getName())); final Path target = feature.copy(test, copy, new TransferStatus().exists(true), new DisabledConnectionCallback(), new DisabledStreamListener()); assertNotEquals(test.attributes().getVersionId(), target.attributes().getVersionId()); assertEquals(target.attributes().getVersionId(), new SDSAttributesFinderFeature(session, nodeid).find(target).getVersionId()); @@ -143,8 +143,8 @@ public void testCopyWithRenameToExistingFile() throws Exception { final Path copy = new Path(folder, test.getName(), EnumSet.of(Path.Type.file)); final SDSCopyFeature proxy = new SDSCopyFeature(session, nodeid); final SDSDelegatingCopyFeature feature = new SDSDelegatingCopyFeature(session, nodeid, proxy); - assertFalse(proxy.isSupported(test, copy)); - assertTrue(feature.isSupported(test, copy)); + assertFalse(proxy.isSupported(test, copy.getParent(), copy.getName())); + assertTrue(feature.isSupported(test, copy.getParent(), copy.getName())); assertNotNull(feature.copy(test, copy, new TransferStatus().exists(true), new DisabledConnectionCallback(), new DisabledStreamListener()).attributes().getVersionId()); final Find find = new DefaultFindFeature(session); final AttributedList files = new SDSListService(session, nodeid).list(folder, new DisabledListProgressListener()); @@ -163,7 +163,7 @@ public void testCopyDirectoryServerSide() throws Exception { final Path target_parent = new SDSDirectoryFeature(session, nodeid).mkdir(new Path(room, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)), new TransferStatus()); final Path target = new Path(target_parent, directory.getName(), EnumSet.of(Path.Type.directory)); final SDSDelegatingCopyFeature feature = new SDSDelegatingCopyFeature(session, nodeid, new SDSCopyFeature(session, nodeid)); - assertTrue(feature.isSupported(directory, target)); + assertTrue(feature.isSupported(directory, target.getParent(), target.getName())); final Path copy = feature.copy(directory, target, new TransferStatus(), new DisabledConnectionCallback(), new DisabledStreamListener()); assertNotNull(copy.attributes().getVersionId()); assertTrue(new SDSFindFeature(session, nodeid).find(file)); @@ -182,7 +182,7 @@ public void testCopyFileToDifferentDataRoom() throws Exception { final Path source = new SDSTouchFeature(session, nodeid).touch(new Path(room1, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)), new TransferStatus()); final Path target = new SDSTouchFeature(session, nodeid).touch(new Path(room2, source.getName(), EnumSet.of(Path.Type.file)), new TransferStatus()); final SDSDelegatingCopyFeature feature = new SDSDelegatingCopyFeature(session, nodeid, new SDSCopyFeature(session, nodeid)); - assertTrue(feature.isSupported(source, target)); + assertTrue(feature.isSupported(source, target.getParent(), target.getName())); assertNotNull(feature.copy(source, target, new TransferStatus(), new DisabledConnectionCallback(), new DisabledStreamListener()).attributes().getVersionId()); assertTrue(new SDSFindFeature(session, nodeid).find(source)); assertTrue(new SDSFindFeature(session, nodeid).find(target)); @@ -222,8 +222,8 @@ public Credentials prompt(final Host bookmark, final String title, final String }, new DisabledStreamListener()); assertNotNull(copy.attributes().getVersionId()); assertEquals(copy.attributes().getVersionId(), new SDSAttributesFinderFeature(session, nodeid).find(copy).getVersionId()); - assertFalse(proxy.isSupported(test, target)); - assertTrue(feature.isSupported(test, target)); + assertFalse(proxy.isSupported(test, target.getParent(), target.getName())); + assertTrue(feature.isSupported(test, target.getParent(), target.getName())); assertTrue(new SDSFindFeature(session, nodeid).find(test)); assertTrue(new SDSFindFeature(session, nodeid).find(copy)); final byte[] compare = new byte[content.length]; @@ -263,8 +263,8 @@ public void testCopyToEncryptedDataRoom() throws Exception { final SDSCopyFeature proxy = new SDSCopyFeature(session, nodeid); final SDSDelegatingCopyFeature feature = new SDSDelegatingCopyFeature(session, nodeid, proxy); assertNotNull(feature.copy(test, target, new TransferStatus().withLength(content.length), new DisabledConnectionCallback(), new DisabledStreamListener()).attributes().getVersionId()); - assertFalse(proxy.isSupported(test, target)); - assertTrue(feature.isSupported(test, target)); + assertFalse(proxy.isSupported(test, target.getParent(), target.getName())); + assertTrue(feature.isSupported(test, target.getParent(), target.getName())); assertTrue(new SDSFindFeature(session, nodeid).find(test)); assertTrue(new SDSFindFeature(session, nodeid).find(target)); final byte[] compare = new byte[content.length]; @@ -320,8 +320,8 @@ public Credentials prompt(final Host bookmark, final String title, final String return new VaultCredentials("eth[oh8uv4Eesij"); } }, new DisabledStreamListener()).attributes().getVersionId()); - assertFalse(proxy.isSupported(test, target)); - assertTrue(feature.isSupported(test, target)); + assertFalse(proxy.isSupported(test, target.getParent(), target.getName())); + assertTrue(feature.isSupported(test, target.getParent(), target.getName())); assertTrue(new SDSFindFeature(session, nodeid).find(test)); assertTrue(new SDSFindFeature(session, nodeid).find(target)); final byte[] compare = new byte[content.length]; @@ -366,7 +366,7 @@ public void testCopyFileSameNameBetweenEncryptedDataRooms() throws Exception { test.withAttributes(status.getResponse()); final Path target = new Path(room2, test.getName(), EnumSet.of(Path.Type.file)); final SDSDelegatingCopyFeature feature = new SDSDelegatingCopyFeature(session, nodeid, new SDSCopyFeature(session, nodeid)); - assertTrue(feature.isSupported(test, target)); + assertTrue(feature.isSupported(test, target.getParent(), target.getName())); final Path copy = feature.copy(test, target, new TransferStatus().withLength(content.length), new DisabledConnectionCallback() { @Override public void warn(final Host bookmark, final String title, final String message, final String defaultButton, final String cancelButton, final String preference) { diff --git a/dracoon/src/test/java/ch/cyberduck/core/sds/SDSDelegatingMoveFeatureTest.java b/dracoon/src/test/java/ch/cyberduck/core/sds/SDSDelegatingMoveFeatureTest.java index 46ecf5fe0c2..96cbdc6584a 100644 --- a/dracoon/src/test/java/ch/cyberduck/core/sds/SDSDelegatingMoveFeatureTest.java +++ b/dracoon/src/test/java/ch/cyberduck/core/sds/SDSDelegatingMoveFeatureTest.java @@ -299,7 +299,7 @@ public void testMoveDirectoryToRoot() throws Exception { final Path test = new SDSDirectoryFeature(session, nodeid).mkdir(new Path(room, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)), new TransferStatus()); final Path target = new Path(new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)); final SDSMoveFeature move = new SDSMoveFeature(session, nodeid); - assertFalse(move.isSupported(test, target)); + assertFalse(move.isSupported(test, target.getParent(), target.getName())); move.move(test, target, new TransferStatus(), new Delete.DisabledCallback(), new DisabledConnectionCallback()); assertEquals(0, session.getMetrics().get(Copy.class)); assertFalse(new SDSFindFeature(session, nodeid).find(test)); @@ -316,7 +316,7 @@ public void testMoveRoomToDirectory() throws Exception { final Path test = new SDSDirectoryFeature(session, nodeid).mkdir(new Path( new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory, Path.Type.volume)), new TransferStatus()); final SDSMoveFeature move = new SDSMoveFeature(session, nodeid); - assertFalse(move.isSupported(test, target)); + assertFalse(move.isSupported(test, target.getParent(), target.getName())); } @Test @@ -328,7 +328,7 @@ public void testMoveSubroom() throws Exception { final Path subroom = new SDSDirectoryFeature(session, nodeid).mkdir(new Path(room, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory, Path.Type.volume)), new TransferStatus()); final SDSMoveFeature move = new SDSMoveFeature(session, nodeid); - assertTrue(move.isSupported(subroom, target)); + assertTrue(move.isSupported(subroom, target.getParent(), target.getName())); move.move(subroom, target, new TransferStatus(), new Delete.DisabledCallback(), new DisabledConnectionCallback()); assertEquals(0, session.getMetrics().get(Copy.class)); subroom.attributes().setVersionId(null); diff --git a/dracoon/src/test/java/ch/cyberduck/core/sds/SDSShareFeatureTest.java b/dracoon/src/test/java/ch/cyberduck/core/sds/SDSShareFeatureTest.java index 66bdffeec9e..723b035f9f8 100644 --- a/dracoon/src/test/java/ch/cyberduck/core/sds/SDSShareFeatureTest.java +++ b/dracoon/src/test/java/ch/cyberduck/core/sds/SDSShareFeatureTest.java @@ -21,12 +21,15 @@ import ch.cyberduck.core.DisabledLoginCallback; import ch.cyberduck.core.DisabledPasswordCallback; import ch.cyberduck.core.Host; +import ch.cyberduck.core.Local; import ch.cyberduck.core.LoginOptions; import ch.cyberduck.core.Path; import ch.cyberduck.core.exception.InteroperabilityException; import ch.cyberduck.core.exception.LoginCanceledException; import ch.cyberduck.core.features.Delete; import ch.cyberduck.core.features.Share; +import ch.cyberduck.core.io.BandwidthThrottle; +import ch.cyberduck.core.io.DisabledStreamListener; import ch.cyberduck.core.sds.io.swagger.client.model.CreateDownloadShareRequest; import ch.cyberduck.core.sds.io.swagger.client.model.CreateUploadShareRequest; import ch.cyberduck.core.sds.io.swagger.client.model.ObjectExpiration; @@ -34,12 +37,16 @@ import ch.cyberduck.core.vault.VaultCredentials; import ch.cyberduck.test.IntegrationTest; +import org.apache.commons.io.IOUtils; +import org.apache.commons.lang3.RandomUtils; import org.joda.time.DateTime; import org.junit.Test; import org.junit.experimental.categories.Category; +import java.io.OutputStream; import java.util.Collections; import java.util.EnumSet; +import java.util.UUID; import static org.junit.Assert.*; @@ -68,6 +75,39 @@ Share.Sharee.world, new CreateDownloadShareRequest() new SDSDeleteFeature(session, nodeid).delete(Collections.singletonList(room), new DisabledLoginCallback(), new Delete.DisabledCallback()); } + @Test + public void testverwriteKeepSharedLink() throws Exception { + final SDSNodeIdProvider nodeid = new SDSNodeIdProvider(session); + final Path room = new SDSDirectoryFeature(session, nodeid).mkdir(new Path(new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory, Path.Type.volume)), new TransferStatus()); + final Path test = new SDSTouchFeature(session, nodeid).touch(new Path(room, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)), new TransferStatus()); + final DescriptiveUrl url = new SDSShareFeature(session, nodeid).toDownloadUrl(test, + Share.Sharee.world, new CreateDownloadShareRequest() + .expiration(new ObjectExpiration().enableExpiration(false)) + .notifyCreator(false) + .sendMail(false) + .sendSms(false) + .password(null) + .mailRecipients(null) + .mailSubject(null) + .mailBody(null) + .maxDownloads(null), new DisabledPasswordCallback()); + assertNotEquals(DescriptiveUrl.EMPTY, url); + assertEquals(DescriptiveUrl.Type.signed, url.getType()); + assertTrue(url.getUrl().startsWith("https://duck.dracoon.com/public/download-shares/")); + final Local local = new Local(System.getProperty("java.io.tmpdir"), UUID.randomUUID().toString()); + final byte[] random = RandomUtils.nextBytes(7352); + final OutputStream out = local.getOutputStream(false); + IOUtils.write(random, out); + out.close(); + final TransferStatus status = new TransferStatus().exists(true).withLength(random.length); + final SDSDirectS3UploadFeature feature = new SDSDirectS3UploadFeature(session, nodeid, new SDSDelegatingWriteFeature(session, nodeid, new SDSDirectS3WriteFeature(session, nodeid))); + feature.upload(test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), + new DisabledStreamListener(), status, new DisabledLoginCallback()); + assertTrue(new SDSFindFeature(session, nodeid).find(test)); + new SDSDeleteFeature(session, nodeid).delete(Collections.singletonList(room), new DisabledLoginCallback(), new Delete.DisabledCallback()); + local.delete(); + } + @Test public void testShareTopLevelRoom() throws Exception { final SDSNodeIdProvider nodeid = new SDSNodeIdProvider(session); diff --git a/dracoon/src/test/java/ch/cyberduck/core/shared/DefaultCopyFeatureTest.java b/dracoon/src/test/java/ch/cyberduck/core/shared/DefaultCopyFeatureTest.java index 038261703e4..edc44472a3f 100644 --- a/dracoon/src/test/java/ch/cyberduck/core/shared/DefaultCopyFeatureTest.java +++ b/dracoon/src/test/java/ch/cyberduck/core/shared/DefaultCopyFeatureTest.java @@ -50,7 +50,7 @@ public class DefaultCopyFeatureTest extends AbstractSDSTest { public void testSupported() throws Exception { final Path source = new Path(new DefaultHomeFinderService(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)); final Path target = new Path(new DefaultHomeFinderService(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)); - assertTrue(new DefaultCopyFeature(session).isSupported(source, target)); + assertTrue(new DefaultCopyFeature(session).isSupported(source, target.getParent(), target.getName())); } @Test diff --git a/dropbox/src/main/java/ch/cyberduck/core/dropbox/DropboxCopyFeature.java b/dropbox/src/main/java/ch/cyberduck/core/dropbox/DropboxCopyFeature.java index 71081137dfa..e00f1973ee9 100644 --- a/dropbox/src/main/java/ch/cyberduck/core/dropbox/DropboxCopyFeature.java +++ b/dropbox/src/main/java/ch/cyberduck/core/dropbox/DropboxCopyFeature.java @@ -73,9 +73,9 @@ public EnumSet features(final Path source, final Path target) { } @Override - public void preflight(final Path source, final Path target) throws BackgroundException { - if(!DropboxTouchFeature.validate(target.getName())) { - throw new InvalidFilenameException(MessageFormat.format(LocaleFactory.localizedString("Cannot create {0}", "Error"), target.getName())); + public void preflight(final Path source, final Path directory, final String filename) throws BackgroundException { + if(!DropboxTouchFeature.validate(filename)) { + throw new InvalidFilenameException(MessageFormat.format(LocaleFactory.localizedString("Cannot create {0}", "Error"), filename)); } } } diff --git a/dropbox/src/main/java/ch/cyberduck/core/dropbox/DropboxMoveFeature.java b/dropbox/src/main/java/ch/cyberduck/core/dropbox/DropboxMoveFeature.java index 54dbb469c58..8492a849cc3 100644 --- a/dropbox/src/main/java/ch/cyberduck/core/dropbox/DropboxMoveFeature.java +++ b/dropbox/src/main/java/ch/cyberduck/core/dropbox/DropboxMoveFeature.java @@ -70,9 +70,9 @@ public EnumSet features(final Path source, final Path target) { } @Override - public void preflight(final Path source, final Path target) throws BackgroundException { - if(!DropboxTouchFeature.validate(target.getName())) { - throw new InvalidFilenameException(MessageFormat.format(LocaleFactory.localizedString("Cannot create {0}", "Error"), target.getName())); + public void preflight(final Path source, final Path directory, final String filename) throws BackgroundException { + if(!DropboxTouchFeature.validate(filename)) { + throw new InvalidFilenameException(MessageFormat.format(LocaleFactory.localizedString("Cannot create {0}", "Error"), filename)); } } } diff --git a/dropbox/src/test/java/ch/cyberduck/core/dropbox/DropboxCopyFeatureTest.java b/dropbox/src/test/java/ch/cyberduck/core/dropbox/DropboxCopyFeatureTest.java index 32bbc8fbdcb..4dead86d3d9 100644 --- a/dropbox/src/test/java/ch/cyberduck/core/dropbox/DropboxCopyFeatureTest.java +++ b/dropbox/src/test/java/ch/cyberduck/core/dropbox/DropboxCopyFeatureTest.java @@ -95,7 +95,7 @@ public void testMoveInvalidFilename() throws Exception { final Path home = new DefaultHomeFinderService(session).find(); final Path file = new DropboxTouchFeature(session).touch(new Path(home, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)), new TransferStatus()); final Path target = new Path(home, "~$f", EnumSet.of(Path.Type.file)); - assertThrows(InvalidFilenameException.class, () -> feature.preflight(file, target)); + assertThrows(InvalidFilenameException.class, () -> feature.preflight(file, target.getParent(), target.getName())); assertThrows(AccessDeniedException.class, () -> feature.copy(file, target, new TransferStatus(), new DisabledConnectionCallback(), new DisabledStreamListener())); new DropboxDeleteFeature(session).delete(Collections.singletonList(file), new DisabledLoginCallback(), new Delete.DisabledCallback()); } diff --git a/dropbox/src/test/java/ch/cyberduck/core/dropbox/DropboxMoveFeatureTest.java b/dropbox/src/test/java/ch/cyberduck/core/dropbox/DropboxMoveFeatureTest.java index 5bf3ac0d5bb..4ea71e8ae73 100644 --- a/dropbox/src/test/java/ch/cyberduck/core/dropbox/DropboxMoveFeatureTest.java +++ b/dropbox/src/test/java/ch/cyberduck/core/dropbox/DropboxMoveFeatureTest.java @@ -119,7 +119,7 @@ public void testMoveInvalidFilename() throws Exception { final Path home = new DefaultHomeFinderService(session).find(); final Path file = new DropboxTouchFeature(session).touch(new Path(home, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)), new TransferStatus()); final Path target = new Path(home, "~$f", EnumSet.of(Path.Type.file)); - assertThrows(InvalidFilenameException.class, () -> feature.preflight(file, target)); + assertThrows(InvalidFilenameException.class, () -> feature.preflight(file, target.getParent(), target.getName())); assertThrows(AccessDeniedException.class, () -> feature.move(file, target, new TransferStatus(), new Delete.DisabledCallback(), new DisabledConnectionCallback())); new DropboxDeleteFeature(session).delete(Collections.singletonList(file), new DisabledLoginCallback(), new Delete.DisabledCallback()); } diff --git a/eue/src/main/java/ch/cyberduck/core/eue/EueCopyFeature.java b/eue/src/main/java/ch/cyberduck/core/eue/EueCopyFeature.java index 1da5dc2a8bb..f194ae4e6ce 100644 --- a/eue/src/main/java/ch/cyberduck/core/eue/EueCopyFeature.java +++ b/eue/src/main/java/ch/cyberduck/core/eue/EueCopyFeature.java @@ -135,9 +135,9 @@ public Path copy(final Path file, final Path target, final TransferStatus status } @Override - public void preflight(final Path source, final Path target) throws BackgroundException { - if(!EueTouchFeature.validate(target.getName())) { - throw new InvalidFilenameException(MessageFormat.format(LocaleFactory.localizedString("Cannot create {0}", "Error"), target.getName())); + public void preflight(final Path source, final Path directory, final String filename) throws BackgroundException { + if(!EueTouchFeature.validate(filename)) { + throw new InvalidFilenameException(MessageFormat.format(LocaleFactory.localizedString("Cannot create {0}", "Error"), filename)); } } diff --git a/eue/src/main/java/ch/cyberduck/core/eue/EueMoveFeature.java b/eue/src/main/java/ch/cyberduck/core/eue/EueMoveFeature.java index 50e1c986050..3a0473acaa8 100644 --- a/eue/src/main/java/ch/cyberduck/core/eue/EueMoveFeature.java +++ b/eue/src/main/java/ch/cyberduck/core/eue/EueMoveFeature.java @@ -17,7 +17,6 @@ import ch.cyberduck.core.CaseInsensitivePathPredicate; import ch.cyberduck.core.ConnectionCallback; -import ch.cyberduck.core.DisabledListProgressListener; import ch.cyberduck.core.LocaleFactory; import ch.cyberduck.core.Path; import ch.cyberduck.core.SimplePathPredicate; @@ -144,15 +143,15 @@ public Path move(final Path file, final Path target, final TransferStatus status } @Override - public void preflight(final Path source, final Path target) throws BackgroundException { + public void preflight(final Path source, final Path directory, final String filename) throws BackgroundException { if(StringUtils.equals(EueResourceIdProvider.TRASH, source.attributes().getFileId())) { throw new InvalidFilenameException(MessageFormat.format(LocaleFactory.localizedString("Cannot rename {0}", "Error"), source.getName())).withFile(source); } if(StringUtils.equals(session.getHost().getProperty("cryptomator.vault.name.default"), source.getName())) { throw new InvalidFilenameException(MessageFormat.format(LocaleFactory.localizedString("Cannot rename {0}", "Error"), source.getName())).withFile(source); } - if(!EueTouchFeature.validate(target.getName())) { - throw new InvalidFilenameException(MessageFormat.format(LocaleFactory.localizedString("Cannot create {0}", "Error"), target.getName())); + if(!EueTouchFeature.validate(filename)) { + throw new InvalidFilenameException(MessageFormat.format(LocaleFactory.localizedString("Cannot create {0}", "Error"), filename)); } } diff --git a/ftp/src/main/java/ch/cyberduck/core/ftp/FTPMoveFeature.java b/ftp/src/main/java/ch/cyberduck/core/ftp/FTPMoveFeature.java index 0469aa34751..abc4018ce18 100644 --- a/ftp/src/main/java/ch/cyberduck/core/ftp/FTPMoveFeature.java +++ b/ftp/src/main/java/ch/cyberduck/core/ftp/FTPMoveFeature.java @@ -62,7 +62,7 @@ public EnumSet features(final Path source, final Path target) { } @Override - public void preflight(final Path source, final Path target) { + public void preflight(final Path source, final Path directory, final String filename) { // Skip checking permission mask } } diff --git a/ftp/src/test/java/ch/cyberduck/core/shared/StatefulDefaultCopyFeatureTest.java b/ftp/src/test/java/ch/cyberduck/core/shared/StatefulDefaultCopyFeatureTest.java index 5d2ca362ae3..f7cca49291f 100644 --- a/ftp/src/test/java/ch/cyberduck/core/shared/StatefulDefaultCopyFeatureTest.java +++ b/ftp/src/test/java/ch/cyberduck/core/shared/StatefulDefaultCopyFeatureTest.java @@ -38,8 +38,8 @@ public class StatefulDefaultCopyFeatureTest extends AbstractFTPTest { public void testSupported() throws Exception { final Path source = new Path(new DefaultHomeFinderService(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)); final Path target = new Path(new DefaultHomeFinderService(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)); - assertFalse(new DefaultCopyFeature(session).isSupported(source, target)); - assertFalse(new DefaultCopyFeature(session).withTarget(session).isSupported(source, target)); - assertTrue(new DefaultCopyFeature(session).withTarget(new FTPSession(new Host(session.getHost()).withCredentials(new Credentials("test", "test")))).isSupported(source, target)); + assertFalse(new DefaultCopyFeature(session).isSupported(source, target.getParent(), target.getName())); + assertFalse(new DefaultCopyFeature(session).withTarget(session).isSupported(source, target.getParent(), target.getName())); + assertTrue(new DefaultCopyFeature(session).withTarget(new FTPSession(new Host(session.getHost()).withCredentials(new Credentials("test", "test")))).isSupported(source, target.getParent(), target.getName())); } } diff --git a/googledrive/src/main/java/ch/cyberduck/core/googledrive/DriveCopyFeature.java b/googledrive/src/main/java/ch/cyberduck/core/googledrive/DriveCopyFeature.java index 98f37a340ea..e9505926ac7 100644 --- a/googledrive/src/main/java/ch/cyberduck/core/googledrive/DriveCopyFeature.java +++ b/googledrive/src/main/java/ch/cyberduck/core/googledrive/DriveCopyFeature.java @@ -64,9 +64,9 @@ public EnumSet features(final Path source, final Path target) { } @Override - public void preflight(final Path source, final Path target) throws BackgroundException { - if(target.getParent().isRoot()) { - throw new UnsupportedException(MessageFormat.format(LocaleFactory.localizedString("Cannot copy {0}", "Error"), source.getName())).withFile(target); + public void preflight(final Path source, final Path directory, final String filename) throws BackgroundException { + if(directory.isRoot()) { + throw new UnsupportedException(MessageFormat.format(LocaleFactory.localizedString("Cannot copy {0}", "Error"), source.getName())).withFile(directory); } if(source.isPlaceholder()) { // Disable for application/vnd.google-apps diff --git a/googledrive/src/main/java/ch/cyberduck/core/googledrive/DriveMoveFeature.java b/googledrive/src/main/java/ch/cyberduck/core/googledrive/DriveMoveFeature.java index c2c44bb8204..68018592556 100644 --- a/googledrive/src/main/java/ch/cyberduck/core/googledrive/DriveMoveFeature.java +++ b/googledrive/src/main/java/ch/cyberduck/core/googledrive/DriveMoveFeature.java @@ -104,9 +104,9 @@ public EnumSet features(final Path source, final Path target) { } @Override - public void preflight(final Path source, final Path target) throws BackgroundException { - if(target.getParent().isRoot()) { - throw new UnsupportedException(MessageFormat.format(LocaleFactory.localizedString("Cannot rename {0}", "Error"), source.getName())).withFile(target); + public void preflight(final Path source, final Path directory, final String filename) throws BackgroundException { + if(directory.isRoot()) { + throw new UnsupportedException(MessageFormat.format(LocaleFactory.localizedString("Cannot rename {0}", "Error"), source.getName())).withFile(directory); } if(source.isPlaceholder()) { // Disable for application/vnd.google-apps diff --git a/googlestorage/src/main/java/ch/cyberduck/core/googlestorage/GoogleStorageCopyFeature.java b/googlestorage/src/main/java/ch/cyberduck/core/googlestorage/GoogleStorageCopyFeature.java index 8dbc390fd92..3a6da4f766e 100644 --- a/googlestorage/src/main/java/ch/cyberduck/core/googlestorage/GoogleStorageCopyFeature.java +++ b/googlestorage/src/main/java/ch/cyberduck/core/googlestorage/GoogleStorageCopyFeature.java @@ -81,12 +81,12 @@ public Path copy(final Path source, final Path target, final TransferStatus stat } @Override - public void preflight(final Path source, final Path target) throws BackgroundException { + public void preflight(final Path source, final Path directory, final String filename) throws BackgroundException { if(containerService.isContainer(source)) { throw new UnsupportedException(MessageFormat.format(LocaleFactory.localizedString("Cannot copy {0}", "Error"), source.getName())).withFile(source); } - if(containerService.isContainer(target)) { - throw new UnsupportedException(MessageFormat.format(LocaleFactory.localizedString("Cannot copy {0}", "Error"), source.getName())).withFile(target); + if(directory.isRoot()) { + throw new UnsupportedException(MessageFormat.format(LocaleFactory.localizedString("Cannot copy {0}", "Error"), source.getName())).withFile(directory); } } } diff --git a/googlestorage/src/main/java/ch/cyberduck/core/googlestorage/GoogleStorageMoveFeature.java b/googlestorage/src/main/java/ch/cyberduck/core/googlestorage/GoogleStorageMoveFeature.java index 68a6c703cc9..463c357110a 100644 --- a/googlestorage/src/main/java/ch/cyberduck/core/googlestorage/GoogleStorageMoveFeature.java +++ b/googlestorage/src/main/java/ch/cyberduck/core/googlestorage/GoogleStorageMoveFeature.java @@ -43,8 +43,8 @@ public Path move(final Path source, final Path renamed, final TransferStatus sta } @Override - public void preflight(final Path source, final Path target) throws BackgroundException { - proxy.preflight(source, target); + public void preflight(final Path source, final Path directory, final String filename) throws BackgroundException { + proxy.preflight(source, directory, filename); delete.preflight(source); } } diff --git a/googlestorage/src/test/java/ch/cyberduck/core/googlestorage/GoogleStorageCopyFeatureTest.java b/googlestorage/src/test/java/ch/cyberduck/core/googlestorage/GoogleStorageCopyFeatureTest.java index bd056f99dfd..8f56a8ade34 100644 --- a/googlestorage/src/test/java/ch/cyberduck/core/googlestorage/GoogleStorageCopyFeatureTest.java +++ b/googlestorage/src/test/java/ch/cyberduck/core/googlestorage/GoogleStorageCopyFeatureTest.java @@ -45,7 +45,7 @@ public void testCopyFileZeroLength() throws Exception { new GoogleStorageTouchFeature(session).touch(test, new TransferStatus().withMime("application/cyberduck").withMetadata(Collections.singletonMap("cyberduck", "set"))); final Path copy = new Path(container, new AsciiRandomStringService().random(), EnumSet.of(Path.Type.file)); final GoogleStorageCopyFeature feature = new GoogleStorageCopyFeature(session); - assertTrue(feature.isSupported(test, copy)); + assertTrue(feature.isSupported(test, copy.getParent(), copy.getName())); feature.copy(test, copy, new TransferStatus(), new DisabledConnectionCallback(), new DisabledStreamListener()); assertTrue(new GoogleStorageFindFeature(session).find(test)); new GoogleStorageDeleteFeature(session).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback()); diff --git a/googlestorage/src/test/java/ch/cyberduck/core/googlestorage/GoogleStorageMoveFeatureTest.java b/googlestorage/src/test/java/ch/cyberduck/core/googlestorage/GoogleStorageMoveFeatureTest.java index daa26e92672..34c911dff84 100644 --- a/googlestorage/src/test/java/ch/cyberduck/core/googlestorage/GoogleStorageMoveFeatureTest.java +++ b/googlestorage/src/test/java/ch/cyberduck/core/googlestorage/GoogleStorageMoveFeatureTest.java @@ -79,9 +79,9 @@ public void testMoveWithDelimiter() throws Exception { @Test public void testSupport() { final Path c = new Path("/c", EnumSet.of(Path.Type.directory)); - assertFalse(new GoogleStorageMoveFeature(session).isSupported(c, c)); + assertFalse(new GoogleStorageMoveFeature(session).isSupported(c, c.getParent(), c.getName())); final Path cf = new Path("/c/f", EnumSet.of(Path.Type.directory)); - assertTrue(new GoogleStorageMoveFeature(session).isSupported(cf, cf)); + assertTrue(new GoogleStorageMoveFeature(session).isSupported(cf, cf.getParent(), cf.getName())); } @Test diff --git a/manta/src/main/java/ch/cyberduck/core/manta/MantaMoveFeature.java b/manta/src/main/java/ch/cyberduck/core/manta/MantaMoveFeature.java index 1cb3ea3cbd3..fb362a0b6c9 100644 --- a/manta/src/main/java/ch/cyberduck/core/manta/MantaMoveFeature.java +++ b/manta/src/main/java/ch/cyberduck/core/manta/MantaMoveFeature.java @@ -65,8 +65,8 @@ public EnumSet features(final Path source, final Path target) { } @Override - public void preflight(final Path source, final Path target) throws BackgroundException { - if(!session.isUserWritable(target)) { + public void preflight(final Path source, final Path directory, final String filename) throws BackgroundException { + if(!session.isUserWritable(directory)) { throw new AccessDeniedException(MessageFormat.format(LocaleFactory.localizedString("Cannot rename {0}", "Error"), source.getName())).withFile(source); } } diff --git a/manta/src/test/java/ch/cyberduck/core/manta/MantaMoveFeatureTest.java b/manta/src/test/java/ch/cyberduck/core/manta/MantaMoveFeatureTest.java index 8e41a42bd0b..3d8cbea9514 100644 --- a/manta/src/test/java/ch/cyberduck/core/manta/MantaMoveFeatureTest.java +++ b/manta/src/test/java/ch/cyberduck/core/manta/MantaMoveFeatureTest.java @@ -50,7 +50,7 @@ public void testRename() throws BackgroundException { touch.touch(file, new TransferStatus().withMime("x-application/cyberduck")); assertNotNull(attributesFinder.find(file)); Path rename = new Path(drive, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)); - assertTrue(move.isSupported(file, rename)); + assertTrue(move.isSupported(file, rename.getParent(), rename.getName())); assertEquals(rename, move.move(file, rename, new TransferStatus(), new Delete.DisabledCallback(), new DisabledConnectionCallback())); assertFalse(new MantaFindFeature(session).find(file)); assertTrue(new MantaFindFeature(session).find(rename)); @@ -73,7 +73,7 @@ public void testMove() throws BackgroundException { touch.touch(touchedFile, new TransferStatus().withMime("x-application/cyberduck")); assertNotNull(attributesFinder.find(touchedFile)); Path rename = new Path(targetDirectory, touchedFile.getName(), EnumSet.of(Path.Type.file)); - assertTrue(move.isSupported(touchedFile, rename)); + assertTrue(move.isSupported(touchedFile, rename.getParent(), rename.getName())); assertEquals(rename, move.move(touchedFile, rename, new TransferStatus(), new Delete.DisabledCallback(), new DisabledConnectionCallback())); assertNotNull(attributesFinder.find(rename)); assertFalse(new MantaFindFeature(session).find(touchedFile)); @@ -96,7 +96,7 @@ public void testMoveRename() throws BackgroundException { touch.touch(touchedFile, new TransferStatus().withMime("x-application/cyberduck")); assertNotNull(attributesFinder.find(touchedFile)); Path rename = new Path(targetDirectory, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)); - assertTrue(move.isSupported(touchedFile, rename)); + assertTrue(move.isSupported(touchedFile, rename.getParent(), rename.getName())); assertEquals(rename, move.move(touchedFile, rename, new TransferStatus(), new Delete.DisabledCallback(), new DisabledConnectionCallback())); assertNotNull(attributesFinder.find(rename)); assertFalse(new MantaFindFeature(session).find(touchedFile)); diff --git a/onedrive/src/main/java/ch/cyberduck/core/onedrive/features/GraphCopyFeature.java b/onedrive/src/main/java/ch/cyberduck/core/onedrive/features/GraphCopyFeature.java index e3807d21a02..8ee1e0f7d30 100644 --- a/onedrive/src/main/java/ch/cyberduck/core/onedrive/features/GraphCopyFeature.java +++ b/onedrive/src/main/java/ch/cyberduck/core/onedrive/features/GraphCopyFeature.java @@ -95,14 +95,14 @@ public EnumSet features(final Path source, final Path target) { } @Override - public void preflight(final Path source, final Path target) throws BackgroundException { - if(!session.isAccessible(target, true)) { + public void preflight(final Path source, final Path directory, final String filename) throws BackgroundException { + if(!session.isAccessible(directory, true)) { throw new UnsupportedException(MessageFormat.format(LocaleFactory.localizedString("Cannot copy {0}", "Error"), source.getName())).withFile(source); } if(!session.isAccessible(source, false)) { throw new UnsupportedException(MessageFormat.format(LocaleFactory.localizedString("Cannot copy {0}", "Error"), source.getName())).withFile(source); } - if(!session.getContainer(source).equals(session.getContainer(target))) { + if(!session.getContainer(source).equals(session.getContainer(directory))) { throw new UnsupportedException(MessageFormat.format(LocaleFactory.localizedString("Cannot copy {0}", "Error"), source.getName())).withFile(source); } if(source.getType().contains(Path.Type.shared)) { diff --git a/onedrive/src/main/java/ch/cyberduck/core/onedrive/features/GraphMoveFeature.java b/onedrive/src/main/java/ch/cyberduck/core/onedrive/features/GraphMoveFeature.java index ab2b52c067b..7acb1f982db 100644 --- a/onedrive/src/main/java/ch/cyberduck/core/onedrive/features/GraphMoveFeature.java +++ b/onedrive/src/main/java/ch/cyberduck/core/onedrive/features/GraphMoveFeature.java @@ -101,14 +101,14 @@ public EnumSet features(final Path source, final Path target) { } @Override - public void preflight(final Path source, final Path target) throws BackgroundException { - if(!session.isAccessible(target, true)) { + public void preflight(final Path source, final Path directory, final String filename) throws BackgroundException { + if(!session.isAccessible(directory, true)) { throw new AccessDeniedException(MessageFormat.format(LocaleFactory.localizedString("Cannot rename {0}", "Error"), source.getName())).withFile(source); } if(!session.isAccessible(source, false)) { throw new AccessDeniedException(MessageFormat.format(LocaleFactory.localizedString("Cannot rename {0}", "Error"), source.getName())).withFile(source); } - if(!session.getContainer(source).equals(session.getContainer(target))) { + if(!session.getContainer(source).equals(session.getContainer(directory))) { throw new UnsupportedException(MessageFormat.format(LocaleFactory.localizedString("Cannot rename {0}", "Error"), source.getName())).withFile(source); } if(source.getType().contains(Path.Type.shared)) { diff --git a/onedrive/src/test/java/ch/cyberduck/core/onedrive/GraphCopyFeatureTest.java b/onedrive/src/test/java/ch/cyberduck/core/onedrive/GraphCopyFeatureTest.java index c18f9a5c0cb..ad67d2b6428 100644 --- a/onedrive/src/test/java/ch/cyberduck/core/onedrive/GraphCopyFeatureTest.java +++ b/onedrive/src/test/java/ch/cyberduck/core/onedrive/GraphCopyFeatureTest.java @@ -70,7 +70,7 @@ public void testCopy() throws Exception { assertNotNull(new GraphAttributesFinderFeature(session, fileid).find(file)); Path rename = new Path(directory, file.getName(), EnumSet.of(Path.Type.file)); final GraphCopyFeature copy = new GraphCopyFeature(session, fileid); - assertTrue(copy.isSupported(file, rename)); + assertTrue(copy.isSupported(file, rename.getParent(), rename.getName())); final Path target = copy.copy(file, rename, new TransferStatus(), new DisabledConnectionCallback(), new DisabledStreamListener()); assertNotEquals(file.attributes().getFileId(), target.attributes().getFileId()); assertEquals(target.attributes().getFileId(), new GraphAttributesFinderFeature(session, fileid).find(rename).getFileId()); diff --git a/onedrive/src/test/java/ch/cyberduck/core/onedrive/GraphMoveFeatureTest.java b/onedrive/src/test/java/ch/cyberduck/core/onedrive/GraphMoveFeatureTest.java index 5bb570d420d..f14f15d9a95 100644 --- a/onedrive/src/test/java/ch/cyberduck/core/onedrive/GraphMoveFeatureTest.java +++ b/onedrive/src/test/java/ch/cyberduck/core/onedrive/GraphMoveFeatureTest.java @@ -76,7 +76,7 @@ public void testRename() throws BackgroundException { assertNotNull(attributes); assertEquals(file.attributes().getFileId(), attributes.getFileId()); Path rename = new Path(drive, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)); - assertTrue(move.isSupported(file, rename)); + assertTrue(move.isSupported(file, rename.getParent(), rename.getName())); final TransferStatus status = new TransferStatus(); final Path target = move.move(file, rename, status, new Delete.DisabledCallback(), new DisabledConnectionCallback()); assertEquals(attributes, target.attributes()); @@ -103,7 +103,7 @@ public void testMove() throws BackgroundException { final PathAttributes attributes = attributesFinder.find(touchedFile); Path rename = new Path(targetDirectory, touchedFile.getName(), EnumSet.of(Path.Type.file)); - assertTrue(move.isSupported(touchedFile, rename)); + assertTrue(move.isSupported(touchedFile, rename.getParent(), rename.getName())); final Path target = move.move(touchedFile, rename, new TransferStatus(), new Delete.DisabledCallback(), new DisabledConnectionCallback()); final PathAttributes renamedAttributes = attributesFinder.find(rename); assertNotNull(renamedAttributes); @@ -131,7 +131,7 @@ public void testMoveToRoot() throws BackgroundException { assertNotNull(attributesFinder.find(touchedFile)); Path rename = new Path(drive, touchedFile.getName(), EnumSet.of(Path.Type.file)); - assertTrue(move.isSupported(touchedFile, rename)); + assertTrue(move.isSupported(touchedFile, rename.getParent(), rename.getName())); move.move(touchedFile, rename, new TransferStatus(), new Delete.DisabledCallback(), new DisabledConnectionCallback()); assertNotNull(attributesFinder.find(rename)); @@ -156,7 +156,7 @@ public void testMoveRename() throws BackgroundException { assertNotNull(attributesFinder.find(touchedFile)); Path rename = new Path(targetDirectory, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)); - assertTrue(move.isSupported(touchedFile, rename)); + assertTrue(move.isSupported(touchedFile, rename.getParent(), rename.getName())); move.move(touchedFile, rename, new TransferStatus(), new Delete.DisabledCallback(), new DisabledConnectionCallback()); assertNotNull(attributesFinder.find(rename)); diff --git a/onedrive/src/test/java/ch/cyberduck/core/onedrive/OfflineGraphCopyMoveFeatureTest.java b/onedrive/src/test/java/ch/cyberduck/core/onedrive/OfflineGraphCopyMoveFeatureTest.java index 9d5f167663a..6b339b6cf44 100644 --- a/onedrive/src/test/java/ch/cyberduck/core/onedrive/OfflineGraphCopyMoveFeatureTest.java +++ b/onedrive/src/test/java/ch/cyberduck/core/onedrive/OfflineGraphCopyMoveFeatureTest.java @@ -147,11 +147,11 @@ void test(final Object feature, final List test) { if(feature instanceof Move) { final Move move = (Move) feature; - assertEquals(String.format("Move \"%s\" to \"%s\".", from, to), testCase.isValid, move.isSupported(from, to)); + assertEquals(String.format("Move \"%s\" to \"%s\".", from, to), testCase.isValid, move.isSupported(from, to.getParent(), to.getName())); } else if(feature instanceof Copy) { final Copy copy = (Copy) feature; - assertEquals(String.format("Copy \"%s\" to \"%s\".", from, to), testCase.isValid, copy.isSupported(from, to)); + assertEquals(String.format("Copy \"%s\" to \"%s\".", from, to), testCase.isValid, copy.isSupported(from, to.getParent(), to.getName())); } else { fail(); diff --git a/openstack/src/main/java/ch/cyberduck/core/openstack/SwiftDefaultCopyFeature.java b/openstack/src/main/java/ch/cyberduck/core/openstack/SwiftDefaultCopyFeature.java index 6e16bf52078..e6a4c198a7b 100644 --- a/openstack/src/main/java/ch/cyberduck/core/openstack/SwiftDefaultCopyFeature.java +++ b/openstack/src/main/java/ch/cyberduck/core/openstack/SwiftDefaultCopyFeature.java @@ -72,12 +72,12 @@ public Path copy(final Path source, final Path target, final TransferStatus stat } @Override - public void preflight(final Path source, final Path target) throws BackgroundException { + public void preflight(final Path source, final Path directory, final String filename) throws BackgroundException { if(containerService.isContainer(source)) { throw new UnsupportedException(MessageFormat.format(LocaleFactory.localizedString("Cannot copy {0}", "Error"), source.getName())).withFile(source); } - if(containerService.isContainer(target)) { - throw new UnsupportedException(MessageFormat.format(LocaleFactory.localizedString("Cannot copy {0}", "Error"), source.getName())).withFile(target); + if(directory.isRoot()) { + throw new UnsupportedException(MessageFormat.format(LocaleFactory.localizedString("Cannot copy {0}", "Error"), source.getName())).withFile(directory); } } } diff --git a/openstack/src/main/java/ch/cyberduck/core/openstack/SwiftLargeObjectCopyFeature.java b/openstack/src/main/java/ch/cyberduck/core/openstack/SwiftLargeObjectCopyFeature.java index 435a5e22a5d..0368c0d739d 100644 --- a/openstack/src/main/java/ch/cyberduck/core/openstack/SwiftLargeObjectCopyFeature.java +++ b/openstack/src/main/java/ch/cyberduck/core/openstack/SwiftLargeObjectCopyFeature.java @@ -67,12 +67,12 @@ public Path copy(final Path source, final Path target, final TransferStatus stat } @Override - public void preflight(final Path source, final Path target) throws BackgroundException { + public void preflight(final Path source, final Path directory, final String filename) throws BackgroundException { if(containerService.isContainer(source)) { throw new UnsupportedException(MessageFormat.format(LocaleFactory.localizedString("Cannot copy {0}", "Error"), source.getName())).withFile(source); } - if(containerService.isContainer(target)) { - throw new UnsupportedException(MessageFormat.format(LocaleFactory.localizedString("Cannot copy {0}", "Error"), source.getName())).withFile(target); + if(directory.isRoot()) { + throw new UnsupportedException(MessageFormat.format(LocaleFactory.localizedString("Cannot copy {0}", "Error"), source.getName())).withFile(directory); } } diff --git a/openstack/src/main/java/ch/cyberduck/core/openstack/SwiftMoveFeature.java b/openstack/src/main/java/ch/cyberduck/core/openstack/SwiftMoveFeature.java index 965073a340c..d6abdea0105 100644 --- a/openstack/src/main/java/ch/cyberduck/core/openstack/SwiftMoveFeature.java +++ b/openstack/src/main/java/ch/cyberduck/core/openstack/SwiftMoveFeature.java @@ -68,8 +68,8 @@ public Path move(final Path file, final Path renamed, final TransferStatus statu } @Override - public void preflight(final Path source, final Path target) throws BackgroundException { - proxy.preflight(source, target); + public void preflight(final Path source, final Path directory, final String filename) throws BackgroundException { + proxy.preflight(source, directory, filename); delete.preflight(source); } } diff --git a/openstack/src/main/java/ch/cyberduck/core/openstack/SwiftSegmentCopyService.java b/openstack/src/main/java/ch/cyberduck/core/openstack/SwiftSegmentCopyService.java index 1ed223b95d3..7510d55f69d 100644 --- a/openstack/src/main/java/ch/cyberduck/core/openstack/SwiftSegmentCopyService.java +++ b/openstack/src/main/java/ch/cyberduck/core/openstack/SwiftSegmentCopyService.java @@ -60,12 +60,12 @@ public Path copy(final Path source, final Path target, final TransferStatus stat } @Override - public void preflight(final Path source, final Path target) throws BackgroundException { + public void preflight(final Path source, final Path directory, final String filename) throws BackgroundException { if(containerService.isContainer(source)) { throw new UnsupportedException(MessageFormat.format(LocaleFactory.localizedString("Cannot copy {0}", "Error"), source.getName())).withFile(source); } - if(containerService.isContainer(target)) { - throw new UnsupportedException(MessageFormat.format(LocaleFactory.localizedString("Cannot copy {0}", "Error"), source.getName())).withFile(target); + if(directory.isRoot()) { + throw new UnsupportedException(MessageFormat.format(LocaleFactory.localizedString("Cannot copy {0}", "Error"), source.getName())).withFile(directory); } } } diff --git a/openstack/src/test/java/ch/cyberduck/core/openstack/SwiftMoveFeatureTest.java b/openstack/src/test/java/ch/cyberduck/core/openstack/SwiftMoveFeatureTest.java index 131f06d932d..42e3eb5c018 100644 --- a/openstack/src/test/java/ch/cyberduck/core/openstack/SwiftMoveFeatureTest.java +++ b/openstack/src/test/java/ch/cyberduck/core/openstack/SwiftMoveFeatureTest.java @@ -89,9 +89,9 @@ public void testMoveNotFound() throws Exception { @Test public void testSupport() { final Path c = new Path("/c", EnumSet.of(Path.Type.directory)); - assertFalse(new SwiftMoveFeature(session).isSupported(c, c)); + assertFalse(new SwiftMoveFeature(session).isSupported(c, c.getParent(), c.getName())); final Path cf = new Path("/c/f", EnumSet.of(Path.Type.directory)); - assertTrue(new SwiftMoveFeature(session).isSupported(cf, cf)); + assertTrue(new SwiftMoveFeature(session).isSupported(cf, cf.getParent(), cf.getName())); } @Test 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 18a1956914a..382c5ad8dd4 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 @@ -3809,7 +3809,7 @@ public boolean isColumnRowEditable(final NSTableColumn column, final NSInteger r if(null == file) { return false; } - return pool.getFeature(Move.class).isSupported(file, file); + return pool.getFeature(Move.class).isSupported(file, file.getParent(), file.getName()); } } diff --git a/osx/src/main/java/ch/cyberduck/ui/cocoa/controller/InfoController.java b/osx/src/main/java/ch/cyberduck/ui/cocoa/controller/InfoController.java index 1d924ff5e21..509c2225b7e 100644 --- a/osx/src/main/java/ch/cyberduck/ui/cocoa/controller/InfoController.java +++ b/osx/src/main/java/ch/cyberduck/ui/cocoa/controller/InfoController.java @@ -1614,7 +1614,7 @@ protected void initGeneral() { filenameField.setStringValue(this.getName()); final Path file = this.getSelected(); filenameField.setEnabled(1 == count - && session.getFeature(Move.class).isSupported(file, file)); + && session.getFeature(Move.class).isSupported(file, file.getParent(), StringUtils.EMPTY)); // Where String path; if(file.isSymbolicLink()) { diff --git a/osx/src/main/java/ch/cyberduck/ui/cocoa/datasource/BrowserTableDataSource.java b/osx/src/main/java/ch/cyberduck/ui/cocoa/datasource/BrowserTableDataSource.java index 7b695ba91e2..8d2de62c5aa 100644 --- a/osx/src/main/java/ch/cyberduck/ui/cocoa/datasource/BrowserTableDataSource.java +++ b/osx/src/main/java/ch/cyberduck/ui/cocoa/datasource/BrowserTableDataSource.java @@ -521,7 +521,7 @@ public NSUInteger validateDrop(final NSTableView view, final Path destination, f if(info.draggingSourceOperationMask().intValue() == NSDraggingInfo.NSDragOperationCopy.intValue()) { // Explicit copy requested if drag operation is already NSDragOperationCopy. User is pressing the option key. for(Path file : pasteboard) { - if(!controller.getSession().getFeature(Copy.class).isSupported(file, destination)) { + if(!controller.getSession().getFeature(Copy.class).isSupported(file, destination.getParent(), destination.getName())) { return NSDraggingInfo.NSDragOperationNone; } } @@ -529,7 +529,7 @@ public NSUInteger validateDrop(final NSTableView view, final Path destination, f } else { for(Path file : pasteboard) { - if(!controller.getSession().getFeature(Move.class).isSupported(file, destination)) { + if(!controller.getSession().getFeature(Move.class).isSupported(file, destination.getParent(), destination.getName())) { return NSDraggingInfo.NSDragOperationNone; } } diff --git a/osx/src/main/java/ch/cyberduck/ui/cocoa/toolbar/BrowserToolbarValidator.java b/osx/src/main/java/ch/cyberduck/ui/cocoa/toolbar/BrowserToolbarValidator.java index 3dc84dc0f5b..abcc4e5bc9e 100644 --- a/osx/src/main/java/ch/cyberduck/ui/cocoa/toolbar/BrowserToolbarValidator.java +++ b/osx/src/main/java/ch/cyberduck/ui/cocoa/toolbar/BrowserToolbarValidator.java @@ -33,8 +33,8 @@ import ch.cyberduck.core.features.Delete; import ch.cyberduck.core.features.Directory; import ch.cyberduck.core.features.Move; -import ch.cyberduck.core.features.Share; import ch.cyberduck.core.features.Restore; +import ch.cyberduck.core.features.Share; import ch.cyberduck.core.features.Symlink; import ch.cyberduck.core.features.Touch; import ch.cyberduck.core.features.Versioning; @@ -268,7 +268,7 @@ else if(action.equals(Foundation.selector("renameFileButtonClicked:"))) { if(null == selected) { return false; } - return controller.getSession().getFeature(Move.class).isSupported(selected, selected); + return controller.getSession().getFeature(Move.class).isSupported(selected, selected.getParent(), selected.getName()); } return false; } diff --git a/s3/src/main/java/ch/cyberduck/core/s3/S3CopyFeature.java b/s3/src/main/java/ch/cyberduck/core/s3/S3CopyFeature.java index 4d6b1d4f2c4..7f86818e424 100644 --- a/s3/src/main/java/ch/cyberduck/core/s3/S3CopyFeature.java +++ b/s3/src/main/java/ch/cyberduck/core/s3/S3CopyFeature.java @@ -105,12 +105,12 @@ protected String copy(final Path source, final S3Object destination, final Trans } @Override - public void preflight(final Path source, final Path target) throws BackgroundException { + public void preflight(final Path source, final Path directory, final String filename) throws BackgroundException { if(containerService.isContainer(source)) { throw new UnsupportedException(MessageFormat.format(LocaleFactory.localizedString("Cannot copy {0}", "Error"), source.getName())).withFile(source); } - if(containerService.isContainer(target)) { - throw new UnsupportedException(MessageFormat.format(LocaleFactory.localizedString("Cannot copy {0}", "Error"), source.getName())).withFile(target); + if(directory.isRoot()) { + throw new UnsupportedException(MessageFormat.format(LocaleFactory.localizedString("Cannot copy {0}", "Error"), source.getName())).withFile(directory); } } } diff --git a/s3/src/main/java/ch/cyberduck/core/s3/S3MoveFeature.java b/s3/src/main/java/ch/cyberduck/core/s3/S3MoveFeature.java index 6f0fcad432e..582d36f0d90 100644 --- a/s3/src/main/java/ch/cyberduck/core/s3/S3MoveFeature.java +++ b/s3/src/main/java/ch/cyberduck/core/s3/S3MoveFeature.java @@ -104,8 +104,8 @@ public Path move(final Path source, final Path renamed, final TransferStatus sta } @Override - public void preflight(final Path source, final Path target) throws BackgroundException { - proxy.preflight(source, target); + public void preflight(final Path source, final Path directory, final String filename) throws BackgroundException { + proxy.preflight(source, directory, filename); delete.preflight(source); } } diff --git a/s3/src/main/java/ch/cyberduck/core/s3/S3ThresholdCopyFeature.java b/s3/src/main/java/ch/cyberduck/core/s3/S3ThresholdCopyFeature.java index 384838f90bd..5f8f27f8bd8 100644 --- a/s3/src/main/java/ch/cyberduck/core/s3/S3ThresholdCopyFeature.java +++ b/s3/src/main/java/ch/cyberduck/core/s3/S3ThresholdCopyFeature.java @@ -58,12 +58,12 @@ public Path copy(final Path source, final Path copy, final TransferStatus status } @Override - public void preflight(final Path source, final Path target) throws BackgroundException { + public void preflight(final Path source, final Path directory, final String filename) throws BackgroundException { if(containerService.isContainer(source)) { throw new UnsupportedException(MessageFormat.format(LocaleFactory.localizedString("Cannot copy {0}", "Error"), source.getName())).withFile(source); } - if(containerService.isContainer(target)) { - throw new UnsupportedException(MessageFormat.format(LocaleFactory.localizedString("Cannot copy {0}", "Error"), source.getName())).withFile(target); + if(directory.isRoot()) { + throw new UnsupportedException(MessageFormat.format(LocaleFactory.localizedString("Cannot copy {0}", "Error"), source.getName())).withFile(directory); } } } diff --git a/s3/src/test/java/ch/cyberduck/core/s3/S3MoveFeatureTest.java b/s3/src/test/java/ch/cyberduck/core/s3/S3MoveFeatureTest.java index ddae7438a0b..131fa0399f5 100644 --- a/s3/src/test/java/ch/cyberduck/core/s3/S3MoveFeatureTest.java +++ b/s3/src/test/java/ch/cyberduck/core/s3/S3MoveFeatureTest.java @@ -145,9 +145,9 @@ public void testMoveWithDelimiter() throws Exception { @Test public void testSupport() { final Path c = new Path("/c", EnumSet.of(Path.Type.directory)); - assertFalse(new S3MoveFeature(session, new S3AccessControlListFeature(session)).isSupported(c, c)); + assertFalse(new S3MoveFeature(session, new S3AccessControlListFeature(session)).isSupported(c, c.getParent(), c.getName())); final Path cf = new Path("/c/f", EnumSet.of(Path.Type.directory)); - assertTrue(new S3MoveFeature(session, new S3AccessControlListFeature(session)).isSupported(cf, cf)); + assertTrue(new S3MoveFeature(session, new S3AccessControlListFeature(session)).isSupported(cf, cf.getParent(), cf.getName())); } @Test diff --git a/smb/src/main/java/ch/cyberduck/core/smb/SMBCopyFeature.java b/smb/src/main/java/ch/cyberduck/core/smb/SMBCopyFeature.java index b0865c86479..1cff373cae8 100644 --- a/smb/src/main/java/ch/cyberduck/core/smb/SMBCopyFeature.java +++ b/smb/src/main/java/ch/cyberduck/core/smb/SMBCopyFeature.java @@ -84,13 +84,13 @@ public Path copy(final Path source, final Path target, final TransferStatus stat } @Override - public void preflight(final Path source, final Path target) throws BackgroundException { + public void preflight(final Path source, final Path directory, final String filename) throws BackgroundException { if(source.isVolume()) { throw new UnsupportedException(MessageFormat.format(LocaleFactory.localizedString("Cannot copy {0}", "Error"), source.getName())).withFile(source); } final SMBPathContainerService containerService = new SMBPathContainerService(session); // Remote copy is only possible between files on the same server - if(!containerService.getContainer(source).equals(containerService.getContainer(target))) { + if(!containerService.getContainer(source).equals(containerService.getContainer(directory))) { throw new UnsupportedException(MessageFormat.format(LocaleFactory.localizedString("Cannot copy {0}", "Error"), source.getName())).withFile(source); } } diff --git a/smb/src/main/java/ch/cyberduck/core/smb/SMBMoveFeature.java b/smb/src/main/java/ch/cyberduck/core/smb/SMBMoveFeature.java index cf667f53668..006bcad860f 100644 --- a/smb/src/main/java/ch/cyberduck/core/smb/SMBMoveFeature.java +++ b/smb/src/main/java/ch/cyberduck/core/smb/SMBMoveFeature.java @@ -74,12 +74,12 @@ public Path move(final Path source, final Path target, final TransferStatus stat } @Override - public void preflight(final Path source, final Path target) throws BackgroundException { + public void preflight(final Path source, final Path directory, final String filename) throws BackgroundException { if(source.isVolume()) { throw new UnsupportedException(MessageFormat.format(LocaleFactory.localizedString("Cannot rename {0}", "Error"), source.getName())).withFile(source); } final SMBPathContainerService containerService = new SMBPathContainerService(session); - if(!containerService.getContainer(source).equals(containerService.getContainer(target))) { + if(!containerService.getContainer(source).equals(containerService.getContainer(directory))) { throw new UnsupportedException(MessageFormat.format(LocaleFactory.localizedString("Cannot rename {0}", "Error"), source.getName())).withFile(source); } } diff --git a/ssh/src/test/java/ch/cyberduck/core/shared/DefaultCopyFeatureTest.java b/ssh/src/test/java/ch/cyberduck/core/shared/DefaultCopyFeatureTest.java index e5176132371..b082a1026c0 100644 --- a/ssh/src/test/java/ch/cyberduck/core/shared/DefaultCopyFeatureTest.java +++ b/ssh/src/test/java/ch/cyberduck/core/shared/DefaultCopyFeatureTest.java @@ -48,7 +48,7 @@ public class DefaultCopyFeatureTest extends AbstractSFTPTest { public void testSupported() throws Exception { final Path source = new Path(new DefaultHomeFinderService(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)); final Path target = new Path(new DefaultHomeFinderService(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)); - assertTrue(new DefaultCopyFeature(session).isSupported(source, target)); + assertTrue(new DefaultCopyFeature(session).isSupported(source, target.getParent(), target.getName())); } @Test diff --git a/storegate/src/test/java/ch/cyberduck/core/storegate/StoregateCopyFeatureTest.java b/storegate/src/test/java/ch/cyberduck/core/storegate/StoregateCopyFeatureTest.java index 466532cccf7..ac80300b40d 100644 --- a/storegate/src/test/java/ch/cyberduck/core/storegate/StoregateCopyFeatureTest.java +++ b/storegate/src/test/java/ch/cyberduck/core/storegate/StoregateCopyFeatureTest.java @@ -50,7 +50,7 @@ public void testCopyFileServerSide() throws Exception { final TransferStatus status = new TransferStatus(); new StoregateTouchFeature(session, nodeid).touch(copy, status); final StoregateCopyFeature feature = new StoregateCopyFeature(session, nodeid); - assertTrue(feature.isSupported(test, copy)); + assertTrue(feature.isSupported(test, copy.getParent(), copy.getName())); assertNotEquals(test.attributes().getFileId(), new StoregateCopyFeature(session, nodeid).copy(test, copy, new TransferStatus(), new DisabledConnectionCallback(), new DisabledStreamListener()).attributes().getFileId()); assertTrue(new DefaultFindFeature(session).find(test)); assertTrue(new DefaultFindFeature(session).find(copy)); @@ -83,7 +83,7 @@ public void testCopyServerSideToExistingFile() throws Exception { final Path copy = new Path(targetFolder, test.getName(), EnumSet.of(Path.Type.file)); new StoregateTouchFeature(session, fileid).touch(copy, new TransferStatus()); final StoregateCopyFeature feature = new StoregateCopyFeature(session, fileid); - assertTrue(feature.isSupported(test, copy)); + assertTrue(feature.isSupported(test, copy.getParent(), copy.getName())); assertNotEquals(test.attributes().getFileId(), new StoregateCopyFeature(session, fileid).copy(test, copy, new TransferStatus().exists(true), new DisabledConnectionCallback(), new DisabledStreamListener()).attributes().getFileId()); final Find find = new DefaultFindFeature(session); final AttributedList files = new StoregateListService(session, fileid).list(targetFolder, new DisabledListProgressListener()); @@ -121,7 +121,7 @@ public void testCopyDirectoryServerSide() throws Exception { final Path target_parent = new StoregateDirectoryFeature(session, fileid).mkdir(new Path(top, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)), new TransferStatus()); final Path target = new Path(target_parent, directory.getName(), EnumSet.of(Path.Type.directory)); final StoregateCopyFeature feature = new StoregateCopyFeature(session, fileid); - assertTrue(feature.isSupported(directory, target)); + assertTrue(feature.isSupported(directory, target.getParent(), target.getName())); final Path copy = new StoregateCopyFeature(session, fileid).copy(directory, target, new TransferStatus(), new DisabledConnectionCallback(), new DisabledStreamListener()); assertNotEquals(file.attributes().getFileId(), copy.attributes().getFileId()); assertTrue(new DefaultFindFeature(session).find(file)); diff --git a/windows/src/main/csharp/ch/cyberduck/ui/controller/BrowserController.cs b/windows/src/main/csharp/ch/cyberduck/ui/controller/BrowserController.cs index 271a580ea85..98def66e721 100644 --- a/windows/src/main/csharp/ch/cyberduck/ui/controller/BrowserController.cs +++ b/windows/src/main/csharp/ch/cyberduck/ui/controller/BrowserController.cs @@ -1056,7 +1056,7 @@ private void View_BrowserModelCanDrop(ModelDropEventArgs args) Move move = (Move)Session.getFeature(typeof(Move)); foreach (Path sourcePath in args.SourceModels) { - if (!move.isSupported(sourcePath, destination)) + if (!move.isSupported(sourcePath, destination.getParent(), destination.getName())) { args.Effect = DragDropEffects.None; args.DropTargetLocation = DropTargetLocation.None; @@ -2032,7 +2032,7 @@ private bool View_ValidateRenameFile() { return false; } - return ((Move)Session.getFeature(typeof(Move))).isSupported(SelectedPath, SelectedPath); + return ((Move)Session.getFeature(typeof(Move))).isSupported(SelectedPath, SelectedPath.getParent(), String.Empty); } return false; } diff --git a/windows/src/main/csharp/ch/cyberduck/ui/controller/InfoController.cs b/windows/src/main/csharp/ch/cyberduck/ui/controller/InfoController.cs index ae73b2295cd..80a350c82b0 100755 --- a/windows/src/main/csharp/ch/cyberduck/ui/controller/InfoController.cs +++ b/windows/src/main/csharp/ch/cyberduck/ui/controller/InfoController.cs @@ -820,7 +820,7 @@ private void InitGeneral() Path file = _files[0]; View.FilenameEnabled = (1 == count && - ((Move)_controller.Session.getFeature(typeof(Move))).isSupported(file, file)); + ((Move)_controller.Session.getFeature(typeof(Move))).isSupported(file, file.getParent(), String.Empty)); string path; if (file.isSymbolicLink()) {