-
Notifications
You must be signed in to change notification settings - Fork 791
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[close #96] Remove all absolute paths from cache
Targeted at sprockets 4.x The patch in #92 was incomplete, it converted all cache keys to use relative paths, but didn't fully remove all absolute paths from cache contents. The test case was accidentally passing since we didn't check to make sure any of the paths from cache were different from the original ones stored. This patch eliminates these absolute paths stored in the cache: - [x] dependency paths - [x] filename - [x] asset uris - [x] "included" paths (no idea what these are) - [x] load paths This patch works by introducing a utility class URITar which can "compress" or "expand" a given uri. A "compressed" uri can either be one that is relative to the root, or an absolute path if it is outside of the root. An expanded uri will always be an absolute path. A uri that is relative to the root will be compressed with no beginning slash file://relative/to/root/file.js A uri that is outside of the root will be compressed with a beginning slash file:///absolute/path/to/file.js Even though I'm using "uri" here the URITar class can also operate on file paths without a valid URI scheme name. Like: relative/to/root/file.js and /absolute/path/to/file.js The UnloadedAsset class was moved to it's own file and refactored to use the new URITar class. Before putting anything in the cache, we will "compress" all uris and paths so that no absolute paths are in the cache (unless they're not relative to the root which would indicate they're somewhere global e.g. from a gem or shared directory). Upon loading an asset in memory, we "expand" all uris since sprockets relies on absolute paths for just about everything. Almost all the business logic is limited to the loader, so the rest of sprockets has no clue if relative or absolute paths were used to build the asset. We are also compressing the "environment-paths" so that dependencies in different paths will differ. I think this is needed, but the tests don't fail when it's taken out. ATP
- Loading branch information
Showing
6 changed files
with
320 additions
and
173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
436e2d6
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.
👓 📖