]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
changed to a 3 level directory hash
authorAndrew Tridgell <tridge@samba.org>
Tue, 2 Apr 2002 05:04:49 +0000 (07:04 +0200)
committerAndrew Tridgell <tridge@samba.org>
Tue, 2 Apr 2002 05:04:49 +0000 (07:04 +0200)
ccache.c

index 900a3f4b215f5b995532e784f686557f3e1c61b0..c278ed70f5f5aa631d6977207dfb8b46fcbbec70 100644 (file)
--- a/ccache.c
+++ b/ccache.c
@@ -115,6 +115,7 @@ static void find_hash(ARGS *args)
 {
        int i;
        char *path_stdout, *path_stderr;
+       char *hash_dir1;
        char *hash_dir;
        char *s;
        struct stat st;
@@ -195,17 +196,23 @@ static void find_hash(ARGS *args)
        free(path_stdout);
        free(path_stderr);
 
-       /* we use a single level subdir for the cache path to reduce the impact
+       /* we use a 2 level subdir for the cache path to reduce the impact
           on filesystems which are slow for large directories
        */
        s = hash_result();
-       x_asprintf(&hash_dir, "%s/%c", cache_dir, *s);
+       x_asprintf(&hash_dir1, "%s/%c", cache_dir, s[0]);
+       x_asprintf(&stats_file, "%s/stats", hash_dir1);
+       if (create_dir(hash_dir1) != 0) {
+               cc_log("failed to create %s\n", hash_dir1);
+               failed();
+       }
+       x_asprintf(&hash_dir, "%s/%c", hash_dir1, s[1]);
+       free(hash_dir1);
        if (create_dir(hash_dir) != 0) {
-               cc_log("failed to create %s\n", cache_dir);
+               cc_log("failed to create %s\n", hash_dir);
                failed();
        }
-       x_asprintf(&hashname, "%s/%s", hash_dir, s+1);
-       x_asprintf(&stats_file, "%s/stats", hash_dir);
+       x_asprintf(&hashname, "%s/%s", hash_dir, s+2);
        free(hash_dir);
 }