diff --git a/lib/manager/VirtualStoredFSManager.d.ts b/lib/manager/VirtualStoredFSManager.d.ts
index 94cbc729..cd4aff04 100644
--- a/lib/manager/VirtualStoredFSManager.d.ts
+++ b/lib/manager/VirtualStoredFSManager.d.ts
@@ -1,13 +1,14 @@
///
-import { IResource, ResourceType, ReturnCallback } from '../resource/IResource';
+import { IResource, ResourceType, ReturnCallback, SimpleCallback } from '../resource/IResource';
+import { Readable, Writable } from 'stream';
import { SerializedObject } from './ISerializer';
import { FSManager } from './FSManager';
-import { Readable, Writable } from 'stream';
export interface IVirtualStoredContentManager {
uid: string;
initialize(callback: (error: Error) => void): any;
read(contentUid: string, callback: ReturnCallback): any;
write(contentUid: string, callback: ReturnCallback): any;
+ deallocate(contentId: string, callback: SimpleCallback): any;
allocate(callback: ReturnCallback): any;
allocate(options: any, callback: ReturnCallback): any;
}
@@ -17,6 +18,7 @@ export declare abstract class VirtualStoredContentManager implements IVirtualSto
abstract read(contentUid: string, callback: ReturnCallback): any;
abstract write(contentUid: string, callback: ReturnCallback): any;
protected abstract _allocate(options: any, callback: ReturnCallback): any;
+ abstract deallocate(contentId: string, callback: SimpleCallback): any;
allocate(callback: ReturnCallback): any;
allocate(options: any, callback: ReturnCallback): any;
}
@@ -34,6 +36,7 @@ export declare class SimpleVirtualStoredContentManager extends VirtualStoredCont
initialize(callback: (error: Error) => void): void;
read(contentUid: string, _callback: ReturnCallback): void;
write(contentUid: string, _callback: ReturnCallback): void;
+ deallocate(uid: string, callback: SimpleCallback): void;
protected _allocate(options: any, _callback: ReturnCallback): void;
}
export declare class VirtualStoredFSManager implements FSManager {
diff --git a/lib/manager/VirtualStoredFSManager.js b/lib/manager/VirtualStoredFSManager.js
index ce3dcf39..7293eaaf 100644
--- a/lib/manager/VirtualStoredFSManager.js
+++ b/lib/manager/VirtualStoredFSManager.js
@@ -95,6 +95,9 @@ var SimpleVirtualStoredContentManager = (function (_super) {
}
});
};
+ SimpleVirtualStoredContentManager.prototype.deallocate = function (uid, callback) {
+ fs.unlink(path.join(this.storeFolderPath, uid), callback);
+ };
SimpleVirtualStoredContentManager.prototype._allocate = function (options, _callback) {
var callback = function (_1, _2) { return process.nextTick(function () { return _callback(_1, _2); }); };
if (!this.initialized)
diff --git a/lib/resource/virtualStored/VirtualStoredFile.d.ts b/lib/resource/virtualStored/VirtualStoredFile.d.ts
index aeb41daa..2604871d 100644
--- a/lib/resource/virtualStored/VirtualStoredFile.d.ts
+++ b/lib/resource/virtualStored/VirtualStoredFile.d.ts
@@ -8,6 +8,7 @@ export declare class VirtualStoredFile extends VirtualStoredResource {
len: number;
constructor(name: string, parent?: IResource, fsManager?: FSManager);
create(callback: SimpleCallback): void;
+ delete(callback: SimpleCallback): void;
type(callback: ReturnCallback): void;
write(targetSource: boolean, callback: ReturnCallback): void;
read(targetSource: boolean, callback: ReturnCallback): void;
diff --git a/lib/resource/virtualStored/VirtualStoredFile.js b/lib/resource/virtualStored/VirtualStoredFile.js
index 2c9cdf0c..79b7fce6 100644
--- a/lib/resource/virtualStored/VirtualStoredFile.js
+++ b/lib/resource/virtualStored/VirtualStoredFile.js
@@ -34,6 +34,9 @@ var VirtualStoredFile = (function (_super) {
callback(e);
});
};
+ VirtualStoredFile.prototype.delete = function (callback) {
+ this.fsManager.contentManager.deallocate(this.contentUid, callback);
+ };
VirtualStoredFile.prototype.type = function (callback) {
callback(null, IResource_1.ResourceType.File);
};
diff --git a/src/manager/VirtualStoredFSManager.ts b/src/manager/VirtualStoredFSManager.ts
index d7b061af..f281c906 100644
--- a/src/manager/VirtualStoredFSManager.ts
+++ b/src/manager/VirtualStoredFSManager.ts
@@ -1,10 +1,10 @@
-import { IResource, ResourceType, ReturnCallback } from '../resource/IResource'
-import { SerializedObject } from './ISerializer'
+import { IResource, ResourceType, ReturnCallback, SimpleCallback } from '../resource/IResource'
import { VirtualStoredFolder } from '../resource/virtualStored/VirtualStoredFolder'
+import { Readable, Writable } from 'stream'
import { VirtualStoredFile } from '../resource/virtualStored/VirtualStoredFile'
+import { SerializedObject } from './ISerializer'
import { FSManager } from './FSManager'
import { Errors } from '../Errors'
-import { Readable, Writable } from 'stream'
import * as path from 'path'
import * as fs from 'fs'
@@ -17,6 +17,8 @@ export interface IVirtualStoredContentManager
read(contentUid : string, callback : ReturnCallback)
write(contentUid : string, callback : ReturnCallback)
+ deallocate(contentId : string, callback : SimpleCallback);
+
allocate(callback : ReturnCallback);
allocate(options : any, callback : ReturnCallback)
}
@@ -28,6 +30,7 @@ export abstract class VirtualStoredContentManager implements IVirtualStoredConte
abstract read(contentUid : string, callback : ReturnCallback)
abstract write(contentUid : string, callback : ReturnCallback)
protected abstract _allocate(options : any, callback : ReturnCallback)
+ abstract deallocate(contentId : string, callback : SimpleCallback);
allocate(callback : ReturnCallback);
allocate(options : any, callback : ReturnCallback)
@@ -128,6 +131,11 @@ export class SimpleVirtualStoredContentManager extends VirtualStoredContentManag
}
})
}
+
+ deallocate(uid : string, callback : SimpleCallback)
+ {
+ fs.unlink(path.join(this.storeFolderPath, uid), callback);
+ }
protected _allocate(options : any, _callback : ReturnCallback)
{
diff --git a/src/resource/virtualStored/VirtualStoredFile.ts b/src/resource/virtualStored/VirtualStoredFile.ts
index 01fb3445..b9088193 100644
--- a/src/resource/virtualStored/VirtualStoredFile.ts
+++ b/src/resource/virtualStored/VirtualStoredFile.ts
@@ -32,6 +32,10 @@ export class VirtualStoredFile extends VirtualStoredResource
callback(e);
})
}
+ delete(callback : SimpleCallback)
+ {
+ (this.fsManager as VirtualStoredFSManager).contentManager.deallocate(this.contentUid, callback);
+ }
// ****************************** Std meta-data ****************************** //
type(callback : ReturnCallback)
diff --git a/test/tests/resourceTesterVirtualStored/2 b/test/tests/resourceTesterVirtualStored/2
deleted file mode 100644
index e69de29b..00000000