add another check for understand if the source and destination are the same during a copy operation
This commit is contained in:
parent
83bb788057
commit
e7cd080da7
|
@ -86,6 +86,7 @@ public class SoftCopyOperator extends SoftCopy {
|
||||||
// if it contains a link field, then I'm going to retrieve the related payload
|
// if it contains a link field, then I'm going to retrieve the related payload
|
||||||
sourceObject = mongoPrimaryInstance.retrieveLinkPayload(sourceObject);
|
sourceObject = mongoPrimaryInstance.retrieveLinkPayload(sourceObject);
|
||||||
ObjectId sourceId=(ObjectId)sourceObject.getId();
|
ObjectId sourceId=(ObjectId)sourceObject.getId();
|
||||||
|
logger.debug("source id is "+sourceId);
|
||||||
InputStream is= sourceObject.getInputStream();
|
InputStream is= sourceObject.getInputStream();
|
||||||
resource.setInputStream(is);
|
resource.setInputStream(is);
|
||||||
GridFSDBFile dest = null;
|
GridFSDBFile dest = null;
|
||||||
|
@ -104,11 +105,16 @@ public class SoftCopyOperator extends SoftCopy {
|
||||||
ObjectId removedId=null;
|
ObjectId removedId=null;
|
||||||
// if the destination location is not empty
|
// if the destination location is not empty
|
||||||
if (dest != null){
|
if (dest != null){
|
||||||
|
String destId=dest.getId().toString();
|
||||||
|
logger.debug("destination id is "+sourceId);
|
||||||
|
// in this case the source and dest are the same object
|
||||||
|
if(sourceId.equals(destId))
|
||||||
|
return destId;
|
||||||
// remove the destination file. The third parameter to true replace the file otherwise the remote id is returned
|
// remove the destination file. The third parameter to true replace the file otherwise the remote id is returned
|
||||||
if(resource.isReplace()){
|
if(resource.isReplace()){
|
||||||
removedId = mongoPrimaryInstance.removeFile(resource, null, resource.isReplace(), null, dest);
|
removedId = mongoPrimaryInstance.removeFile(resource, null, resource.isReplace(), null, dest);
|
||||||
}else{
|
}else{
|
||||||
return dest.getId().toString();
|
return destId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// get metacollection instance
|
// get metacollection instance
|
||||||
|
|
Loading…
Reference in New Issue