Skip to content
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

fix cache directory not writable (#327) #338

Closed
wants to merge 1 commit into from

Conversation

frontsideair
Copy link

Please Read the CONTRIBUTING Guidelines
In particular the portion on Commit Message Formatting

Please check if the PR fulfills these requirements

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

What is the current behavior? (You can also link to an open issue here)
Cannot recover if cache directory is not writable.

What is the new behavior?
Switches to tmpdir if cache directory is not writable.

Does this PR introduce a breaking change?

  • Yes
  • No

@codecov-io
Copy link

Current coverage is 82.35% (diff: 75.00%)

Merging #338 into master will increase coverage by 0.65%

@@             master       #338   diff @@
==========================================
  Files             6          6          
  Lines           153        153          
  Methods          22         21     -1   
  Messages          0          0          
  Branches         33         31     -2   
==========================================
+ Hits            125        126     +1   
- Misses           13         14     +1   
+ Partials         15         13     -2   

Powered by Codecov. Last update 3e1b5bf...2970b13

directory = params.directory;
mkdirp.sync(directory);
} else {
directory = findCacheDir({ name: "babel-loader", create: true });
Copy link
Contributor

Choose a reason for hiding this comment

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

If findCacheDir doesn't find the package root directory, it doesn't throw, only returns null. Can you handle that case below? If directory is null we should fall back to os.tmpdir().

Copy link
Author

Choose a reason for hiding this comment

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

Yes, but passing create: true makes findCacheDir create the directory, which will force it to throw if it doesn't exist.

It would make sense to turn this into a test case.

Copy link
Contributor

Choose a reason for hiding this comment

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

Only if it can find a parent directory with package.json: https://github.com/avajs/find-cache-dir/blob/7df8ba743347945d1f6d51a281fe6776d656b104/index.js#L17-L19

If pkgDir.sync(dir) returns null, findCacheDir will also return null regardless of the create option.

+1 for adding a test case.

Copy link
Author

Choose a reason for hiding this comment

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

You're completely right, I guess I should not let findCacheDir to create the directory. I'll take a look at this today hopefully.

@danez
Copy link
Member

danez commented Dec 15, 2016

merged with #346

@danez danez closed this Dec 15, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants