diff options
author | Thomas Tanner <trtanner@btinternet.com> | 2016-01-30 22:35:38 (GMT) |
---|---|---|
committer | Thomas Tanner <trtanner@btinternet.com> | 2016-01-30 22:35:38 (GMT) |
commit | a88dd02a03343dd0a0e17f6ad589148bf77d0493 (patch) | |
tree | 45b4fbf27d5f1f074ba8b343378303513784225c | |
parent | b7bf26899595e90e1cc6937fb18fd5702bec8d8d (diff) | |
download | SCons-a88dd02a03343dd0a0e17f6ad589148bf77d0493.zip SCons-a88dd02a03343dd0a0e17f6ad589148bf77d0493.tar.gz SCons-a88dd02a03343dd0a0e17f6ad589148bf77d0493.tar.bz2 |
Change the cache to use the first two characters of the md5 for the directory
name (more smaller directories, because they tend to get huge otherwise)
-rw-r--r-- | src/engine/SCons/CacheDir.py | 2 | ||||
-rw-r--r-- | src/engine/SCons/CacheDirTests.py | 2 | ||||
-rw-r--r-- | src/script/scons-rename-cachedirs.py | 62 |
3 files changed, 64 insertions, 2 deletions
diff --git a/src/engine/SCons/CacheDir.py b/src/engine/SCons/CacheDir.py index 3b7d06f..be0163d 100644 --- a/src/engine/SCons/CacheDir.py +++ b/src/engine/SCons/CacheDir.py @@ -164,7 +164,7 @@ class CacheDir(object): return None, None sig = node.get_cachedir_bsig() - subdir = sig[0].upper() + subdir = sig[:2].upper() dir = os.path.join(self.path, subdir) return dir, os.path.join(dir, sig) diff --git a/src/engine/SCons/CacheDirTests.py b/src/engine/SCons/CacheDirTests.py index 7ac97ef..3b99d41 100644 --- a/src/engine/SCons/CacheDirTests.py +++ b/src/engine/SCons/CacheDirTests.py @@ -100,7 +100,7 @@ class CacheDirTestCase(BaseTestCase): try: f5 = self.File("cd.f5", 'a_fake_bsig') result = self._CacheDir.cachepath(f5) - dirname = os.path.join('cache', 'A') + dirname = os.path.join('cache', 'A_') filename = os.path.join(dirname, 'a_fake_bsig') assert result == (dirname, filename), result finally: diff --git a/src/script/scons-rename-cachedirs.py b/src/script/scons-rename-cachedirs.py new file mode 100644 index 0000000..dd76a42 --- /dev/null +++ b/src/script/scons-rename-cachedirs.py @@ -0,0 +1,62 @@ +#! /usr/bin/env python
+#
+# SCons - a Software Constructor
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+__version__ = "__VERSION__"
+
+__build__ = "__BUILD__"
+
+__buildsys__ = "__BUILDSYS__"
+
+__date__ = "__DATE__"
+
+__developer__ = "__DEVELOPER__"
+
+import glob
+import os
+
+# The entire purpose of this script is to rename the files in the specified
+# cache directory from the 16 single hex digit directories to 256 2 hex digit
+# directories.
+
+# You run this in the cache directory.
+expected = ['{:X}'.format(x) for x in range(0, 16)]
+# check there are 16 directories, 0 - 9, A - F
+if sorted(glob.glob('*')) != [x]:
+ raise RuntimeError("This doesn't look like a cache directory")
+dirs = set()
+for file in glob.iglob(os.path.join('*', '*')):
+ name = os.path.basename(file)
+ dir = name[:2].upper()
+ print dir, name
+ if dir not in dirs:
+ os.mkdir(dir)
+ dirs.add(dir)
+ os.rename(file, os.path.join(dir, name))
+
+ # Now delete the original directories
+ for dir in expected:
+ os.rmdir(dir)
\ No newline at end of file |