fix check, change doesFileExists to doesPathExists

This commit is contained in:
Abhinav 2022-06-23 15:38:19 +05:30
parent feb20afa9e
commit fdae6bd9f0
2 changed files with 8 additions and 8 deletions

View file

@ -1,7 +1,7 @@
import {} from './common';
import {
createDirectory,
doesFileExists,
doesPathExists,
readTextFile,
renameDirectory,
writeFile,
@ -11,11 +11,11 @@ import { ipcRenderer } from 'electron';
import { logError } from '../utils/logging';
export const exists = (path: string) => {
return doesFileExists(path);
return doesPathExists(path);
};
export const checkExistsAndCreateCollectionDir = async (dirPath: string) => {
if (!doesFileExists(dirPath)) {
if (!doesPathExists(dirPath)) {
await createDirectory(dirPath);
}
};
@ -24,7 +24,7 @@ export const checkExistsAndRename = async (
oldDirPath: string,
newDirPath: string
) => {
if (doesFileExists(oldDirPath)) {
if (doesPathExists(oldDirPath)) {
await renameDirectory(oldDirPath, newDirPath);
}
};
@ -42,7 +42,7 @@ export const saveFileToDisk = async (path: string, fileData: any) => {
export const getExportRecord = async (filePath: string) => {
try {
if (!(await doesFileExists(filePath))) {
if (!(await doesPathExists(filePath))) {
return null;
}
const recordFile = await readTextFile(filePath);

View file

@ -155,11 +155,11 @@ export async function doesFolderExists(dirPath: string) {
.catch(() => false);
}
export async function doesFileExists(dirPath: string) {
export async function doesPathExists(dirPath: string) {
return await fs
.stat(dirPath)
.then((stats) => {
return stats.isFile();
.then((stats: fs.Stats) => {
return stats.isFile() || stats.isDirectory();
})
.catch(() => false);
}