Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

recursive: true is mkdir -p

Manav Rathib6b4ee7e3af6
diff --git a/desktop/src/api/cache.ts b/desktop/src/api/cache.ts
index c1a0b9871c..fe5f7bd932 100644
--- a/desktop/src/api/cache.ts
+++ b/desktop/src/api/cache.ts
@@ -22,9 +22,7 @@ export async function openDiskCache(
cacheLimitInBytes?: number,
) {
const cacheBucketDir = await getCacheBucketDir(cacheName);
- if (!existsSync(cacheBucketDir)) {
- await fs.mkdir(cacheBucketDir, { recursive: true });
- }
+ await fs.mkdir(cacheBucketDir, { recursive: true });
return new DiskCache(cacheBucketDir, cacheLimitInBytes);
}
diff --git a/desktop/src/preload.ts b/desktop/src/preload.ts
index b66409137a..8c717e8ab8 100644
--- a/desktop/src/preload.ts
+++ b/desktop/src/preload.ts
@@ -143,11 +143,8 @@ const writeNodeStream = async (
const exists = (path: string) => existsSync(path);
-const checkExistsAndCreateDir = async (dirPath: string) => {
- if (!existsSync(dirPath)) {
- await fs.mkdir(dirPath);
- }
-};
+const checkExistsAndCreateDir = (dirPath: string) =>
+ fs.mkdir(dirPath, { recursive: true });
const saveStreamToDisk = writeStream;
@@ -175,9 +172,7 @@ async function moveFile(
}
// check if destination folder exists
const destinationFolder = path.dirname(destinationPath);
- if (!existsSync(destinationFolder)) {
- await fs.mkdir(destinationFolder, { recursive: true });
- }
+ await fs.mkdir(destinationFolder, { recursive: true });
await fs.rename(sourcePath, destinationPath);
}
diff --git a/desktop/src/services/clipService.ts b/desktop/src/services/clipService.ts
index 145f00a4db..65b4a52bb0 100644
--- a/desktop/src/services/clipService.ts
+++ b/desktop/src/services/clipService.ts
@@ -79,10 +79,7 @@ function getModelSavePath(modelName: string) {
async function downloadModel(saveLocation: string, url: string) {
// confirm that the save location exists
const saveDir = path.dirname(saveLocation);
- if (!existsSync(saveDir)) {
- log.info("creating model save dir");
- await fs.mkdir(saveDir, { recursive: true });
- }
+ await fs.mkdir(saveDir, { recursive: true });
log.info("downloading clip model");
const res = await net.fetch(url);
if (!res.ok) throw new Error(`Failed to fetch ${url}: HTTP ${res.status}`);
diff --git a/desktop/src/utils/temp.ts b/desktop/src/utils/temp.ts
index 91496ce139..7bb20468aa 100644
--- a/desktop/src/utils/temp.ts
+++ b/desktop/src/utils/temp.ts
@@ -1,17 +1,14 @@
import { app } from "electron";
+import { existsSync } from "node:fs";
+import * as fs from "node:fs/promises";
import path from "path";
-import { existsSync, mkdir } from "promise-fs";
-
-const ENTE_TEMP_DIRECTORY = "ente";
const CHARACTERS =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
export async function getTempDirPath() {
- const tempDirPath = path.join(app.getPath("temp"), ENTE_TEMP_DIRECTORY);
- if (!existsSync(tempDirPath)) {
- await mkdir(tempDirPath);
- }
+ const tempDirPath = path.join(app.getPath("temp"), "ente");
+ await fs.mkdir(tempDirPath, { recursive: true });
return tempDirPath;
}