This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: copy 2
Type: Stage:
Components: Library (Lib) Versions: Python 2.5
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: amaury.forgeotdarc, georg.brandl, robpy1
Priority: normal Keywords:

Created on 2007-07-30 21:30 by robpy1, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (4)
msg32570 - (view) Author: robs pythonid (robpy1) Date: 2007-07-30 21:30
I am having problems with the shutil.copy2

I am making a backup program but when I use copy2 the time of my destination file is often two seconds newer than my source file. I was immediately aware that (as in previous bugs) the decimals are always incorrect (so I always use int(os.path.getmtime(source)) but i also see that the seconds are one or two of. It happens in about 10% of the files copied.

example of my trace of the check after the copy2 call "shutil.copy2(src,trg)"
rereading the mtime gives a difference of one second where the target is 1 second newer.

23:13:50 Non Copied: d:\MyPython\archief.txt , f:\PythonBackup\d-drive\MyPython\archief.txt (1177881701 == 1177881702) N

hard to believe? I also used os.utime(trg,(t,t)) to try to correct it but it gives the same error

Anybody have the same experience... and how to solve this, just installed python 2.5.1, no help.....
msg55175 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2007-08-23 18:20
Which "time" is that? Windows three timestamps, IIRC: creation,
modification, access.
msg55732 - (view) Author: robs pythonid (robpy1) Date: 2007-09-07 07:34
Thanks for your reaction, I do not really now the answer to your 
question but I added the code to copy files in a directory (to keep it 
simple I removed the recursiveness):

import os
import shutil


for afile in filelist:
    source=sourcedir + "\\" + afile
    if os.path.isfile(source):
        print source,time1,
        if os.path.isfile(target):
            if time1>time2:
        if docopy==1:
            print " ....copying"
            print " not copied"

If I run this program twice without changing any file in the source 
directory it should not copy any files anymore (but is does 20% of the 
files it there are 100000 files). Now that I have been thinking about 
this a little the problems I see, happen on a Windows Vista Business 
machine, on my XP machine i don't seem to be able to reproduce the 
issues, maybe it is somethin in Vista.....

quite frustrating....
msg90884 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2009-07-24 14:32
The "f": drive probably was a FAT32 filesystem, which has a resolution
of two seconds...
Date User Action Args
2022-04-11 14:56:25adminsetgithub: 45256
2009-07-24 14:32:01amaury.forgeotdarcsetstatus: open -> closed

nosy: + amaury.forgeotdarc
messages: + msg90884

resolution: not a bug
2007-09-07 07:34:15robpy1setmessages: + msg55732
2007-08-23 18:20:09georg.brandlsetnosy: + georg.brandl
messages: + msg55175
2007-07-30 21:30:50robpy1create