diff options
| author | Steven Knight <knight@baldmt.com> | 2003-03-15 13:58:13 (GMT) |
|---|---|---|
| committer | Steven Knight <knight@baldmt.com> | 2003-03-15 13:58:13 (GMT) |
| commit | 5ea9b7416ae70c3a4678bcf337bebd41b944cf86 (patch) | |
| tree | c1410150f79bcdfef458091d9769f64174ed5a26 /src/engine/SCons/Node/FS.py | |
| parent | 127d61ac6d0a272bf82cbcaf5923b4ddd302ec7e (diff) | |
| download | SCons-5ea9b7416ae70c3a4678bcf337bebd41b944cf86.zip SCons-5ea9b7416ae70c3a4678bcf337bebd41b944cf86.tar.gz SCons-5ea9b7416ae70c3a4678bcf337bebd41b944cf86.tar.bz2 | |
Fix two bugs in CacheDir handling. (Jeff Petkau)
Diffstat (limited to 'src/engine/SCons/Node/FS.py')
| -rw-r--r-- | src/engine/SCons/Node/FS.py | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py index b0bc3e4..e5182cd 100644 --- a/src/engine/SCons/Node/FS.py +++ b/src/engine/SCons/Node/FS.py @@ -130,11 +130,27 @@ CacheRetrieveSilent = SCons.Action.Action(CacheRetrieveFunc, None) def CachePushFunc(target, source, env): t = target[0] cachedir, cachefile = t.cachepath() + if os.path.exists(cachefile): + # Don't bother copying it if it's already there. + return + if not os.path.isdir(cachedir): os.mkdir(cachedir) - shutil.copy2(t.path, cachefile) - st = os.stat(t.path) - os.chmod(cachefile, stat.S_IMODE(st[stat.ST_MODE]) | stat.S_IWRITE) + + tempfile = cachefile+'.tmp' + try: + shutil.copy2(t.path, tempfile) + os.rename(tempfile, cachefile) + st = os.stat(t.path) + os.chmod(cachefile, stat.S_IMODE(st[stat.ST_MODE]) | stat.S_IWRITE) + except OSError: + # It's possible someone else tried writing the file at the same + # time we did. Print a warning but don't stop the build, since + # it doesn't affect the correctness of the build. + SCons.Warnings.warn(SCons.Warnings.CacheWriteErrorWarning, + "Unable to copy %s to cache. Cache file is %s" + % (str(target), cachefile)) + return CachePush = SCons.Action.Action(CachePushFunc, None) |
