mirror of
https://github.com/hierynomus/sshj.git
synced 2025-12-06 15:20:54 +03:00
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:
@@ -38,11 +38,20 @@ public class SFTPFileTransfer
|
|||||||
|
|
||||||
private volatile LocalFileFilter uploadFilter;
|
private volatile LocalFileFilter uploadFilter;
|
||||||
private volatile RemoteResourceFilter downloadFilter;
|
private volatile RemoteResourceFilter downloadFilter;
|
||||||
|
private volatile boolean preserveAttributes = true;
|
||||||
|
|
||||||
public SFTPFileTransfer(SFTPEngine engine) {
|
public SFTPFileTransfer(SFTPEngine engine) {
|
||||||
this.engine = engine;
|
this.engine = engine;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getPreserveAttributes() {
|
||||||
|
return preserveAttributes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPreserveAttributes(boolean preserveAttributes) {
|
||||||
|
this.preserveAttributes = preserveAttributes;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void upload(String source, String dest)
|
public void upload(String source, String dest)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
@@ -106,8 +115,8 @@ public class SFTPFileTransfer
|
|||||||
default:
|
default:
|
||||||
throw new IOException(remote + " is not a regular file or directory");
|
throw new IOException(remote + " is not a regular file or directory");
|
||||||
}
|
}
|
||||||
copyAttributes(remote, adjustedFile);
|
if (getPreserveAttributes())
|
||||||
|
copyAttributes(remote, adjustedFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
private LocalDestFile downloadDir(final TransferListener listener,
|
private LocalDestFile downloadDir(final TransferListener listener,
|
||||||
@@ -173,7 +182,8 @@ public class SFTPFileTransfer
|
|||||||
adjustedPath = uploadFile(listener.file(local.getName(), local.getLength()), local, remote);
|
adjustedPath = uploadFile(listener.file(local.getName(), local.getLength()), local, remote);
|
||||||
} else
|
} else
|
||||||
throw new IOException(local + " is not a file or directory");
|
throw new IOException(local + " is not a file or directory");
|
||||||
engine.setAttributes(adjustedPath, getAttributes(local));
|
if (getPreserveAttributes())
|
||||||
|
engine.setAttributes(adjustedPath, getAttributes(local));
|
||||||
}
|
}
|
||||||
|
|
||||||
private String uploadDir(final TransferListener listener,
|
private String uploadDir(final TransferListener listener,
|
||||||
|
|||||||
Reference in New Issue
Block a user