Skip to content

Commit d250050

Browse files
committed
Minor cleanups
1 parent 9e7d9a1 commit d250050

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

src/auth.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class Auth {
7575
*/
7676
async init() {
7777
if (this.adapter.init) {
78-
return await this.adapter.init();
78+
return this.adapter.init();
7979
}
8080

8181
return true;

src/settings.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,10 @@ class Settings {
4343
*/
4444
constructor(core, options = {}) {
4545
this.core = core;
46-
this.options = Object.assign({
47-
adapter: nullAdapter
48-
}, options);
46+
this.options = {
47+
adapter: nullAdapter,
48+
...options
49+
};
4950

5051
if (this.options.adapter === 'fs') {
5152
this.options.adapter = fsAdapter;

src/utils/vfs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ const mountpointResolver = core => async (path) => {
168168
? adapters[mount.adapter]
169169
: adapters.system);
170170

171-
return {mount, adapter};
171+
return Object.freeze({mount, adapter});
172172
};
173173

174174
/*

src/vfs.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,11 @@ const createRequestFactory = findMountpoint => (getter, method, readOnly, respon
149149
const {attributes} = found.mount;
150150
const strict = attributes.strictGroups !== false;
151151
const ranges = (!attributes.adapter || attributes.adapter === 'system') || attributes.ranges === true;
152-
const wrapper = m => found.adapter[m]({adapter: found.adapter, mount: found.mount})(...args);
153-
const readstat = () => wrapper('stat').catch(() => ({}));
152+
const vfsMethodWrapper = m => found.adapter[m](found)(...args);
153+
const readstat = () => vfsMethodWrapper('stat').catch(() => ({}));
154154
await checkMountpointPermission(req, res, method, readOnly, strict)(found);
155155

156-
const result = await wrapper(method);
156+
const result = await vfsMethodWrapper(method);
157157
if (method === 'readfile') {
158158
const stat = await readstat();
159159

@@ -195,7 +195,6 @@ const createCrossRequestFactory = findMountpoint => (getter, method, respond) =>
195195
const srcMount = await findMountpoint(from);
196196
const destMount = await findMountpoint(to);
197197
const sameAdapter = srcMount.adapter === destMount.adapter;
198-
const createArgs = t => ({adapter: t.adapter, mount: t.mount});
199198

200199
const srcStrict = srcMount.mount.attributes.strictGroups !== false;
201200
const destStrict = destMount.mount.attributes.strictGroups !== false;
@@ -204,21 +203,21 @@ const createCrossRequestFactory = findMountpoint => (getter, method, respond) =>
204203

205204
if (sameAdapter) {
206205
const result = await srcMount
207-
.adapter[method](createArgs(srcMount), createArgs(destMount))(from, to, options);
206+
.adapter[method](srcMount, destMount)(from, to, options);
208207

209208
return !!result;
210209
}
211210

212211
// Simulates a copy/move
213212
const stream = await srcMount.adapter
214-
.readfile(createArgs(srcMount))(from, options);
213+
.readfile(srcMount)(from, options);
215214

216215
const result = await destMount.adapter
217-
.writefile(createArgs(destMount))(to, stream, options);
216+
.writefile(destMount)(to, stream, options);
218217

219218
if (method === 'rename') {
220219
await srcMount.adapter
221-
.unlink(createArgs(srcMount))(from, options);
220+
.unlink(srcMount)(from, options);
222221
}
223222

224223
return !!result;

0 commit comments

Comments
 (0)