Skip to content

Commit 3aed74b

Browse files
committed
feat(read): change lstat to stat to support symlinks in the cache
1 parent 78f0b8b commit 3aed74b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

lib/content/read.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ async function read (cache, integrity, opts = {}) {
1313
const { size } = opts
1414
const { stat, cpath, sri } = await withContentSri(cache, integrity, async (cpath, sri) => {
1515
// get size
16-
const stat = await fs.lstat(cpath)
16+
const stat = await fs.stat(cpath)
1717
return { stat, cpath, sri }
1818
})
1919
if (typeof size === 'number' && stat.size !== size) {
@@ -73,8 +73,8 @@ function readStream (cache, integrity, opts = {}) {
7373
// Set all this up to run on the stream and then just return the stream
7474
Promise.resolve().then(async () => {
7575
const { stat, cpath, sri } = await withContentSri(cache, integrity, async (cpath, sri) => {
76-
// just lstat to ensure it exists
77-
const stat = await fs.lstat(cpath)
76+
// just stat to ensure it exists
77+
const stat = await fs.stat(cpath)
7878
return { stat, cpath, sri }
7979
})
8080
if (typeof size === 'number' && size !== stat.size) {
@@ -111,7 +111,7 @@ async function hasContent (cache, integrity) {
111111

112112
try {
113113
return await withContentSri(cache, integrity, async (cpath, sri) => {
114-
const stat = await fs.lstat(cpath)
114+
const stat = await fs.stat(cpath)
115115
return { size: stat.size, sri, stat }
116116
})
117117
} catch (err) {
@@ -139,7 +139,7 @@ function hasContentSync (cache, integrity) {
139139

140140
return withContentSriSync(cache, integrity, (cpath, sri) => {
141141
try {
142-
const stat = fs.lstatSync(cpath)
142+
const stat = fs.statSync(cpath)
143143
return { size: stat.size, sri, stat }
144144
} catch (err) {
145145
if (err.code === 'ENOENT') {

0 commit comments

Comments
 (0)