Skip to content

Conversation

@wan-hellopupil
Copy link
Contributor

I've hit an issue where I wanted my express server to return the new paths of javascript/css assets on livereload (for example, first load /main.df75ab9.js, after livereload /main.db7a554.js).

However for now staticify will keep the original hashes in its cache for a filename, even after the file changes and the use of staticify.refresh(), thus preventing getVersionedPath from returning the new shortHash for a filename.

This PR makes sure that we clear the memoized cache of filename-to-hashes in refresh(), so that files that have changed and have new hashes can have their new shortHash-paths returned by getVersionedPath.

@XhmikosR
Copy link
Collaborator

Thanks for the PR. Can you add a test for refresh(), please?

@wan-hellopupil
Copy link
Contributor Author

I couldn't find a way to access the content of the memoized hash cache programmatically in the test, so I create/modify a file under /test to be able to observe a new versioned path and compare it to one generated before a refresh() call.

@XhmikosR
Copy link
Collaborator

XhmikosR commented Mar 25, 2019 via email

@wan-hellopupil
Copy link
Contributor Author

wan-hellopupil commented Mar 25, 2019

I've changed the test to use async filesystem function. Like this?

@XhmikosR
Copy link
Collaborator

I'd say just revert the last patch for now, because we have nested callbacks.

Maybe with async/await later someone we'll tackle all of those including core :)

@wan-hellopupil
Copy link
Contributor Author

Hi, do you need me to do anything else in that PR, or should I just wait for whenever you have some free time to check & review it?

@XhmikosR
Copy link
Collaborator

XhmikosR commented Apr 2, 2019

Oh, sorry, I wasn't notified about your last force push. I will try to have a look in the next days.


const staticifyObj = staticify(ROOT);
const versionedPath = staticifyObj.getVersionedPath('/test/variable_file.txt');
const versioned = versionedPath.split('.');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason you are splitting this here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No particular reason expect for the fact that I copied it from the .getVersionedPath test.

@XhmikosR XhmikosR merged commit 99f2aa3 into errorception:master Apr 3, 2019
@XhmikosR
Copy link
Collaborator

XhmikosR commented Apr 3, 2019

Thanks! I'm gonna release this later today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants