# SHA-1 checksum portion of file path in gradle cache is missing leading zeros

**URL:** <https://discuss.gradle.org/t/sha-1-checksum-portion-of-file-path-in-gradle-cache-is-missing-leading-zeros/1244>\
**Category:** Old Forum Archive\
**Created:** [September 8, 2014, 6:56pm UTC](https://discuss.gradle.org/t/sha-1-checksum-portion-of-file-path-in-gradle-cache-is-missing-leading-zeros/1244 "2014-09-08T18:56:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rich\_Fromm](https://avatars.discourse-cdn.com/v4/letter/r/47e85d/32.png) [@Rich\_Fromm](https://discuss.gradle.org/u/Rich_Fromm)\
**Post date:** [September 8, 2014, 6:56pm UTC](https://discuss.gradle.org/t/sha-1-checksum-portion-of-file-path-in-gradle-cache-is-missing-leading-zeros/1244/1 "2014-09-08T18:56:00Z")

</div>

As a testcase (entire ‘build.gradle’ not included), I built something with a dependency on log4j 1.2.12:

```gradle
dependencies {
   runtime group: 'log4j', name: 'log4j', version: '1.2.12'
}

```

Note that while the SHA-1 checksum of this file is ‘057b8740427ee6d7b0b60792751356cad17dc0d9’ (40 characters, **with** leading zero), the directory that the file is placed in the cache is ‘57b8740427ee6d7b0b60792751356cad17dc0d9’ (39 characters, **without** leading zero):

```gradle
$ sha1sum /opt/gradle/rich/.gradle/caches/modules-2/files-2.1/log4j/log4j/1.2.12/57b8740427ee6d7b0b60792751356cad17dc0d9/log4j-1.2.12.jar
057b8740427ee6d7b0b60792751356cad17dc0d9
/opt/gradle/rich/.gradle/caches/modules-2/files-2.1/log4j/log4j/1.2.12/57b8740427ee6d7b0b60792751356cad17dc0d9/log4j-1.2.12.jar

```

I’m doing something with higher level custom tools that manage dependencies across hundreds of projects that assumes that that portion of the filename is the full 40 character hash, and this breaks that.

I know, a reasonable rebuttal to that is that this is an internal implementation detail, and it’s not part of any documented API, and that the storage on the filesystem could change at any time, and that I simply shouldn’t be doing that.

Nevertheless, I suspect that it is an oversight that the leading zero is lost in this case, and it would likely be a very trivial fix to add it. Compare to GRADLE-2456, in which the leading zero had been lost when publishing an artifact to Artifactory (observed in 1.1, fixed in 1.3-rc-1).

I first observed this in gradle 1.7, but I just tested it with the newly released gradle 2.1 (which is what is shown above), and it is still present.

---

<div class="post-metadata">

**Author:** ![Rene](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/rene/32/8082_2.png) [@Rene](https://discuss.gradle.org/u/Rene)\
**Post date:** [September 8, 2014, 7:17pm UTC](https://discuss.gradle.org/t/sha-1-checksum-portion-of-file-path-in-gradle-cache-is-missing-leading-zeros/1244/2 "2014-09-08T19:17:00Z")

</div>

Hey Rich,  
The file path in the gradle cache is not public api. That means it could change with every release. The fact that the sha1 checksum is part of the path is more or less an implementation detail. We are aware of the missing zeros. One reason to ignore these is the file path length limitation on windows we often see. Saving any character here can make a difference. Your best bet is to add the leading zeros yourself.&nbsp;  
  
cheers,  
René
