-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
enhancements to transfer operations for add'l checking and path handling. #31
Comments
on copy of dir to file now throws an exception.. testing with icptarget existsicp -r source target icp -r source/. target target not existsicp -r source target gives /target/blah icp -r source/. target |
testing with cp(newdir has file1.txt and file2.txt) target exists(newdir has file1.txt and file2.txt) cp -r newdir newtarget cp -r newdir/. newtarget target not exists.. same behavior |
hao testing on ubuntu is consistent between cp and irods icp |
see as Rion's reference @Override
public void get(String remotedir, String localdir, RemoteTransferListener listener)
throws IOException, RemoteDataException
{
try
{
IRODSFile irodsFile = getFile(remotedir);
if (listener == null) {
listener = new RemoteTransferListener(null);
}
if (irodsFile.exists())
{
File localDir = new File(localdir);
if (irodsFile.isDirectory())
{
if (!localDir.exists())
{
if (!localDir.getParentFile().exists()) {
throw new java.io.FileNotFoundException("No such file or directory");
} else {
// create the target directory
if (!localDir.mkdir()) {
throw new IOException("Failed to create local download directory");
}
}
// recursively copy files into the local folder since irods won't let you specify
// the target folder name
List<CollectionAndDataObjectListingEntry> entries =
geCollectionAndDataObjectListAndSearchAO().listDataObjectsAndCollectionsUnderPath(resolvePath(remotedir));
for (CollectionAndDataObjectListingEntry entry : entries)
{
getDataTransferOperations().getOperation(irodsFile.getAbsolutePath() + "/" + entry.getNodeLabelDisplayValue(),
localDir.getAbsolutePath() + File.separator + entry.getNodeLabelDisplayValue(), resource, listener, null);
TransferStatus statusCallback = listener.getOverallStatusCallback();
if (statusCallback != null && statusCallback.getTransferException() != null) {
throw statusCallback.getTransferException();
}
}
}
else
{
getDataTransferOperations().getOperation(irodsFile,
localDir, listener, null);
TransferStatus statusCallback = listener.getOverallStatusCallback();
if (statusCallback != null && statusCallback.getTransferException() != null) {
throw statusCallback.getTransferException();
}
}
}
else
{
getDataTransferOperations().getOperation(irodsFile,
localDir, listener, null);
TransferStatus statusCallback = listener.getOverallStatusCallback();
if (statusCallback != null && statusCallback.getTransferException() != null) {
throw statusCallback.getTransferException();
}
}
}
else
{
throw new java.io.FileNotFoundException("No such file or directory");
}
}
catch (FileNotFoundException e) {
throw new java.io.FileNotFoundException("No such file or directory");
}
catch (CatNoAccessException e) {
throw new RemoteDataException("Failed to get " + remotedir + " due to insufficient privileges.", e);
}
catch (DataNotFoundException e) {
throw new java.io.FileNotFoundException("No such file or directory");
}
catch (IOException e) {
throw e;
}
catch (JargonException e) {
throw new RemoteDataException("Failed to get file from irods.", e);
}
catch (RemoteDataException e) {
throw e;
}
catch (Exception e) {
throw new RemoteDataException("Failed to copy file to irods.", e);
}
}
|
Useful integration of io utils for path normalization worth considering. |
added dir create and folder permission checks to get and put code |
Also, I DataTransferOperations.getOperation behaves a bit oddly. If I ask it to get a collection, it will not let me name the resulting directory. Say I make cal call to copy /demo/home/dooley/somefolder to /Users/dooley/deleteme. If the local folder exists, some folder will be copied into it. If it does not, it will be created and some folder copied in. That’s the opposite of what I’d expect on a posix file system and forces me to manually check the local path, create the target directory, list the remote path, and copy each collection or data object individually to the new target directory. All of that after I have to manually check permissions manually so I can pass back valid error messages to my users.
Here is the behavior of scp:
dooley$ scp -r docker:deleteme . dooley$ ls deleteme dooley$ scp -r docker:deleteme deleteme dooley$ ls deleteme deleteme dooley$ scp -r docker:deleteme samefoldernewname dooley$ ls deleteme samefoldernewname
example handler in pseudocode
The text was updated successfully, but these errors were encountered: