Search in sources :

Example 1 with UploadSymlinkResolver

use of ch.cyberduck.core.transfer.symlink.UploadSymlinkResolver in project cyberduck by iterate-ch.

the class SynchronizationPathFilterTest method testAcceptDirectory.

@Test
public void testAcceptDirectory() throws Exception {
    Session session = new NullSession(new Host(new TestProtocol()));
    final SynchronizationPathFilter mirror = new SynchronizationPathFilter(new ComparePathFilter() {

        @Override
        public Comparison compare(Path file, Local local, final ProgressListener listener) {
            return Comparison.equal;
        }
    }, new OverwriteFilter(new DownloadSymlinkResolver(Collections.<TransferItem>emptyList()), session), new ch.cyberduck.core.transfer.upload.OverwriteFilter(new UploadSymlinkResolver(null, Collections.<TransferItem>emptyList()), session), TransferAction.mirror);
    assertTrue(mirror.accept(new Path("/p", EnumSet.of(Path.Type.directory)), null, new TransferStatus().exists(true)));
}
Also used : Path(ch.cyberduck.core.Path) ComparePathFilter(ch.cyberduck.core.synchronization.ComparePathFilter) DefaultComparePathFilter(ch.cyberduck.core.synchronization.DefaultComparePathFilter) TestProtocol(ch.cyberduck.core.TestProtocol) NullSession(ch.cyberduck.core.NullSession) NullLocal(ch.cyberduck.core.NullLocal) Local(ch.cyberduck.core.Local) Host(ch.cyberduck.core.Host) DownloadSymlinkResolver(ch.cyberduck.core.transfer.symlink.DownloadSymlinkResolver) DisabledProgressListener(ch.cyberduck.core.DisabledProgressListener) ProgressListener(ch.cyberduck.core.ProgressListener) Comparison(ch.cyberduck.core.synchronization.Comparison) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) UploadSymlinkResolver(ch.cyberduck.core.transfer.symlink.UploadSymlinkResolver) OverwriteFilter(ch.cyberduck.core.transfer.download.OverwriteFilter) NullSession(ch.cyberduck.core.NullSession) Session(ch.cyberduck.core.Session) Test(org.junit.Test)

Example 2 with UploadSymlinkResolver

use of ch.cyberduck.core.transfer.symlink.UploadSymlinkResolver in project cyberduck by iterate-ch.

the class SynchronizationPathFilterTest method testPrepare.

