-
Notifications
You must be signed in to change notification settings - Fork 136
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
Clear is not clearing #365
Comments
For example this works well on a ;(async function() {
const Hyperbee = require('hyperbee');
const Hypercore = require('hypercore');
const fs = require('fs').promises;
await fs.rm('./db', { recursive: true });
let Toyota = {
make: "Toyota",
model: "Camry",
owner: "John Doe"
};
let Honda = {
make: "Honda",
model: "Civic",
owner: "Mark smith"
};
const core = new Hypercore('./db');
const car = new Hyperbee(core);
await car.ready();
await car.put('Toyota', JSON.stringify(Toyota));
console.log((await car.core.get(0)).toString()); // dont remove this
console.log(JSON.parse((await car.get('Toyota')).value.toString()));
await car.put('Honda', JSON.stringify(Honda));
Honda.owner = 'benz';
await car.put('Honda', JSON.stringify(Honda));
const trim = car.core.length;
console.log(trim); // 4
const view = car.createReadStream();
for await (const entry of view) {
await car.put(entry.key.toString(), entry.value.toString());
}
await car.core.clear(1, trim);
console.log(JSON.parse((await car.get('Toyota')).value.toString()));
console.log(JSON.parse((await car.get('Honda')).value.toString()));
console.log(car.core.length); // 6
console.log('#0', await car.core.get(0, { wait: false })); // hyperbee
console.log('#1', await car.core.get(1, { wait: false })); // null
console.log('#2', await car.core.get(2, { wait: false })); // null
console.log('#3', await car.core.get(3, { wait: false })); // null
console.log('#4', await car.core.get(4, { wait: false })); // Toyota buffer
console.log('#5', await car.core.get(5, { wait: false })); // Honda buffer
await car.close();
})(); |
Use drive.clear(filename) to clear content on the drive |
I am going through similar situation in which drive.clear(filePath) doesn't actually clear the data. The disk space also is not reduced. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The text was updated successfully, but these errors were encountered: