Skip to content

Commit f511e85

Browse files
committed
Removed listFilePaths from storage interface.
Removed unused constants and functions in names.ts.
1 parent 2866631 commit f511e85

File tree

3 files changed

+3
-53
lines changed

3 files changed

+3
-53
lines changed

src/storage/client_side_storage.ts

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -209,38 +209,6 @@ class ClientSideStorage implements commonStorage.Storage {
209209
});
210210
}
211211

212-
// TODO(lizlooney): remove listFilePaths
213-
async listFilePaths(opt_filePathRegexPattern?: string): Promise<string[]> {
214-
215-
const regExp = opt_filePathRegexPattern
216-
? new RegExp(opt_filePathRegexPattern)
217-
: null;
218-
return new Promise((resolve, reject) => {
219-
const filePaths: string[] = [];
220-
const openKeyCursorRequest = this.db.transaction([FILES_STORE_NAME], 'readonly')
221-
.objectStore(FILES_STORE_NAME)
222-
.openKeyCursor();
223-
openKeyCursorRequest.onerror = () => {
224-
console.log('IndexedDB openKeyCursor request failed. openKeyCursorRequest.error is...');
225-
console.log(openKeyCursorRequest.error);
226-
reject(new Error('IndexedDB openKeyCursor request failed.'));
227-
};
228-
openKeyCursorRequest.onsuccess = () => {
229-
const cursor = openKeyCursorRequest.result;
230-
if (cursor && cursor.key) {
231-
const filePath: string = cursor.key as string;
232-
if (!regExp || regExp.test(filePath)) {
233-
filePaths.push(filePath);
234-
}
235-
cursor.continue();
236-
} else {
237-
// The cursor is done. We have finished reading all the files.
238-
resolve(filePaths);
239-
}
240-
};
241-
});
242-
}
243-
244212
async rename(oldPath: string, newPath: string): Promise<void> {
245213
if (oldPath.endsWith('/')) {
246214
return this.renameDirectory(oldPath, newPath);

src/storage/common_storage.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@ export interface Storage {
3030

3131
list(path: string): Promise<string[]>;
3232

33-
// TODO(lizlooney): remove listFilePaths
34-
listFilePaths(opt_filePathRegexPattern?: string): Promise<string[]>;
35-
3633
rename(oldPath: string, newPath: string): Promise<void>;
3734

3835
fetchFileContentText(filePath: string): Promise<string>;

src/storage/names.ts

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,14 @@ export const CLASS_NAME_ROBOT = 'Robot';
5656
export const CLASS_NAME_TELEOP = 'Teleop';
5757

5858
// The extension of all JSON files is .json.
59-
export const JSON_FILE_EXTENSION = '.json';
59+
const JSON_FILE_EXTENSION = '.json';
6060

6161
// The extension of a downloaded project is .blocks.
6262
export const UPLOAD_DOWNLOAD_FILE_EXTENSION = '.blocks';
6363

6464
// The file name of the project info file.
6565
const PROJECT_INFO_FILE_NAME = 'project.info.json';
6666

67-
// The file name of the project info file.
68-
const ROBOT_MODULE_FILE_NAME = 'Robot.robot.json';
69-
7067
// A project name starts with an uppercase letter, followed by alphanumeric characters.
7168
const REGEX_PROJECT_NAME_PART = '[A-Z][A-Za-z0-9]*';
7269

@@ -81,9 +78,9 @@ const REGEX_MODULE_TYPE_PART = '\.(robot|mechanism|opmode)';
8178

8279
export const PROJECTS_DIRECTORY_PATH = '/projects/';
8380

84-
// This regex is used to extract the project name and file name from a file path.
81+
// This regex is used to extract the project name from a file path.
8582
const REGEX_FILE_PATH = '^' + escapeRegExp(PROJECTS_DIRECTORY_PATH) +
86-
'(' + REGEX_PROJECT_NAME_PART + ')/(.*' + escapeRegExp(JSON_FILE_EXTENSION) + ')$';
83+
'(' + REGEX_PROJECT_NAME_PART + ')/.*' + escapeRegExp(JSON_FILE_EXTENSION) + '$';
8784

8885
// This regex is used to extract the class name from a module path.
8986
const REGEX_MODULE_PATH = '^' + escapeRegExp(PROJECTS_DIRECTORY_PATH) +
@@ -192,18 +189,6 @@ export function getProjectName(filePath: string): string {
192189
return result[1];
193190
}
194191

195-
/**
196-
* Returns the file name for given file path.
197-
*/
198-
export function getFileName(filePath: string): string {
199-
const regex = new RegExp(REGEX_FILE_PATH);
200-
const result = regex.exec(filePath)
201-
if (!result) {
202-
throw new Error('Unable to extract the file name from "' + filePath + '"');
203-
}
204-
return result[2];
205-
}
206-
207192
/**
208193
* Returns true if the given file name is a valid module file name.
209194
*/

0 commit comments

Comments
 (0)