use of ch.cyberduck.core.CachingFindFeature in project cyberduck by iterate-ch.
the class CachingFindFeatureTest method testFindDefault.
@Test
public void testFindDefault() throws Exception {
final PathCache cache = new PathCache(1);
final Path bucket = new Path("versioning-test-us-east-1-cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume));
final String name = new AlphanumericRandomStringService().random();
final CachingFindFeature f = new CachingFindFeature(cache, new DefaultFindFeature(session));
assertFalse(f.find(new Path(bucket, name, EnumSet.of(Path.Type.file))));
final Path test = new S3TouchFeature(session).touch(new Path(bucket, name, EnumSet.of(Path.Type.file)), new TransferStatus());
assertFalse(f.find(test));
cache.clear();
assertTrue(f.find(test));
// Find without version id set in attributes
assertTrue(f.find(new Path(test).withAttributes(PathAttributes.EMPTY)));
new S3DefaultDeleteFeature(session).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
use of ch.cyberduck.core.CachingFindFeature in project cyberduck by iterate-ch.
the class SyncTransfer method list.
@Override
public List<TransferItem> list(final Session<?> session, final Path directory, final Local local, final ListProgressListener listener) throws BackgroundException {
if (log.isDebugEnabled()) {
log.debug(String.format("Children for %s", directory));
}
final Set<TransferItem> children = new HashSet<>();
final Find finder = new CachingFindFeature(cache, session.getFeature(Find.class, new DefaultFindFeature(session)));
if (finder.find(directory)) {
children.addAll(download.list(session, directory, local, listener));
}
if (local.exists()) {
children.addAll(upload.list(session, directory, local, listener));
}
return new ArrayList<>(children);
}
use of ch.cyberduck.core.CachingFindFeature in project cyberduck by iterate-ch.
the class CachingFindFeatureTest method testFind.
@Test
public void testFind() throws Exception {
final PathCache cache = new PathCache(1);
final Path bucket = new Path("versioning-test-us-east-1-cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume));
final Path file = new Path(bucket, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
assertFalse(new CachingFindFeature(cache, new S3FindFeature(session)).find(file));
final Path test = new S3TouchFeature(session).touch(file, new TransferStatus());
// Find without version id set in attributes
assertTrue(new CachingFindFeature(cache, new S3FindFeature(session)).find(test));
assertTrue(new CachingFindFeature(cache, new S3FindFeature(session)).find(file));
// Test wrong type
assertFalse(new CachingFindFeature(cache, new S3FindFeature(session)).find(new Path(bucket, test.getName(), EnumSet.of(Path.Type.directory))));
assertEquals(test.attributes(), new CachingAttributesFinderFeature(cache, new S3AttributesFinderFeature(session)).find(test));
assertTrue(new CachingFindFeature(cache, new Find() {
@Override
public boolean find(final Path file, final ListProgressListener listener) {
fail("Expected cache hit");
return false;
}
}).find(test));
new S3DefaultDeleteFeature(session).delete(Collections.singletonList(file), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
use of ch.cyberduck.core.CachingFindFeature in project cyberduck by iterate-ch.
the class SyncTransfer method filter.
@Override
public TransferPathFilter filter(final Session<?> source, final Session<?> destination, final TransferAction action, final ProgressListener listener) {
if (log.isDebugEnabled()) {
log.debug(String.format("Filter transfer with action %s", action));
}
final Find find = new CachingFindFeature(cache, source.getFeature(Find.class, new DefaultFindFeature(source)));
final AttributesFinder attributes = new CachingAttributesFinderFeature(cache, source.getFeature(AttributesFinder.class, new DefaultAttributesFinderFeature(source)));
// Set chosen action (upload, download, mirror) from prompt
comparison = new CachingComparePathFilter(new DefaultComparePathFilter(source, host.getTimezone())).withCache(comparisons).withAttributes(attributes).withFinder(find);
return new SynchronizationPathFilter(comparison, download.filter(source, destination, TransferAction.overwrite, listener).withAttributes(attributes).withFinder(find), upload.filter(source, destination, TransferAction.overwrite, listener).withAttributes(attributes).withFinder(find), action);
}
Aggregations