Make testing more generic.
[lgpl/argeo-commons.git] / org.argeo.core / src / org / argeo / sync / fs / PathSync.java
index 99d5de81fb23da18fe679a1cfaa9251bef4c2891..151194da6bbcb140793ff788ee71ac79b40784c3 100644 (file)
@@ -6,19 +6,15 @@ import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.nio.file.spi.FileSystemProvider;
-import java.time.ZonedDateTime;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 import org.argeo.jackrabbit.fs.DavexFsProvider;
 import org.argeo.ssh.Sftp;
 import org.argeo.sync.SyncException;
-import org.argeo.util.LangUtils;
 
+/** Synchronises two paths. */
 public class PathSync implements Runnable {
-       private final static Log log = LogFactory.getLog(PathSync.class);
-
        private final URI sourceUri, targetUri;
+       private boolean delete = false;
 
        public PathSync(URI sourceUri, URI targetUri) {
                this.sourceUri = sourceUri;
@@ -30,11 +26,8 @@ public class PathSync implements Runnable {
                try {
                        Path sourceBasePath = createPath(sourceUri);
                        Path targetBasePath = createPath(targetUri);
-                       SyncFileVisitor syncFileVisitor = new SyncFileVisitor(sourceBasePath, targetBasePath);
-                       ZonedDateTime begin = ZonedDateTime.now();
+                       SyncFileVisitor syncFileVisitor = new SyncFileVisitor(sourceBasePath, targetBasePath, delete);
                        Files.walkFileTree(sourceBasePath, syncFileVisitor);
-                       if (log.isDebugEnabled())
-                               log.debug("Sync from " + sourceBasePath + " to " + targetBasePath + " took " + LangUtils.since(begin));
                } catch (Exception e) {
                        e.printStackTrace();
                }
@@ -57,8 +50,4 @@ public class PathSync implements Runnable {
                        throw new SyncException("URI scheme not supported for " + uri);
                return path;
        }
-
-       static enum Arg {
-               to, from;
-       }
 }