Skip to content

Commit

Permalink
Auto-merge for PR #15 via VersionBot
Browse files Browse the repository at this point in the history
Update e2fsprogs and file-disk
  • Loading branch information
resin-io-versionbot[bot] authored Mar 27, 2018
2 parents 0109dce + 072d841 commit 9eb6cf8
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 13 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file
automatically by Versionist. DO NOT EDIT THIS FILE MANUALLY!
This project adheres to [Semantic Versioning](http://semver.org/).

## v1.0.0 - 2018-03-27

* Update file-disk to ^4.1.1 #15 [Alexis Svinartchouk]
* Update e2fsprogs to v1.44.1 #15 [Alexis Svinartchouk]

## v0.1.1 - 2017-11-21

* Ensure pre-gyp releases use the existing versionbot tag (not a new one) #13 [Tim Perry]
Expand Down
2 changes: 1 addition & 1 deletion deps/e2fsprogs
Submodule e2fsprogs updated 240 files
31 changes: 23 additions & 8 deletions lib/disk.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,44 @@
'use strict';

const filedisk = require('file-disk');

const constants = require('./constants');

class DiskWrapper extends filedisk.DiskWrapper {
const promiseToCallback = (promise, callback, transform) => {
promise
.then((result) => {
const args = (transform === undefined) ? [] : transform(result);
callback(null, ...args);
})
.catch(callback);
};

class DiskWrapper {
constructor(disk, offset=0) {
super(disk);
this.disk = disk;
this.offset = offset;
}

request(type, offset, length, buffer, callback) {
offset += this.offset;
switch(type) {
case constants.E2FS_BLK_READ:
this.disk.read(buffer, 0, buffer.length, offset, callback);
promiseToCallback(
this.disk.read(buffer, 0, buffer.length, offset),
callback,
({ bytesRead, buffer }) => [ bytesRead, buffer ]
);
break;
case constants.E2FS_BLK_WRITE:
this.disk.write(buffer, 0, buffer.length, offset, callback);
promiseToCallback(
this.disk.write(buffer, 0, buffer.length, offset),
callback,
({ bytesWritten, buffer }) => [ bytesWritten, buffer ]
);
break;
case constants.E2FS_BLK_FLUSH:
this.disk.flush(callback);
promiseToCallback(this.disk.flush(), callback);
break;
case constants.E2FS_BLK_DISCARD:
this.disk.discard(offset, length, callback);
promiseToCallback(this.disk.discard(offset, length), callback);
break;
default:
callback(new Error('Unknown request type: ' + type));
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ext2fs",
"version": "0.1.1",
"version": "1.0.0",
"description": "NodeJS native bindings to the libext2fs for cross-platform ext filesystem handling",
"author": "Petros Angelatos <[email protected]>",
"contributors": [
Expand Down Expand Up @@ -30,7 +30,7 @@
"async": "^2.4.1",
"bindings": "^1.2.1",
"eslint": "^3.19.0",
"file-disk": "^1.0.0",
"file-disk": "^4.1.1",
"nan": "^2.5.1",
"node-pre-gyp": "^0.6.39"
},
Expand Down Expand Up @@ -60,4 +60,4 @@
"bugs": {
"url": "https://github.com/resin-io/node-ext2fs/issues"
}
}
}
2 changes: 1 addition & 1 deletion test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,7 @@ describe('ext2fs', function() {
return fs.trimAsync();
})
.then(function() {
return disk.getBlockMapAsync(blockSize);
return disk.getBlockMap(blockSize, true); // true is for calculateChecksums
})
.then(function(bmap) {
assert.strictEqual(bmap.imageSize, 4194304);
Expand Down

0 comments on commit 9eb6cf8

Please sign in to comment.