file.copy: be smart with file changes

On 28/07/2014 19:17, C. R. Oldham wrote:
>
> In salt/states/file.py:
>
> > @@ -3314,11 +3315,14 @@ def copy(name, source, force=False, makedirs=False):
> >          return _error(ret, 'Source file "{0}" is not present'.format(source))
> >  
> >      if os.path.lexists(source) and os.path.lexists(name):
> > +        # if this is a file which did not changed, do not update
> > +        if force and os.path.isfile(name):
> > +            hash1 = salt.utils.get_hash(name)
> > +            hash2 = salt.utils.get_hash(source)
> > +            if hash2 != hash1:
>
> The way I read lines 3322 and 3323 is "If the hashes don't match then set
> 'changed' to False". Intuitively I would think that if the hashes don't match
> then the files have been changed, so changed should be 'True'?
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/saltstack/salt/pull/14539/files#r15475940>.
>
no, if even force is activated but the file are the same, we dont copy as it is
a noop and can take several hours for example on large files on an NFS share.

-- 
Cordialement,
kiorky
GPG Key FingerPrint: 0x1A1194B7681112AF
Pensez à l’environnement. 
N’imprimez ce courriel que si vous en avez vraiment besoin.