@parcel/cache
Advanced tools
Comparing version 2.0.0-canary.1632 to 2.0.0-canary.1633
@@ -154,2 +154,8 @@ "use strict"; | ||
async setLargeBlob(key, contents, options) { | ||
const previousEntry = await this.get(key); | ||
if (previousEntry) { | ||
await this.store.remove(key); | ||
await this.fsCache.deleteLargeBlob(previousEntry.largeBlobKey); | ||
} | ||
// $FlowFixMe flow libs are outdated but we only support node>16 so randomUUID is present | ||
@@ -156,0 +162,0 @@ const largeBlobKey = `${key}_${_crypto().default.randomUUID()}`; |
{ | ||
"name": "@parcel/cache", | ||
"description": "Interface for defining caches and file-system, IDB and LMDB implementations.", | ||
"version": "2.0.0-canary.1632+98a6b8ed7", | ||
"version": "2.0.0-canary.1633+5b0f645b9", | ||
"license": "MIT", | ||
@@ -28,9 +28,9 @@ "publishConfig": { | ||
"dependencies": { | ||
"@parcel/fs": "2.0.0-canary.1632+98a6b8ed7", | ||
"@parcel/logger": "2.0.0-canary.1632+98a6b8ed7", | ||
"@parcel/utils": "2.0.0-canary.1632+98a6b8ed7", | ||
"@parcel/fs": "2.0.0-canary.1633+5b0f645b9", | ||
"@parcel/logger": "2.0.0-canary.1633+5b0f645b9", | ||
"@parcel/utils": "2.0.0-canary.1633+5b0f645b9", | ||
"lmdb": "2.8.5" | ||
}, | ||
"peerDependencies": { | ||
"@parcel/core": "^2.0.0-canary.1630+98a6b8ed7" | ||
"@parcel/core": "^2.0.0-canary.1631+5b0f645b9" | ||
}, | ||
@@ -44,3 +44,3 @@ "devDependencies": { | ||
}, | ||
"gitHead": "98a6b8ed78a3f977e3b2fecb2561ac831f88d221" | ||
"gitHead": "5b0f645b9104f2a9fcd40a88c22859673e75e67a" | ||
} |
@@ -144,2 +144,8 @@ // @flow strict-local | ||
): Promise<void> { | ||
const previousEntry = await this.get<LargeBlobEntry>(key); | ||
if (previousEntry) { | ||
await this.store.remove(key); | ||
await this.fsCache.deleteLargeBlob(previousEntry.largeBlobKey); | ||
} | ||
// $FlowFixMe flow libs are outdated but we only support node>16 so randomUUID is present | ||
@@ -146,0 +152,0 @@ const largeBlobKey = `${key}_${crypto.randomUUID()}`; |
@@ -5,2 +5,3 @@ // @flow | ||
import * as tempy from 'tempy'; | ||
import fs from 'fs'; | ||
import assert from 'assert'; | ||
@@ -11,5 +12,6 @@ import path from 'path'; | ||
describe('LMDBCache', () => { | ||
let tmpDir: string; | ||
let lmdbCache: Cache; | ||
beforeEach(async () => { | ||
const tmpDir = path.join(tempy.directory(), 'LMDBCache'); | ||
tmpDir = path.join(tempy.directory(), 'LMDBCache'); | ||
mkdirp.sync(tmpDir); | ||
@@ -63,2 +65,21 @@ lmdbCache = new LMDBCache(tmpDir); | ||
}); | ||
it('setting multiple large blobs and then removing them will leave the disk empty', async () => { | ||
assert(!(await lmdbCache.has('test-key')), 'LMDB did not start empty'); | ||
const filesAtStart = fs.readdirSync(tmpDir); | ||
const buffer = Buffer.from([1, 2, 3, 4]); | ||
await lmdbCache.setLargeBlob('test-key', buffer); | ||
await lmdbCache.setLargeBlob('test-key', buffer); | ||
await lmdbCache.setLargeBlob('test-key', buffer); | ||
await lmdbCache.setLargeBlob('other-key', buffer); | ||
await lmdbCache.setLargeBlob('other-key', buffer); | ||
await lmdbCache.setLargeBlob('other-key', buffer); | ||
await lmdbCache.deleteLargeBlob('test-key'); | ||
await lmdbCache.deleteLargeBlob('other-key'); | ||
const filesAtEnd = fs.readdirSync(tmpDir); | ||
assert.deepEqual(filesAtStart, filesAtEnd); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
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
40170
1201
2