@parcel/cache
Advanced tools
Comparing version 2.0.0-canary.1562 to 2.0.0-canary.1563
@@ -45,12 +45,6 @@ "use strict"; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); } | ||
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } } | ||
function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; } // flowlint-next-line untyped-import:off | ||
// flowlint-next-line untyped-import:off | ||
const pipeline = (0, _util().promisify)(_stream().default.pipeline); | ||
var _getFilePath = /*#__PURE__*/new WeakSet(); | ||
var _unlinkChunks = /*#__PURE__*/new WeakSet(); | ||
class FSCache { | ||
constructor(fs, cacheDir) { | ||
_classPrivateMethodInitSpec(this, _unlinkChunks); | ||
_classPrivateMethodInitSpec(this, _getFilePath); | ||
this.fs = fs; | ||
@@ -100,9 +94,20 @@ this.dir = cacheDir; | ||
} | ||
#getFilePath(key, index) { | ||
return _path().default.join(this.dir, `${key}-${index}`); | ||
} | ||
async #unlinkChunks(key, index) { | ||
try { | ||
await this.fs.unlink(this.#getFilePath(key, index)); | ||
await this.#unlinkChunks(key, index + 1); | ||
} catch (err) { | ||
// If there's an error, no more chunks are left to delete | ||
} | ||
} | ||
hasLargeBlob(key) { | ||
return this.fs.exists(_classPrivateMethodGet(this, _getFilePath, _getFilePath2).call(this, key, 0)); | ||
return this.fs.exists(this.#getFilePath(key, 0)); | ||
} | ||
async getLargeBlob(key) { | ||
const buffers = []; | ||
for (let i = 0; await this.fs.exists(_classPrivateMethodGet(this, _getFilePath, _getFilePath2).call(this, key, i)); i += 1) { | ||
const file = this.fs.readFile(_classPrivateMethodGet(this, _getFilePath, _getFilePath2).call(this, key, i)); | ||
for (let i = 0; await this.fs.exists(this.#getFilePath(key, i)); i += 1) { | ||
const file = this.fs.readFile(this.#getFilePath(key, i)); | ||
buffers.push(file); | ||
@@ -117,3 +122,3 @@ } | ||
// If there's one chunk, don't slice the content | ||
writePromises.push(this.fs.writeFile(_classPrivateMethodGet(this, _getFilePath, _getFilePath2).call(this, key, 0), contents, { | ||
writePromises.push(this.fs.writeFile(this.#getFilePath(key, 0), contents, { | ||
signal: options === null || options === void 0 ? void 0 : options.signal | ||
@@ -123,3 +128,3 @@ })); | ||
for (let i = 0; i < chunks; i += 1) { | ||
writePromises.push(this.fs.writeFile(_classPrivateMethodGet(this, _getFilePath, _getFilePath2).call(this, key, i), typeof contents === 'string' ? contents.slice(i * _constants.WRITE_LIMIT_CHUNK, (i + 1) * _constants.WRITE_LIMIT_CHUNK) : contents.subarray(i * _constants.WRITE_LIMIT_CHUNK, (i + 1) * _constants.WRITE_LIMIT_CHUNK), { | ||
writePromises.push(this.fs.writeFile(this.#getFilePath(key, i), typeof contents === 'string' ? contents.slice(i * _constants.WRITE_LIMIT_CHUNK, (i + 1) * _constants.WRITE_LIMIT_CHUNK) : contents.subarray(i * _constants.WRITE_LIMIT_CHUNK, (i + 1) * _constants.WRITE_LIMIT_CHUNK), { | ||
signal: options === null || options === void 0 ? void 0 : options.signal | ||
@@ -131,3 +136,3 @@ })); | ||
// If there's already a files following this chunk, it's old and should be removed | ||
writePromises.push(_classPrivateMethodGet(this, _unlinkChunks, _unlinkChunks2).call(this, key, chunks)); | ||
writePromises.push(this.#unlinkChunks(key, chunks)); | ||
await Promise.all(writePromises); | ||
@@ -161,13 +166,2 @@ } | ||
exports.FSCache = FSCache; | ||
function _getFilePath2(key, index) { | ||
return _path().default.join(this.dir, `${key}-${index}`); | ||
} | ||
async function _unlinkChunks2(key, index) { | ||
try { | ||
await this.fs.unlink(_classPrivateMethodGet(this, _getFilePath, _getFilePath2).call(this, key, index)); | ||
await _classPrivateMethodGet(this, _unlinkChunks, _unlinkChunks2).call(this, key, index + 1); | ||
} catch (err) { | ||
// If there's an error, no more chunks are left to delete | ||
} | ||
} | ||
(0, _core().registerSerializableClass)(`${_package.default.version}:FSCache`, FSCache); |
@@ -52,8 +52,5 @@ "use strict"; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); } | ||
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } } | ||
function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; } // flowlint-next-line untyped-import:off | ||
// flowlint-next-line untyped-import:off | ||
// $FlowFixMe | ||
const pipeline = (0, _util().promisify)(_stream().default.pipeline); | ||
var _getFilePath = /*#__PURE__*/new WeakSet(); | ||
class LMDBCache { | ||
@@ -63,3 +60,2 @@ // $FlowFixMe | ||
constructor(cacheDir) { | ||
_classPrivateMethodInitSpec(this, _getFilePath); | ||
this.fs = new (_fs().NodeFS)(); | ||
@@ -114,4 +110,7 @@ this.dir = cacheDir; | ||
} | ||
#getFilePath(key, index) { | ||
return _path().default.join(this.dir, `${key}-${index}`); | ||
} | ||
hasLargeBlob(key) { | ||
return this.fs.exists(_classPrivateMethodGet(this, _getFilePath, _getFilePath2).call(this, key, 0)); | ||
return this.fs.exists(this.#getFilePath(key, 0)); | ||
} | ||
@@ -137,5 +136,2 @@ | ||
exports.LMDBCache = LMDBCache; | ||
function _getFilePath2(key, index) { | ||
return _path().default.join(this.dir, `${key}-${index}`); | ||
} | ||
(0, _core().registerSerializableClass)(`${_package.default.version}:LMDBCache`, LMDBCache); |
{ | ||
"name": "@parcel/cache", | ||
"version": "2.0.0-canary.1562+f84b6dc3f", | ||
"version": "2.0.0-canary.1563+46c2729c0", | ||
"license": "MIT", | ||
@@ -20,3 +20,3 @@ "publishConfig": { | ||
"engines": { | ||
"node": ">= 12.0.0" | ||
"node": ">= 16.0.0" | ||
}, | ||
@@ -28,9 +28,9 @@ "scripts": { | ||
"dependencies": { | ||
"@parcel/fs": "2.0.0-canary.1562+f84b6dc3f", | ||
"@parcel/logger": "2.0.0-canary.1562+f84b6dc3f", | ||
"@parcel/utils": "2.0.0-canary.1562+f84b6dc3f", | ||
"@parcel/fs": "2.0.0-canary.1563+46c2729c0", | ||
"@parcel/logger": "2.0.0-canary.1563+46c2729c0", | ||
"@parcel/utils": "2.0.0-canary.1563+46c2729c0", | ||
"lmdb": "2.8.5" | ||
}, | ||
"peerDependencies": { | ||
"@parcel/core": "^2.0.0-canary.1560+f84b6dc3f" | ||
"@parcel/core": "^2.0.0-canary.1561+46c2729c0" | ||
}, | ||
@@ -44,3 +44,3 @@ "devDependencies": { | ||
}, | ||
"gitHead": "f84b6dc3f97333445c83ea46f60f8e17f0b65397" | ||
"gitHead": "46c2729c053e9bdcd8a2962dbba6f78a4c343c7e" | ||
} |
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
28484
883