Skip to content

Commit

Permalink
Cleaned the code
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrienCastex committed Jul 10, 2017
1 parent d191897 commit 6acbcdd
Show file tree
Hide file tree
Showing 13 changed files with 23 additions and 25 deletions.
4 changes: 2 additions & 2 deletions examples/v1/gatewayPhysical/ts/PhysicalGFSManager.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { SerializedObject, FSManager, Errors, IResource, ResourceType, PhysicalFSManager, PhysicalFile, PhysicalFolder, PhysicalResource } from '../../../lib/index.js'
import { SerializedObject, FSManager, Errors, IResource, ResourceType, PhysicalFSManager, PhysicalFile, PhysicalFolder, PhysicalResource } from 'webdav-server'
import { PhysicalGateway } from './PhysicalGateway'

export class PhysicalGFSManager extends PhysicalFSManager
{
uid : string = "PhysicalGFSManager_1.0.0";
uid : string = 'PhysicalGFSManager_1.0.0';

serialize(resource : any, obj : SerializedObject) : object
{
Expand Down
2 changes: 1 addition & 1 deletion examples/v1/gatewayPhysical/ts/PhysicalGateway.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { PhysicalGFSManager } from './PhysicalGFSManager'
import * as webdav from '../../../lib/index.js'
import * as webdav from 'webdav-server'
import * as path from 'path'
import * as fs from 'fs'

Expand Down
2 changes: 1 addition & 1 deletion examples/v2/customMethod2/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as request from 'request'
// Server instantiation
const server = new webdav.WebDAVServer();

let folderNotify = { };
const folderNotify = { };
server.method('TRACE', {
unchunked(ctx : webdav.HTTPRequestContext, data : Buffer, cb : () => void)
{
Expand Down
2 changes: 1 addition & 1 deletion examples/v2/webResource/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class WebFileSystemSerializer implements v2.FileSystemSerializer
{
uid() : string
{
return "WebFileSystemSerializer_1.0.0";
return 'WebFileSystemSerializer_1.0.0';
}

serialize(fs : WebFileSystem, callback : v2.ReturnCallback<any>) : void
Expand Down
2 changes: 1 addition & 1 deletion lib/helper/v2/IfParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ function parseIfHeader(ifHeader) {
});
match = rex.exec(ifHeader);
}
if (orArray.length == 0)
if (orArray.length === 0)
return function (ctx, resource, callback) { return callback(null, true); };
return function (ctx, resource, callback) {
var nb = orArray.length;
Expand Down
2 changes: 1 addition & 1 deletion lib/manager/PhysicalGFSManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var PhysicalGFSManager = (function (_super) {
__extends(PhysicalGFSManager, _super);
function PhysicalGFSManager() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.uid = "PhysicalGFSManager_1.0.0";
_this.uid = 'PhysicalGFSManager_1.0.0';
return _this;
}
PhysicalGFSManager.prototype.serialize = function (resource, obj) {
Expand Down
7 changes: 3 additions & 4 deletions lib/manager/v2/fileSystem/FileSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ var FileSystem = (function () {
cb(null, can ? path : null);
});
})
.error(function (e) { return __callback(e); })
.error(__callback)
.done(function () { return __callback(null, data.filter(function (p) { return !!p; }).map(function (p) { return p.fileName(); })); });
});
};
Expand Down Expand Up @@ -804,7 +804,7 @@ var FileSystem = (function () {
});
})
.error(callback)
.done(function () { return callback(); });
.done(function (_) { return callback(); });
}
};
FileSystem.prototype.listDeepLocks = function (ctx, startPath, _depth, _callback) {
Expand Down Expand Up @@ -872,8 +872,7 @@ var FileSystem = (function () {
callback(null, paths
.map(function (p) { return new Path_1.Path(p); })
.map(function (p) {
for (var i = 0; i < fsFullPath.paths.length; ++i)
p.removeRoot();
fsFullPath.paths.forEach(function () { return p.removeRoot(); });
return p;
}));
});
Expand Down
6 changes: 3 additions & 3 deletions lib/manager/v2/fileSystem/StandardMethods.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ var StandardMethods = (function () {
pmTo.setProperty(name, prop.value, prop.attributes, cb);
})
.error(callback)
.done(function () { return callback(); });
.done(function (_) { return callback(); });
});
});
});
Expand Down Expand Up @@ -104,9 +104,9 @@ var StandardMethods = (function () {
return callback(e);
var subDepth = depth === -1 ? -1 : Math.max(0, depth - 1);
new Workflow_1.Workflow()
.each(files, function (file, cb) { return StandardMethods.standardCopy(ctx, subPathFrom.getChildPath(file), fsFrom, subPathTo.getChildPath(file), fsTo, overwrite, subDepth, function (e) { return cb(e); }); })
.each(files, function (file, cb) { return StandardMethods.standardCopy(ctx, subPathFrom.getChildPath(file), fsFrom, subPathTo.getChildPath(file), fsTo, overwrite, subDepth, cb); })
.error(callback)
.done(function () { return callback(); });
.done(function (_) { return callback(); });
});
};
fsFrom.type(ctx, subPathFrom, function (e, type) {
Expand Down
2 changes: 1 addition & 1 deletion src/helper/v2/IfParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export function parseIfHeader(ifHeader : string)
match = rex.exec(ifHeader);
}

if(orArray.length == 0)
if(orArray.length === 0)
return (ctx : RequestContext, resource : Resource, callback : ReturnCallback<boolean>) => callback(null, true);

return function(ctx : RequestContext, resource : Resource, callback : ReturnCallback<boolean>) {
Expand Down
2 changes: 1 addition & 1 deletion src/manager/PhysicalGFSManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { IResource } from '../resource/IResource'

export class PhysicalGFSManager extends PhysicalFSManager
{
uid : string = "PhysicalGFSManager_1.0.0";
uid : string = 'PhysicalGFSManager_1.0.0';

serialize(resource : any, obj : SerializedObject) : object
{
Expand Down
7 changes: 3 additions & 4 deletions src/manager/v2/fileSystem/FileSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1061,7 +1061,7 @@ export abstract class FileSystem implements ISerializableFileSystem
cb(null, can ? path : null);
});
})
.error((e) => __callback(e))
.error(__callback)
.done(() => __callback(null, data.filter((p) => !!p).map((p) => p.fileName())));
})
}
Expand Down Expand Up @@ -1302,7 +1302,7 @@ export abstract class FileSystem implements ISerializableFileSystem
})
})
.error(callback)
.done(() => callback());
.done((_) => callback());
}
}

