Skip to content

Commit

Permalink
Fix #7653. Allow to merge directories with the skip transfer option.
Browse files Browse the repository at this point in the history
Former-commit-id: 9ba99ae64d2a21106939ab40cfe130c27921aac3
  • Loading branch information
dkocher committed Apr 7, 2014
1 parent 49a10e0 commit 22d9d84
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 10 deletions.
2 changes: 1 addition & 1 deletion source/ch/cyberduck/core/transfer/download/SkipFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public SkipFilter(final SymlinkResolver<Path> symlinkResolver, final Session<?>

@Override
public boolean accept(final Path file, final Local local, final TransferStatus parent) throws BackgroundException {
if(local.exists()) {
if(local.isFile() && local.exists()) {
if(log.isInfoEnabled()) {
log.info(String.format("Skip file %s", file));
}
Expand Down
2 changes: 1 addition & 1 deletion source/ch/cyberduck/core/transfer/upload/SkipFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public SkipFilter(final SymlinkResolver<Local> symlinkResolver, final Session<?>
@Override
public boolean accept(final Path file, final Local local, final TransferStatus parent) throws BackgroundException {
if(parent.isExists()) {
if(find.find(file)) {
if(local.isFile() && find.find(file)) {
if(log.isInfoEnabled()) {
log.info(String.format("Skip file %s", file));
}
Expand Down
34 changes: 30 additions & 4 deletions test/ch/cyberduck/core/transfer/download/SkipFilterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,41 @@ public void testAccept() throws Exception {
public boolean exists() {
return false;
}
}, new TransferStatus()
));
}, new TransferStatus().exists(true)
)
);
assertFalse(f.accept(new Path("a", EnumSet.of(Path.Type.file)) {
}, new NullLocal("a", "b") {
@Override
public boolean exists() {
return true;
}
}, new TransferStatus()
));
}, new TransferStatus().exists(true)
)
);
}

@Test
public void testAcceptDirectory() throws Exception {
SkipFilter f = new SkipFilter(new DisabledDownloadSymlinkResolver(), new NullSession(new Host("h")));
assertTrue(f.accept(new Path("a", EnumSet.of(Path.Type.directory)) {
}, new NullLocal("a", "b") {
@Override
public boolean isFile() {
return false;
}

@Override
public boolean isDirectory() {
return true;
}

@Override
public boolean exists() {
return true;
}
}, new TransferStatus().exists(true)
)
);
}
}
39 changes: 35 additions & 4 deletions test/ch/cyberduck/core/transfer/upload/SkipFilterTest.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package ch.cyberduck.core.transfer.upload;

import ch.cyberduck.core.AbstractTestCase;
import ch.cyberduck.core.Cache;
import ch.cyberduck.core.Host;
import ch.cyberduck.core.NullLocal;
import ch.cyberduck.core.NullSession;
import ch.cyberduck.core.Path;
import ch.cyberduck.core.exception.BackgroundException;
import ch.cyberduck.core.exception.NotfoundException;
import ch.cyberduck.core.features.Find;
import ch.cyberduck.core.transfer.TransferStatus;
import ch.cyberduck.core.transfer.symlink.DisabledUploadSymlinkResolver;

Expand All @@ -23,13 +26,42 @@ public class SkipFilterTest extends AbstractTestCase {

@Test
public void testAccept() throws Exception {
SkipFilter f = new SkipFilter(new DisabledUploadSymlinkResolver(), new NullSession(new Host("h")) {
@Override
public <T> T getFeature(Class<T> type) {
if(type == Find.class) {
return (T) new Find() {
@Override
public boolean find(Path file) throws BackgroundException {
return true;
}

@Override
public Find withCache(Cache cache) {
return this;
}
};
}
return super.getFeature(type);
}
});
assertFalse(f.accept(new Path("a", EnumSet.of(Path.Type.file)), new NullLocal("a") {
@Override
public boolean exists() {
return true;
}
}, new TransferStatus().exists(true)));
}

@Test
public void testAcceptDirectory() throws Exception {
SkipFilter f = new SkipFilter(new DisabledUploadSymlinkResolver(), new NullSession(new Host("h")));
assertTrue(f.accept(new Path("a", EnumSet.of(Path.Type.file)), new NullLocal("a") {
assertTrue(f.accept(new Path("a", EnumSet.of(Path.Type.directory)), new NullLocal("a") {
@Override
public boolean exists() {
return true;
}
}, new TransferStatus()));
}, new TransferStatus().exists(true)));
}

@Test(expected = NotfoundException.class)
Expand All @@ -40,7 +72,6 @@ public void testNotFound() throws Exception {
public boolean exists() {
return false;
}
}, new TransferStatus()
));
}, new TransferStatus().exists(true)));
}
}

0 comments on commit 22d9d84

Please sign in to comment.