@Override
public Path move(final Path file, final Path renamed, TransferStatus status, final Delete.Callback callback, final ConnectionCallback connectionCallback) throws BackgroundException {
try {
if(status.isExists()) {
delete.delete(Collections.singletonList(renamed), connectionCallback, callback);
}
session.sftp().rename(file.getAbsolute(), renamed.getAbsolute());
return new Path(renamed.getParent(), renamed.getName(), renamed.getType(), new PathAttributes(file.attributes()));
}
catch(IOException e) {
throw new SFTPExceptionMappingService().map("Cannot rename {0}", e, file);
}
}