Expand Down Expand Up @@ -1438,8 +1438,7 @@ export abstract class FileSystem implements ISerializableFileSystem
callback(null, paths
.map((p) => new Path(p))
.map((p) => {
for(let i = 0; i < fsFullPath.paths.length; ++i)
p.removeRoot();
fsFullPath.paths.forEach(() => p.removeRoot());
return p;
})
);
Expand Down
6 changes: 3 additions & 3 deletions src/manager/v2/fileSystem/StandardMethods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export abstract class StandardMethods
pmTo.setProperty(name, prop.value, prop.attributes, cb)
})
.error(callback)
.done(() => callback())
.done((_) => callback())
})
})
})
Expand Down Expand Up @@ -154,9 +154,9 @@ export abstract class StandardMethods
const subDepth = depth === -1 ? -1 : Math.max(0, depth - 1);

new Workflow()
.each(files, (file, cb) => StandardMethods.standardCopy(ctx, subPathFrom.getChildPath(file), fsFrom, subPathTo.getChildPath(file), fsTo, overwrite, subDepth, (e) => cb(e)))
.each(files, (file, cb) => StandardMethods.standardCopy(ctx, subPathFrom.getChildPath(file), fsFrom, subPathTo.getChildPath(file), fsTo, overwrite, subDepth, cb))
.error(callback)
.done(() => callback());
.done((_) => callback());
})
}

Expand Down
4 changes: 2 additions & 2 deletions test/v2/tests.ts/lockUnlock/.createFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,9 @@ export function lockResource(
const lock = {
scope: activeLock.find('DAV:lockscope').elements[0].name.replace('DAV:', '').toLowerCase(),
type: activeLock.find('DAV:locktype').elements[0].name.replace('DAV:', '').toLowerCase(),
depth: sDepth === 'infinity' ? -1 : parseInt(sDepth),
depth: sDepth === 'infinity' ? -1 : parseInt(sDepth, 10),
owner: activeLock.find('DAV:owner').elements,
timeoutSec: parseInt(sTimeout.substring(sTimeout.indexOf(':') + 1)),
timeoutSec: parseInt(sTimeout.substring(sTimeout.indexOf(':') + 1), 10),
uuid: activeLock.find('DAV:locktoken').find('DAV:href').findText(),
root: activeLock.find('DAV:lockroot').find('DAV:href').findText()
};
Expand Down

0 comments on commit 6acbcdd

Please sign in to comment.