@Test
public void testPrepare() throws Exception {
    final Path test = new Path("/t/a", EnumSet.of(Path.Type.file));
    Session session = new NullSession(new Host(new TestProtocol()));
    final NullLocal local = new NullLocal(System.getProperty("java.io.tmpdir"), UUID.randomUUID().toString()) {

        @Override
        public boolean isSymbolicLink() {
            return false;
        }

        @Override
        public LocalAttributes attributes() {
            return new LocalAttributes(this.getAbsolute()) {

                @Override
                public long getSize() {
                    return 1L;
                }
            };
        }

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

        @Override
        public boolean exists() {
            return true;
        }
    };
    final SynchronizationPathFilter mirror = new SynchronizationPathFilter(new DefaultComparePathFilter(session, TimeZone.getDefault()), new OverwriteFilter(new DownloadSymlinkResolver(Collections.<TransferItem>emptyList()), session), new ch.cyberduck.core.transfer.upload.OverwriteFilter(new UploadSymlinkResolver(null, Collections.<TransferItem>emptyList()), session), TransferAction.mirror);
    assertTrue(mirror.accept(test, local, new TransferStatus().exists(true)));
    final TransferStatus status = mirror.prepare(test, local, new TransferStatus().exists(true), new DisabledProgressListener());
    assertNotNull(status);
    assertEquals(1L, status.getLength());
    final SynchronizationPathFilter download = new SynchronizationPathFilter(new DefaultComparePathFilter(session, TimeZone.getDefault()), new OverwriteFilter(new DownloadSymlinkResolver(Collections.<TransferItem>emptyList()), session), new ch.cyberduck.core.transfer.upload.OverwriteFilter(new UploadSymlinkResolver(null, Collections.<TransferItem>emptyList()), session), TransferAction.download);
    assertFalse(download.accept(test, local, new TransferStatus().exists(true)));
    final SynchronizationPathFilter upload = new SynchronizationPathFilter(new DefaultComparePathFilter(session, TimeZone.getDefault()), new OverwriteFilter(new DownloadSymlinkResolver(Collections.<TransferItem>emptyList()), session), new ch.cyberduck.core.transfer.upload.OverwriteFilter(new UploadSymlinkResolver(null, Collections.<TransferItem>emptyList()), session), TransferAction.upload);
    assertTrue(upload.accept(test, local, new TransferStatus().exists(true)));
}
Also used : Path(ch.cyberduck.core.Path) DisabledProgressListener(ch.cyberduck.core.DisabledProgressListener) TestProtocol(ch.cyberduck.core.TestProtocol) LocalAttributes(ch.cyberduck.core.LocalAttributes) NullSession(ch.cyberduck.core.NullSession) Host(ch.cyberduck.core.Host) DownloadSymlinkResolver(ch.cyberduck.core.transfer.symlink.DownloadSymlinkResolver) DefaultComparePathFilter(ch.cyberduck.core.synchronization.DefaultComparePathFilter) NullLocal(ch.cyberduck.core.NullLocal) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) UploadSymlinkResolver(ch.cyberduck.core.transfer.symlink.UploadSymlinkResolver) OverwriteFilter(ch.cyberduck.core.transfer.download.OverwriteFilter) NullSession(ch.cyberduck.core.NullSession) Session(ch.cyberduck.core.Session) Test(org.junit.Test)

Example 3 with UploadSymlinkResolver

use of ch.cyberduck.core.transfer.symlink.UploadSymlinkResolver in project cyberduck by iterate-ch.

the class UploadTransfer method transfer.

@Override
public void transfer(final Session<?> source, final Session<?> destination, final Path file, final Local local, final TransferOptions options, final TransferStatus overall, final TransferStatus segment, final ConnectionCallback connectionCallback, final ProgressListener listener, final StreamListener streamListener) throws BackgroundException {
    if (log.isDebugEnabled()) {
        log.debug(String.format("Transfer file %s with options %s", file, options));
    }
    if (local.isSymbolicLink()) {
        final Symlink feature = source.getFeature(Symlink.class);
        final UploadSymlinkResolver symlinkResolver = new UploadSymlinkResolver(feature, roots);
        if (symlinkResolver.resolve(local)) {
            // Make relative symbolic link
            final String target = symlinkResolver.relativize(local.getAbsolute(), local.getSymlinkTarget().getAbsolute());
            if (log.isDebugEnabled()) {
                log.debug(String.format("Create symbolic link from %s to %s", file, target));
            }
            feature.symlink(file, target);
            return;
        }
    }
    if (file.isFile()) {
        listener.message(MessageFormat.format(LocaleFactory.localizedString("Uploading {0}", "Status"), file.getName()));
        // Transfer
        final Upload upload = source.getFeature(Upload.class);
        final Object reply = upload.upload(file, local, bandwidth, new UploadStreamListener(this, streamListener), segment, connectionCallback);
    } else if (file.isDirectory()) {
        if (!segment.isExists()) {
            listener.message(MessageFormat.format(LocaleFactory.localizedString("Making directory {0}", "Status"), file.getName()));
            final Directory feature = source.getFeature(Directory.class);
            final AttributedList<Path> list = new AttributedList<>(cache.get(file.getParent()));
            list.add(feature.mkdir(file, segment));
            cache.put(file.getParent(), list);
            segment.setComplete();
        }
    }
}
Also used : Symlink(ch.cyberduck.core.features.Symlink) Upload(ch.cyberduck.core.features.Upload) UploadSymlinkResolver(ch.cyberduck.core.transfer.symlink.UploadSymlinkResolver) Directory(ch.cyberduck.core.features.Directory)

