Skip to content

Commit

Permalink
#31 working on get consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-conway committed Jul 17, 2014
1 parent 8699360 commit b90ec4a
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1824,22 +1824,27 @@ private void processCopyWhenSourceIsDir(
preCountIrodsFilesBeforeTransfer(sourceFile.getAbsolutePath(),
operativeTransferControlBlock);

// The source directory becomes the new target subdirectory
/*
* Don't copy to self
*/
if (targetFile.getAbsolutePath().equals(sourceFile.getParent())) {
log.error("source file is being copied to own parent:{}",
sourceFile.getAbsolutePath());
throw new DuplicateDataException(
"attempt to copy source file to its parent");
}

// if the target is a file, use the parent
// if the target is a file throw an exception
if (targetFile.exists() && targetFile.isFile()) {
targetFile = (IRODSFile) targetFile.getParentFile();
log.info("target of copy is a file, path switched to parent: {}",
log.error("attempt to copy a directory to a file: {}",
targetFile.getAbsolutePath());
throw new JargonException("attempt to copy a directory to a file");
}

// here I know the source file is a collection
// The source directory contents are copied under the target contents

targetFile = getIRODSFileFactory().instanceIRODSFile(
targetFile.getAbsolutePath(), sourceFile.getName());

Expand Down

0 comments on commit b90ec4a

Please sign in to comment.