-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace colons in transform cache filenames #8353
Changes from 3 commits
051c575
70067fb
6f47664
0737f6b
57dd825
8b9d171
944291c
af36665
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -94,6 +94,7 @@ export default class ScriptTransformer { | |
rootDir: this._config.rootDir, | ||
}), | ||
) | ||
.update(filename) | ||
.update(CACHE_VERSION) | ||
.digest('hex'); | ||
} else { | ||
|
@@ -102,6 +103,7 @@ export default class ScriptTransformer { | |
.update(fileData) | ||
.update(configString) | ||
.update(instrument ? 'instrument' : '') | ||
.update(filename) | ||
.update(CACHE_VERSION) | ||
.digest('hex'); | ||
} | ||
|
@@ -121,11 +123,11 @@ export default class ScriptTransformer { | |
// Create sub folders based on the cacheKey to avoid creating one | ||
// directory with many files. | ||
const cacheDir = path.join(baseCacheDir, cacheKey[0] + cacheKey[1]); | ||
const cacheFilenamePrefix = path | ||
.basename(filename, path.extname(filename)) | ||
.replace(/:/g, '_COLON_'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is colon really the only character that might cause issues here? Especially when you consider it's possible for a cache to be created on one system and then be used on another (this is what we do at Facebook and I'm sure it's not totally unique). Stepping back a second, the extension being added to the file seems odd to me in the first place. With your @SimenB let me know if you have any thoughts but here is my recommended course of action:
That should resolve the core issue and other similar issues we don't know about yet. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is obviously no technical necessity to have the prefix because it's already in the hash (and stripping away most of the path would make it useless for collision avoidance anyway), but I would guess it's there to make debugging / working on cache related things easier? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, good point. I'm still in favor of killing it if it's causing issues. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the filename prefix is helpful with debugging cache related things, how about we prefix with just the alphanumeric characters from the filename? That should solve any issues across systems but retain the human friendly context There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @scotthovestadt you fine with this too? I think it's a good way to handle it |
||
const cachePath = slash( | ||
path.join( | ||
cacheDir, | ||
path.basename(filename, path.extname(filename)) + '_' + cacheKey, | ||
), | ||
path.join(cacheDir, cacheFilenamePrefix + '_' + cacheKey), | ||
); | ||
createDirectory(cacheDir); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't necessary because
getCacheKey
includes thefilename
already.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I thought so as well, my comment was only to seek confirmation ^^