-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7c7874c
commit 6e58ac6
Showing
171 changed files
with
12,419 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { ReturnCallback } from '../../resource/IResource'; | ||
import { RequestContext } from '../../server/v2/RequestContext'; | ||
import { Resource } from '../../manager/v2/fileSystem/Resource'; | ||
export declare function extractOneToken(ifHeader: string): string; | ||
export declare function parseIfHeader(ifHeader: string): (ctx: RequestContext, resource: Resource, callback: ReturnCallback<boolean>) => void; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var Path_1 = require("../../manager/v2/Path"); | ||
var url = require("url"); | ||
function NoLock() { | ||
return function (resource, callback) { | ||
resource.lockManager(function (e, lm) { | ||
if (e) | ||
return callback(e, false); | ||
lm.getLocks(function (e, locks) { | ||
callback(e, locks ? locks.length === 0 : false); | ||
}); | ||
}); | ||
}; | ||
} | ||
function Token(token) { | ||
return function (resource, callback) { | ||
resource.lockManager(function (e, lm) { | ||
if (e) | ||
return callback(e, false); | ||
lm.getLock(token, function (e, lock) { return callback(e, !!lock && !e); }); | ||
}); | ||
}; | ||
} | ||
function Tag(tag) { | ||
return function (resource, callback) { | ||
resource.etag(function (e, etag) { return callback(e, !e && etag === tag); }); | ||
}; | ||
} | ||
function Not(filter) { | ||
return function (resource, callback) { | ||
filter(resource, function (e, v) { | ||
callback(e, !v); | ||
}); | ||
}; | ||
} | ||
function parseInternal(group) { | ||
var rex = /((not)|<([^>]+)>|\[([^\]]+)\]|<(DAV:no-lock)>)/ig; | ||
var match = rex.exec(group); | ||
var isNot = false; | ||
var andArray = []; | ||
function add(filter) { | ||
andArray.push(isNot ? Not(filter) : filter); | ||
isNot = false; | ||
} | ||
while (match) { | ||
if (match[2]) { | ||
isNot = true; | ||
} | ||
else if (match[3]) { | ||
add(Token(match[3])); | ||
} | ||
else if (match[4]) { | ||
add(Tag(match[4])); | ||
} | ||
else if (match[5]) { | ||
add(NoLock()); | ||
} | ||
match = rex.exec(group); | ||
} | ||
if (andArray.length) | ||
return function (r, callback) { return callback(null, true); }; | ||
return function (resource, callback) { | ||
var nb = andArray.length; | ||
function done(error, result) { | ||
if (nb <= 0) | ||
return; | ||
if (error) { | ||
nb = -1; | ||
callback(error, false); | ||
return; | ||
} | ||
--nb; | ||
if (nb === 0 || !result) { | ||
nb = -1; | ||
callback(null, result); | ||
} | ||
} | ||
andArray.forEach(function (a) { return a(resource, done); }); | ||
}; | ||
} | ||
function extractOneToken(ifHeader) { | ||
var match = /^[ ]*\([ ]*<([^>]+)>[ ]*\)[ ]*$/.exec(ifHeader); | ||
if (!match) | ||
return null; | ||
else | ||
return match[1]; | ||
} | ||
exports.extractOneToken = extractOneToken; | ||
function parseIfHeader(ifHeader) { | ||
var rex = /(?:<([^>]+)>)?\s*\(([^\)]+)\)/g; | ||
var match = rex.exec(ifHeader); | ||
var orArray = []; | ||
var oldPath = undefined; | ||
while (match) { | ||
if (match[1]) | ||
oldPath = url.parse(match[1]).path; | ||
orArray.push({ | ||
path: oldPath, | ||
actions: parseInternal(match[2]) | ||
}); | ||
match = rex.exec(ifHeader); | ||
} | ||
if (orArray.length == 0) | ||
return function (ctx, resource, callback) { return callback(null, true); }; | ||
return function (ctx, resource, callback) { | ||
var nb = orArray.length; | ||
function done(error, result) { | ||
if (nb <= 0) | ||
return; | ||
if (error) { | ||
nb = -1; | ||
callback(error, false); | ||
return; | ||
} | ||
--nb; | ||
if (nb === 0 || result) { | ||
nb = -1; | ||
callback(null, result); | ||
} | ||
} | ||
orArray.forEach(function (a) { | ||
if (!a.path) | ||
a.actions(resource, done); | ||
else { | ||
var sPath_1 = new Path_1.Path(a.path); | ||
ctx.server.getFileSystem(sPath_1, function (fs, _, sub) { | ||
a.actions(fs.resource(ctx, sPath_1), done); | ||
}); | ||
} | ||
}); | ||
}; | ||
} | ||
exports.parseIfHeader = parseIfHeader; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export * from './IfParser'; | ||
export * from '../Workflow'; | ||
export * from '../XML'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
"use strict"; | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__export(require("./IfParser")); | ||
__export(require("../Workflow")); | ||
__export(require("../XML")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './export'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
"use strict"; | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__export(require("./export")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
export declare class Path { | ||
paths: string[]; | ||
constructor(path: Path | string[] | string); | ||
isRoot(): boolean; | ||
fileName(): string; | ||
rootName(): string; | ||
parentName(): string; | ||
getParent(): Path; | ||
hasParent(): boolean; | ||
removeRoot(): string; | ||
removeFile(): string; | ||
getChildPath(childPath: string | Path): Path; | ||
clone(): Path; | ||
toString(endsWithSlash?: boolean): string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var Path = (function () { | ||
function Path(path) { | ||
if (path.constructor === String) { | ||
var sPath = decodeURI(path); | ||
var doubleIndex = void 0; | ||
while ((doubleIndex = sPath.indexOf('//')) !== -1) | ||
sPath = sPath.substr(0, doubleIndex) + sPath.substr(doubleIndex + 1); | ||
this.paths = sPath.replace(/(^\/|\/$)/g, '').split('/'); | ||
} | ||
else if (path.constructor === Path) | ||
this.paths = path.paths.filter(function (x) { return true; }); // clone | ||
else | ||
this.paths = path; | ||
this.paths = this.paths.filter(function (p) { return p.length > 0; }); | ||
} | ||
Path.prototype.isRoot = function () { | ||
return this.paths.length === 0 || this.paths.length === 1 && this.paths[0].length === 0; | ||
}; | ||
Path.prototype.fileName = function () { | ||
return this.paths[this.paths.length - 1]; | ||
}; | ||
Path.prototype.rootName = function () { | ||
return this.paths[0]; | ||
}; | ||
Path.prototype.parentName = function () { | ||
return this.paths[this.paths.length - 2]; | ||
}; | ||
Path.prototype.getParent = function () { | ||
return new Path(this.paths.slice(0, this.paths.length - 1)); | ||
}; | ||
Path.prototype.hasParent = function () { | ||
return this.paths.length >= 2; | ||
}; | ||
Path.prototype.removeRoot = function () { | ||
return this.paths.shift(); | ||
}; | ||
Path.prototype.removeFile = function () { | ||
return this.paths.pop(); | ||
}; | ||
Path.prototype.getChildPath = function (childPath) { | ||
var subPath = new Path(childPath); | ||
var path = this.clone(); | ||
for (var _i = 0, _a = subPath.paths; _i < _a.length; _i++) { | ||
var subName = _a[_i]; | ||
path.paths.push(subName); | ||
} | ||
return path; | ||
}; | ||
Path.prototype.clone = function () { | ||
return new Path(this); | ||
}; | ||
Path.prototype.toString = function (endsWithSlash) { | ||
if (endsWithSlash === void 0) { endsWithSlash = false; } | ||
var value = '/' + this.paths.join('/'); | ||
if (endsWithSlash && value.length > 1) | ||
return value + '/'; | ||
return value; | ||
}; | ||
return Path; | ||
}()); | ||
exports.Path = Path; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export * from './instances/FTPFileSystem'; | ||
export * from './instances/PhysicalFileSystem'; | ||
export * from './instances/VirtualFileSystem'; | ||
export * from './fileSystem/export'; | ||
export * from './Path'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
"use strict"; | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__export(require("./instances/FTPFileSystem")); | ||
__export(require("./instances/PhysicalFileSystem")); | ||
__export(require("./instances/VirtualFileSystem")); | ||
__export(require("./fileSystem/export")); | ||
__export(require("./Path")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { XMLElement } from '../../../helper/XML'; | ||
export declare type SimpleCallback = (error?: Error) => void; | ||
export declare type ReturnCallback<T> = (error?: Error, data?: T) => void; | ||
export declare type Return2Callback<T1, T2> = (error?: Error, data1?: T1, data2?: T2) => void; | ||
export declare type ResourcePropertyValue = string | XMLElement | XMLElement[]; | ||
export declare class ResourceType { | ||
isFile: boolean; | ||
isDirectory: boolean; | ||
static File: ResourceType; | ||
static Directory: ResourceType; | ||
static Hybrid: ResourceType; | ||
static NoResource: ResourceType; | ||
constructor(isFile: boolean, isDirectory: boolean); | ||
} | ||
export declare type OpenWriteStreamMode = 'mustCreate' | 'canCreate' | 'mustExist' | 'canCreateIntermediates' | 'mustCreateIntermediates'; | ||
export interface SubTree { | ||
[name: string]: ResourceType | SubTree; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var ResourceType = (function () { | ||
function ResourceType(isFile, isDirectory) { | ||
this.isFile = isFile; | ||
this.isDirectory = isDirectory; | ||
} | ||
return ResourceType; | ||
}()); | ||
ResourceType.File = new ResourceType(true, false); | ||
ResourceType.Directory = new ResourceType(false, true); | ||
ResourceType.Hybrid = new ResourceType(true, true); | ||
ResourceType.NoResource = new ResourceType(false, false); | ||
exports.ResourceType = ResourceType; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { RequestContext } from '../../../server/v2/RequestContext'; | ||
import { ResourceType, OpenWriteStreamMode } from './CommonTypes'; | ||
export interface IContextInfo { | ||
context: RequestContext; | ||
} | ||
export interface OpenWriteStreamInfo extends IContextInfo { | ||
targetSource: boolean; | ||
estimatedSize: number; | ||
mode: OpenWriteStreamMode; | ||
} | ||
export interface OpenReadStreamInfo extends IContextInfo { | ||
targetSource: boolean; | ||
estimatedSize: number; | ||
} | ||
export interface MimeTypeInfo extends IContextInfo { | ||
targetSource: boolean; | ||
} | ||
export interface SizeInfo extends IContextInfo { | ||
targetSource: boolean; | ||
} | ||
export interface CreateInfo extends IContextInfo { | ||
type: ResourceType; | ||
} | ||
export interface CopyInfo extends IContextInfo { | ||
depth: number; | ||
overwrite: boolean; | ||
} | ||
export interface DeleteInfo extends IContextInfo { | ||
depth: number; | ||
} | ||
export interface MoveInfo extends IContextInfo { | ||
overwrite: boolean; | ||
} | ||
export interface ETagInfo extends IContextInfo { | ||
} | ||
export interface RenameInfo extends IContextInfo { | ||
} | ||
export interface AvailableLocksInfo extends IContextInfo { | ||
} | ||
export interface LockManagerInfo extends IContextInfo { | ||
} | ||
export interface PropertyManagerInfo extends IContextInfo { | ||
} | ||
export interface ReadDirInfo extends IContextInfo { | ||
} | ||
export interface CreationDateInfo extends IContextInfo { | ||
} | ||
export interface LastModifiedDateInfo extends IContextInfo { | ||
} | ||
export interface WebNameInfo extends IContextInfo { | ||
} | ||
export interface DisplayNameInfo extends IContextInfo { | ||
} | ||
export interface TypeInfo extends IContextInfo { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
Oops, something went wrong.