Example 4 with UploadSymlinkResolver

use of ch.cyberduck.core.transfer.symlink.UploadSymlinkResolver in project cyberduck by iterate-ch.

the class UploadTransfer method filter.

@Override
public AbstractUploadFilter 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 and options %s", action, options));
    }
    final Symlink symlink = source.getFeature(Symlink.class);
    final UploadSymlinkResolver resolver = new UploadSymlinkResolver(symlink, roots);
    if (options.temporary) {
        options.withTemporary(source.getFeature(Write.class).temporary());
    }
    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)));
    if (action.equals(TransferAction.resume)) {
        return new ResumeFilter(resolver, source, options).withFinder(find).withAttributes(attributes);
    }
    if (action.equals(TransferAction.rename)) {
        return new RenameFilter(resolver, source, options).withFinder(find).withAttributes(attributes);
    }
    if (action.equals(TransferAction.renameexisting)) {
        return new RenameExistingFilter(resolver, source, options).withFinder(find).withAttributes(attributes);
    }
    if (action.equals(TransferAction.skip)) {
        return new SkipFilter(resolver, source, options).withFinder(find).withAttributes(attributes);
    }
    if (action.equals(TransferAction.comparison)) {
        return new CompareFilter(resolver, source, options, listener).withFinder(find).withAttributes(attributes);
    }
    return new OverwriteFilter(resolver, source, options).withFinder(find).withAttributes(attributes);
}
Also used : AttributesFinder(ch.cyberduck.core.features.AttributesFinder) ResumeFilter(ch.cyberduck.core.transfer.upload.ResumeFilter) Symlink(ch.cyberduck.core.features.Symlink) DefaultAttributesFinderFeature(ch.cyberduck.core.shared.DefaultAttributesFinderFeature) DefaultFindFeature(ch.cyberduck.core.shared.DefaultFindFeature) RenameFilter(ch.cyberduck.core.transfer.upload.RenameFilter) CompareFilter(ch.cyberduck.core.transfer.upload.CompareFilter) Find(ch.cyberduck.core.features.Find) SkipFilter(ch.cyberduck.core.transfer.upload.SkipFilter) UploadSymlinkResolver(ch.cyberduck.core.transfer.symlink.UploadSymlinkResolver) RenameExistingFilter(ch.cyberduck.core.transfer.upload.RenameExistingFilter) OverwriteFilter(ch.cyberduck.core.transfer.upload.OverwriteFilter)

Aggregations

UploadSymlinkResolver (ch.cyberduck.core.transfer.symlink.UploadSymlinkResolver)4 DisabledProgressListener (ch.cyberduck.core.DisabledProgressListener)2 Host (ch.cyberduck.core.Host)2 NullLocal (ch.cyberduck.core.NullLocal)2 NullSession (ch.cyberduck.core.NullSession)2 Path (ch.cyberduck.core.Path)2 Session (ch.cyberduck.core.Session)2 TestProtocol (ch.cyberduck.core.TestProtocol)2 Symlink (ch.cyberduck.core.features.Symlink)2 DefaultComparePathFilter (ch.cyberduck.core.synchronization.DefaultComparePathFilter)2 TransferStatus (ch.cyberduck.core.transfer.TransferStatus)2 OverwriteFilter (ch.cyberduck.core.transfer.download.OverwriteFilter)2 DownloadSymlinkResolver (ch.cyberduck.core.transfer.symlink.DownloadSymlinkResolver)2 Test (org.junit.Test)2 Local (ch.cyberduck.core.Local)1 LocalAttributes (ch.cyberduck.core.LocalAttributes)1 ProgressListener (ch.cyberduck.core.ProgressListener)1 AttributesFinder (ch.cyberduck.core.features.AttributesFinder)1 Directory (ch.cyberduck.core.features.Directory)1 Find (ch.cyberduck.core.features.Find)1