# understanding copy

**URL:** <https://forum.ansible.com/t/understanding-copy/11617>\
**Category:** Ansible Project\
**Created:** [June 15, 2012, 4:21pm UTC](https://forum.ansible.com/t/understanding-copy/11617 "2012-06-15T16:21:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nathan\_Feger](https://avatars.discourse-cdn.com/v4/letter/n/c0e974/32.png) [@Nathan\_Feger](https://forum.ansible.com/u/Nathan_Feger)\
**Post date:** [June 15, 2012, 4:21pm UTC](https://forum.ansible.com/t/understanding-copy/11617/1 "2012-06-15T16:21:42Z")

</div>

I’m looking at the copy module to get my head around trying to write my own module. Am I interpreting the code correctly when I say that copy always copys a file to the remote host, then runs md5sums on both files on the remote host, then overwrites the destination file if they do not match?

Thanks,  
Nathan

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [June 15, 2012, 4:54pm UTC](https://forum.ansible.com/t/understanding-copy/11617/2 "2012-06-15T16:54:00Z")

</div>

Yes. That’s what it does, but not what it should do. (Not a bug really, just the absence of an optimization that really ought to be there)

Presently, the “if does not match” stuff was originally done to support notifiers, not really to be efficient.

Patches to upgrade this are very welcome.

---

<div class="post-metadata">

**Author:** ![Nathan\_Feger](https://avatars.discourse-cdn.com/v4/letter/n/c0e974/32.png) [@Nathan\_Feger](https://forum.ansible.com/u/Nathan_Feger)\
**Post date:** [June 15, 2012, 7:02pm UTC](https://forum.ansible.com/t/understanding-copy/11617/3 "2012-06-15T19:02:16Z")

</div>

that’s good at least I’m on the right track. When does the file identified by src get copied to the remote machine? By when I really mean: Where in the code?

I found a cool little utility to do an md5sum without even fully loading a file, so I might be able to provide that patch once I get my head around this a bit more.

Nahtan
