putArchive method

  1. @override
Future<void> putArchive(
  1. String id,
  2. String path,
  3. List<int> tarBytes
)
override

Writes tarBytes — a ustar archive — into the container, at path.

path must already exist inside the container as a directory: that is Docker's own rule for PUT /containers/{id}/archive, not something rig adds. Throws CopyDestinationNotFound when it does not.

Implementation

@override
Future<void> putArchive(String id, String path, List<int> tarBytes) async {
  calls.add('putArchive:$id:$path');
  final c = _require(id);
  final dir = p.posix.normalize(path);
  if (!c.directories.contains(dir)) {
    throw CopyDestinationNotFound(containerId: id, directory: path);
  }
  for (final entry in readTarEntries(Uint8List.fromList(tarBytes))) {
    final full = p.posix.normalize(p.posix.join(dir, entry.name));
    if (entry.isDirectory) {
      c.directories.add(full);
    } else {
      c.files[full] = entry.content;
    }
  }
}