copy method

Future<bool> copy(
  1. String from,
  2. String to,
  3. String hash, {
  4. bool executable = false,
})

Asks the node to copy from to to under the served root, reusing the node-side bytes — but only when from still hashes to hash.

Returns true when the node verified and copied; false when from drifted or vanished, in which case the caller falls back to a byte transfer. A false outcome is a normal reply, not an error.

Implementation

Future<bool> copy(
  String from,
  String to,
  String hash, {
  bool executable = false,
}) async {
  final reply = await _call(
    DriveOp.copy,
    fields: {
      'from': from,
      'to': to,
      'hash': hash,
      if (executable) kDriveExecutable: true,
    },
  );
  return reply.header['copied'] == true;
}