IBDecodable / IBLinter

A linter tool for Interface Builder
MIT License
948 stars 42 forks source link

Broken caching system #156

Closed shuguenot closed 4 years ago

shuguenot commented 4 years ago

Depending of the generated hash used for storing cache on disk, an error may occur .

Error Domain=NSCocoaErrorDomain Code=4 "The file “wba57NyfgQqd1OIToLN0OA+c0=” doesn’t exist." UserInfo={NSFilePath=/Users/xxxxxxxx/Library/Caches/IBLinter/0.4.22/7/wba57NyfgQqd1OIToLN0OA+c0=, NSUnderlyingError=0x1069e3020 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}} Program ended with exit code: 0

In the example above, the generated base64 hash is "7/wba57NyfgQqd1OIToLN0OA+c0=", it contains "/" character (which is a valid base 64 encoding character). But it breaks the LintDiskCache.save() when trying to execute "contentData.write(to: cacheFilePath)".

As a workaround i rewrote these lines on LintDiskCache.new() and LintDiskCache.load() :

let hashKey = Data(configContent.sha1()).base64EncodedString() to let hashKey = Data(configContent.sha1()).base64EncodedString().replacingOccurrences(of: "/", with: "_")

kateinoigakukun commented 4 years ago

Thanks for your report. It seems a reasonable workaround. Could you make a PR for the change?