X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=org.argeo.core%2Fsrc%2Forg%2Fargeo%2Fcli%2Ffs%2FPathSync.java;fp=org.argeo.core%2Fsrc%2Forg%2Fargeo%2Fcli%2Ffs%2FPathSync.java;h=0000000000000000000000000000000000000000;hb=03f646fd0d7e7ce393694c836c779bc67a4eef55;hp=9ab9cafad72db38d14022f0f352def5f4c314dfb;hpb=c53fec78daddb69c489686844188036b04e1615a;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.core/src/org/argeo/cli/fs/PathSync.java b/org.argeo.core/src/org/argeo/cli/fs/PathSync.java deleted file mode 100644 index 9ab9cafad..000000000 --- a/org.argeo.core/src/org/argeo/cli/fs/PathSync.java +++ /dev/null @@ -1,61 +0,0 @@ -package org.argeo.cli.fs; - -import java.net.URI; -import java.nio.file.FileSystems; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.nio.file.spi.FileSystemProvider; -import java.util.concurrent.Callable; - -import org.argeo.sync.SyncResult; - -/** Synchronises two paths. */ -public class PathSync implements Callable> { - private final URI sourceUri, targetUri; - private final boolean delete; - private final boolean recursive; - - public PathSync(URI sourceUri, URI targetUri) { - this(sourceUri, targetUri, false, false); - } - - public PathSync(URI sourceUri, URI targetUri, boolean delete, boolean recursive) { - this.sourceUri = sourceUri; - this.targetUri = targetUri; - this.delete = delete; - this.recursive = recursive; - } - - @Override - public SyncResult call() { - try { - Path sourceBasePath = createPath(sourceUri); - Path targetBasePath = createPath(targetUri); - SyncFileVisitor syncFileVisitor = new SyncFileVisitor(sourceBasePath, targetBasePath, delete, recursive); - Files.walkFileTree(sourceBasePath, syncFileVisitor); - return syncFileVisitor.getSyncResult(); - } catch (Exception e) { - throw new IllegalStateException("Cannot sync " + sourceUri + " to " + targetUri, e); - } - } - - private Path createPath(URI uri) { - Path path; - if (uri.getScheme() == null) { - path = Paths.get(uri.getPath()); - } else if (uri.getScheme().equals("file")) { - FileSystemProvider fsProvider = FileSystems.getDefault().provider(); - path = fsProvider.getPath(uri); - } else if (uri.getScheme().equals("davex")) { - throw new UnsupportedOperationException(); -// FileSystemProvider fsProvider = new DavexFsProvider(); -// path = fsProvider.getPath(uri); -// } else if (uri.getScheme().equals("sftp")) { -// Sftp sftp = new Sftp(uri); -// path = sftp.getBasePath(); - } else - throw new IllegalArgumentException("URI scheme not supported for " + uri); - return path; - } -}