Commit c27e26f
committed
docker cp: report both content size and transferred size
When copying files to a container, the `docker cp` command would print
a message reporting the size of files copied. However, this size was
based on the size of the TAR stream sent, which includes the size of
the TAR headers.
docker container create --name my-container busybox
touch empty-file
docker cp empty-file my-container:/empty-file
Successfully copied 1.54kB to my-container:/empty-file
This patch adds a `calcTARContentSize` utility, which uses the
TAR headers to calculate the size of files included.
With this patch applied, the content size is reported, instead
of the size of the TAR stream used for transport;
docker container create --name my-container busybox
touch empty-file
docker cp empty-file my-container:/empty-file
Successfully copied 0B (transferred 1.54kB) to my-container:/empty-file
mkdir empty-dir
docker cp ./empty-dir my-container:/somewhere/
Successfully copied 0B (transferred 1.54kB) to my-container:/somewhere/
docker cp ./cli/command my-container:/files/
Successfully copied 2.01MB (transferred 2.53MB) to my-container:/files/
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>1 parent 7b93d61 commit c27e26f
1 file changed
+55
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
354 | 355 | | |
355 | 356 | | |
356 | 357 | | |
| 358 | + | |
357 | 359 | | |
358 | 360 | | |
359 | 361 | | |
| |||
387 | 389 | | |
388 | 390 | | |
389 | 391 | | |
390 | | - | |
| 392 | + | |
391 | 393 | | |
392 | 394 | | |
393 | 395 | | |
| 396 | + | |
394 | 397 | | |
395 | 398 | | |
396 | 399 | | |
| |||
421 | 424 | | |
422 | 425 | | |
423 | 426 | | |
424 | | - | |
425 | | - | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
426 | 430 | | |
427 | 431 | | |
428 | 432 | | |
| |||
469 | 473 | | |
470 | 474 | | |
471 | 475 | | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
0 commit comments