Skip to content

Commit 9946758

Browse files
committedOct 18, 2019
Fix issue with path resolution in VFS on cross requests (fixes #19)
1 parent 819b0cc commit 9946758

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed
 

‎__tests__/adapters/vfs/system.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ describe('VFS System adapter', () => {
3434
}
3535
};
3636

37-
const request = (name, ...args) => adapter[name](vfs)(...args);
37+
const request = (name, ...args) => adapter[name](vfs, vfs)(...args);
3838

3939
test('#touch', () => {
4040
return expect(request('touch', 'home:/test'))

‎src/adapters/vfs/system.js

+6-7
Original file line numberDiff line numberDiff line change
@@ -160,13 +160,12 @@ module.exports = (core) => {
160160
: promise.then(() => true);
161161
};
162162

163-
const crossWrapper = method => vfs => (src, dest, options = {}) =>
164-
Promise.resolve({
165-
realSource: getRealPath(core, vfs.req, vfs.mount, src),
166-
realDest: getRealPath(core, vfs.req, vfs.mount, dest)
167-
})
168-
.then(({realSource, realDest}) => fs[method](realSource, realDest))
169-
.then(() => true);
163+
const crossWrapper = method => (srcVfs, destVfs) => (src, dest, options = {}) => Promise.resolve({
164+
realSource: getRealPath(core, srcVfs.req, srcVfs.mount, src),
165+
realDest: getRealPath(core, destVfs.req, destVfs.mount, dest)
166+
})
167+
.then(({realSource, realDest}) => fs[method](realSource, realDest))
168+
.then(() => true);
170169

171170
return {
172171
watch: (mount, callback) => {

‎src/vfs.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ const createCrossRequestFactory = findMountpoint => (getter, method, respond) =>
150150

151151
if (sameAdapter) {
152152
const result = await srcMount
153-
.adapter[method](createArgs(srcMount))(from, to, options);
153+
.adapter[method](createArgs(srcMount), createArgs(destMount))(from, to, options);
154154

155155
return !!result;
156156
}

0 commit comments

Comments
 (0)
Please sign in to comment.