-
Notifications
You must be signed in to change notification settings - Fork 31
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
[BUG] rm.all
doesn't delete anything on Windows
#165
Comments
rm.all
doesn't delete anythingrm.all
doesn't delete anything on Windows
The problem is lib/util/glob.js https://www.npmjs.com/package/glob#windows The Maybe const globify = (pattern) => pattern.replace(/\\+|\/{2,}/g, '/') But I really don't understand why double forward slashes are replaced at all. |
I'm having an issue where the The root of the problem is the same: I found that before const globify = pattern => pattern.split('\\').join('/') But when created the file const globify = pattern => pattern.split('//').join('/') which is causing problems when |
## What While testing `cacache.verify` I found that on Windows the `stats` returned by it are not properly reported. Moreover, I found that `cacache.verify` fails to delete files if no cache entries refer to them. `cacache.rm.all` also fails to work on Windows: the cache is not cleared after calling this function. ## Why The root of the problem is the same: `globify` function is not replacing to forward-slashes as [`glob` library is expecting to handle Windows paths](https://github.com/isaacs/node-glob#windows). I found that originally `globify` was at `lib/verify.js`, the replacement [of the forward-slashes was made correctly](https://github.com/npm/cacache/pull/101/files#diff-eeac8636d9b6fc8549cda5929066bc44196ae8b9daac1f414fdd61e2e1340db6R16). ```javascript const globify = pattern => pattern.split('\\').join('/') ``` But when created the file `lib/util/glob.js` and moved `globify` there, it [was changed](https://github.com/npm/cacache/pull/141/files#diff-20cceb346ffab6392d2b141017e1aa137df33c1c3ce59d5ccc765171586919f4R6) to ```javascript const globify = pattern => pattern.split('//').join('/') ``` which is causing problems when `glob` is used for obtaining stats and cleanup in the case of [`verify`](https://github.com/npm/cacache/blob/13a4ba3423d8d33b7d718e7200e5d3a5ec720a6d/lib/verify.js#L113) and delete the cache with [rm.all](https://github.com/npm/cacache/blob/13a4ba3423d8d33b7d718e7200e5d3a5ec720a6d/lib/rm.js#L29) ## Change details Replace backslash by forward-slashes if they are present on a path before calling `glob`. Initially I was going to rollback the change to the first implementation of `globify`, but I though it would be more explicit to use [path.sep](https://nodejs.org/api/path.html#pathsep). ## Issues reported [BUG] rm.all doesn't delete anything on Windows #165
Is there an existing issue for this?
Current Behavior
node:19.6.0-alpine
Output
After
rm.all
cache keys still exist and nothing is delete from the filesystem.Expected Behavior
Exception:
NotFoundError: No cache entry for test-key found in ./cache
Works as expected in version 16.1.3
Steps To Reproduce
No response
Environment
The text was updated successfully, but these errors were encountered: