Provide a preference SFTPFileTransfer.setPreserveAttributes() to not set file attributes post upload or download.

Should address issue #42 / pull request #43
This commit is contained in:
Shikhar Bhushan
2012-05-12 16:24:01 +01:00
parent e4d3a1f866
commit 540708e540

View File

@@ -38,11 +38,20 @@ public class SFTPFileTransfer
private volatile LocalFileFilter uploadFilter;
private volatile RemoteResourceFilter downloadFilter;
private volatile boolean preserveAttributes = true;
public SFTPFileTransfer(SFTPEngine engine) {
this.engine = engine;
}
public boolean getPreserveAttributes() {
return preserveAttributes;
}
public void setPreserveAttributes(boolean preserveAttributes) {
this.preserveAttributes = preserveAttributes;
}
@Override
public void upload(String source, String dest)
throws IOException {
@@ -106,8 +115,8 @@ public class SFTPFileTransfer
default:
throw new IOException(remote + " is not a regular file or directory");
}
if (getPreserveAttributes())
copyAttributes(remote, adjustedFile);
}
private LocalDestFile downloadDir(final TransferListener listener,
@@ -173,6 +182,7 @@ public class SFTPFileTransfer
adjustedPath = uploadFile(listener.file(local.getName(), local.getLength()), local, remote);
} else
throw new IOException(local + " is not a file or directory");
if (getPreserveAttributes())
engine.setAttributes(adjustedPath, getAttributes(local));
}