Search in sources :

Example 1 with CachingFindFeature

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());
}
Also used : PathCache(ch.cyberduck.core.PathCache) Path(ch.cyberduck.core.Path) Delete(ch.cyberduck.core.features.Delete) S3TouchFeature(ch.cyberduck.core.s3.S3TouchFeature) S3DefaultDeleteFeature(ch.cyberduck.core.s3.S3DefaultDeleteFeature) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) CachingFindFeature(ch.cyberduck.core.CachingFindFeature) AbstractS3Test(ch.cyberduck.core.s3.AbstractS3Test) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Example 2 with CachingFindFeature

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);
}
Also used : DefaultFindFeature(ch.cyberduck.core.shared.DefaultFindFeature) Find(ch.cyberduck.core.features.Find) ArrayList(java.util.ArrayList) CachingFindFeature(ch.cyberduck.core.CachingFindFeature) HashSet(java.util.HashSet)

Example 3 with CachingFindFeature

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());
}
Also used : PathCache(ch.cyberduck.core.PathCache) Path(ch.cyberduck.core.Path) Delete(ch.cyberduck.core.features.Delete) S3AttributesFinderFeature(ch.cyberduck.core.s3.S3AttributesFinderFeature) S3FindFeature(ch.cyberduck.core.s3.S3FindFeature) S3TouchFeature(ch.cyberduck.core.s3.S3TouchFeature) S3DefaultDeleteFeature(ch.cyberduck.core.s3.S3DefaultDeleteFeature) CachingAttributesFinderFeature(ch.cyberduck.core.CachingAttributesFinderFeature) CachingFindFeature(ch.cyberduck.core.CachingFindFeature) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) Find(ch.cyberduck.core.features.Find) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) ListProgressListener(ch.cyberduck.core.ListProgressListener) AbstractS3Test(ch.cyberduck.core.s3.AbstractS3Test) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Example 4 with CachingFindFeature

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);
}
Also used : SynchronizationPathFilter(ch.cyberduck.core.transfer.synchronisation.SynchronizationPathFilter) DefaultAttributesFinderFeature(ch.cyberduck.core.shared.DefaultAttributesFinderFeature) DefaultFindFeature(ch.cyberduck.core.shared.DefaultFindFeature) CachingAttributesFinderFeature(ch.cyberduck.core.CachingAttributesFinderFeature) AttributesFinder(ch.cyberduck.core.features.AttributesFinder) Find(ch.cyberduck.core.features.Find) CachingComparePathFilter(ch.cyberduck.core.synchronization.CachingComparePathFilter) CachingFindFeature(ch.cyberduck.core.CachingFindFeature) DefaultComparePathFilter(ch.cyberduck.core.synchronization.DefaultComparePathFilter)

Aggregations

CachingFindFeature (ch.cyberduck.core.CachingFindFeature)4 Find (ch.cyberduck.core.features.Find)3 AlphanumericRandomStringService (ch.cyberduck.core.AlphanumericRandomStringService)2 CachingAttributesFinderFeature (ch.cyberduck.core.CachingAttributesFinderFeature)2 DisabledLoginCallback (ch.cyberduck.core.DisabledLoginCallback)2 Path (ch.cyberduck.core.Path)2 PathCache (ch.cyberduck.core.PathCache)2 Delete (ch.cyberduck.core.features.Delete)2 AbstractS3Test (ch.cyberduck.core.s3.AbstractS3Test)2 S3DefaultDeleteFeature (ch.cyberduck.core.s3.S3DefaultDeleteFeature)2 S3TouchFeature (ch.cyberduck.core.s3.S3TouchFeature)2 DefaultFindFeature (ch.cyberduck.core.shared.DefaultFindFeature)2 TransferStatus (ch.cyberduck.core.transfer.TransferStatus)2 IntegrationTest (ch.cyberduck.test.IntegrationTest)2 Test (org.junit.Test)2 ListProgressListener (ch.cyberduck.core.ListProgressListener)1 AttributesFinder (ch.cyberduck.core.features.AttributesFinder)1 S3AttributesFinderFeature (ch.cyberduck.core.s3.S3AttributesFinderFeature)1 S3FindFeature (ch.cyberduck.core.s3.S3FindFeature)1 DefaultAttributesFinderFeature (ch.cyberduck.core.shared.DefaultAttributesFinderFeature)1