diff --git a/src/app/shared/system-service/file.service.ts b/src/app/shared/system-service/file.service.ts index be2cbcf3..643e062d 100644 --- a/src/app/shared/system-service/file.service.ts +++ b/src/app/shared/system-service/file.service.ts @@ -88,21 +88,6 @@ export class FileService{ return iconPath; } - public async checkIfExistsAsync(dirPath:string):Promise{ - await this.initBrowserFsAsync(); - return new Promise((resolve) =>{ - this._fileSystem.exists(`${dirPath}`, (exits) =>{ - if(exits){ - console.log('checkIfExistsAsync :Already exists',exits); - resolve(true) - }else{ - console.log('checkIfExistsAsync :Does not exists',exits); - resolve(false); - } - }); - }) - } - public async checkIfDirectory(path: string):Promise { await this.initBrowserFsAsync(); @@ -119,6 +104,21 @@ export class FileService{ }); } + public async checkIfExistsAsync(dirPath:string):Promise{ + await this.initBrowserFsAsync(); + return new Promise((resolve) =>{ + this._fileSystem.exists(`${dirPath}`, (exits) =>{ + if(exits){ + console.log('checkIfExistsAsync :Already exists',exits); + resolve(true) + }else{ + console.log('checkIfExistsAsync :Does not exists',exits); + resolve(false); + } + }); + }) + } + public async copyFileAsync(sourcepath:string, destinationpath:string):Promise{ await this.initBrowserFsAsync(); @@ -274,19 +274,19 @@ export class FileService{ return this._directoryFileEntires; } - public async getFilesFromDirectoryAsync(dirPath:string):Promise{ + public async getFilesPathsFromDirectoryAsync(dirPath:string):Promise{ await this.initBrowserFsAsync(); - return new Promise((resolve, reject) => { + return new Promise((resolve, reject) => { const fs = this._fileSystem; const interval = setInterval(() => { fs.readdir(dirPath, function(err, files) { if(err){ console.log("Oops! a boo boo happened, filesystem wasn't ready:", err); - reject(err); + reject([]); }else{ clearInterval(interval); - resolve(files); + resolve(files || []); } }); }, this.SECONDS_DELAY); diff --git a/src/app/system-apps/fileexplorer/fileexplorer.component.ts b/src/app/system-apps/fileexplorer/fileexplorer.component.ts index 2675bec8..c7a35b39 100644 --- a/src/app/system-apps/fileexplorer/fileexplorer.component.ts +++ b/src/app/system-apps/fileexplorer/fileexplorer.component.ts @@ -626,7 +626,7 @@ export class FileExplorerComponent implements BaseComponent, OnInit, AfterViewIn private async loadFilesInfoAsync():Promise{ this.files = []; this._fileService.resetDirectoryFiles(); - const dirFileEntries = await this._fileService.getFilesFromDirectoryAsync(this.directory) as []; + const dirFileEntries = await this._fileService.getFilesPathsFromDirectoryAsync(this.directory); this._directoryFilesEntires = this._fileService.getFileEntriesFromDirectory(dirFileEntries,this.directory); for(let i = 0; i < dirFileEntries.length; i++){ diff --git a/src/app/system-apps/filemanager/filemanager.component.ts b/src/app/system-apps/filemanager/filemanager.component.ts index 2c549106..e31d7ab2 100644 --- a/src/app/system-apps/filemanager/filemanager.component.ts +++ b/src/app/system-apps/filemanager/filemanager.component.ts @@ -153,7 +153,7 @@ export class FileManagerComponent implements BaseComponent, OnInit, AfterViewIni private async loadFilesInfoAsync():Promise{ this.files = []; this._fileService.resetDirectoryFiles(); - const dirFileEntries = await this._fileService.getFilesFromDirectoryAsync(this.directory) as []; + const dirFileEntries = await this._fileService.getFilesPathsFromDirectoryAsync(this.directory); this._directoryFilesEntires = this._fileService.getFileEntriesFromDirectory(dirFileEntries,this.directory); for(let i = 0; i < dirFileEntries.length; i++){ diff --git a/src/app/system-apps/photoviewer/photoviewer.component.ts b/src/app/system-apps/photoviewer/photoviewer.component.ts index de4a3db8..4e53c64a 100644 --- a/src/app/system-apps/photoviewer/photoviewer.component.ts +++ b/src/app/system-apps/photoviewer/photoviewer.component.ts @@ -169,7 +169,7 @@ export class PhotoViewerComponent implements BaseComponent, OnInit, OnDestroy, A // else, go fetch. const dirPath = dirname(this.picSrc); //console.log('dirPath:', dirPath); - const pathList:string[] = await this._fileService.getFilesFromDirectoryAsync(dirPath) as string[]; + const pathList:string[] = await this._fileService.getFilesPathsFromDirectoryAsync(dirPath); //check for images for(let i = 0; i <= pathList.length - 1; i++){ diff --git a/src/app/system-apps/terminal/terminal.commands.ts b/src/app/system-apps/terminal/terminal.commands.ts index 2e355ea8..e72586f1 100644 --- a/src/app/system-apps/terminal/terminal.commands.ts +++ b/src/app/system-apps/terminal/terminal.commands.ts @@ -599,7 +599,7 @@ Mandatory argument to long options are mandotory for short options too. private async loadFilesInfoAsync(directory:string):Promise{ this.files = []; this._fileService.resetDirectoryFiles(); - const dirFileEntries = await this._fileService.getFilesFromDirectoryAsync(directory) as []; + const dirFileEntries = await this._fileService.getFilesPathsFromDirectoryAsync(directory); this._directoryFilesEntires = this._fileService.getFileEntriesFromDirectory(dirFileEntries,directory); for(let i = 0; i < dirFileEntries.length; i++){