Skip to content

Commit

Permalink
- return count of removed files/directories
Browse files Browse the repository at this point in the history
  • Loading branch information
Valodya committed Aug 13, 2018
1 parent 2385648 commit ceaf75c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
8 changes: 4 additions & 4 deletions backendless.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -783,17 +783,17 @@ declare module __Backendless {

copyFile(sourcePath: string, targetPath: string): Promise<Object>;

removeSync(fileURL: string): void;
removeSync(fileURL: string): number;

remove(fileURL: string): Promise<void>;
remove(fileURL: string): Promise<number>;

existsSync(path: string): Object;

exists(path: string): Promise<Object>;

removeDirectorySync(path: string): void;
removeDirectorySync(path: string): number;

removeDirectory(path: string): Promise<void>;
removeDirectory(path: string): Promise<number>;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/files/remove.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export function remove(path, asyncHandler) {
throw new Error('File "path" must not be empty and must be String')
}

Request.delete({
return Request.delete({
url : isRemoteUrl(path) ? path : Urls.filePath(path),
isAsync : !!asyncHandler,
asyncHandler: asyncHandler
Expand Down
10 changes: 6 additions & 4 deletions test/tsd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -592,8 +592,10 @@ function testFilesService() {
let resultStr: string;
let resultBool: boolean;
let resultObj: Object;
let resultNumber: number;
let promiseObject: Promise<Object>;
let promiseVoid: Promise<void>;
let promiseNumber: Promise<number>;

resultStr = Backendless.Files.restUrl;

Expand Down Expand Up @@ -634,14 +636,14 @@ function testFilesService() {
resultObj = Backendless.Files.copyFileSync(sourcePath, targetPath);
promiseObject = Backendless.Files.copyFile(sourcePath, targetPath);

Backendless.Files.removeSync(fileURL);
promiseVoid = Backendless.Files.remove(fileURL);
resultNumber = Backendless.Files.removeSync(fileURL);
promiseNumber = Backendless.Files.remove(fileURL);

resultObj = Backendless.Files.existsSync(path);
promiseObject = Backendless.Files.exists(path);

Backendless.Files.removeDirectorySync(path);
promiseVoid = Backendless.Files.removeDirectory(path);
resultNumber = Backendless.Files.removeDirectorySync(path);
promiseNumber = Backendless.Files.removeDirectory(path);

resultObj = Backendless.Files.Permissions.READ.grantUserSync(userid, url);
resultObj = Backendless.Files.Permissions.READ.grantRoleSync(roleName, url);
Expand Down

0 comments on commit ceaf75c

Please sign in to comment.