π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
add userCacheDirectory in electron store
Abhinav680a8fd0563f
diff --git a/src/api/cache.ts b/src/api/cache.tsindex f2131f538a..35b63c58bc 100644--- a/src/api/cache.ts+++ b/src/api/cache.ts@@ -6,7 +6,7 @@ import { DiskCache } from '../services/diskCache';const ENTE_CACHE_DIR_NAME = 'ente';const getCacheDir = async () => {- const customCacheDir = await getCustomCacheDirectory();+ const customCacheDir = await getUserCacheDirectory();if (customCacheDir && existsSync(customCacheDir)) {return customCacheDir;}@@ -41,12 +41,10 @@ export async function deleteDiskCache(cacheName: string) {}}-export async function setCustomCacheDirectory(- directory: string-): Promise<void> {- await ipcRenderer.invoke('set-custom-cache-directory', directory);+export async function setUserCacheDirectory(directory: string): Promise<void> {+ await ipcRenderer.invoke('set-user-cache-directory', directory);}-export async function getCustomCacheDirectory(): Promise<string> {- return await ipcRenderer.invoke('get-custom-cache-directory');+export async function getUserCacheDirectory(): Promise<string> {+ return await ipcRenderer.invoke('get-user-cache-directory');}diff --git a/src/preload.ts b/src/preload.tsindex 3dbc501b65..73ea3dba1d 100644--- a/src/preload.ts+++ b/src/preload.ts@@ -29,8 +29,8 @@ import { clearElectronStore } from './api/electronStore';import {openDiskCache,deleteDiskCache,- setCustomCacheDirectory,- getCustomCacheDirectory,+ setUserCacheDirectory,+ getUserCacheDirectory,} from './api/cache';import {checkExistsAndCreateDir,@@ -124,6 +124,6 @@ windowObject['ElectronAPIs'] = {computeImageEmbedding,computeTextEmbedding,getPlatform,- setCustomCacheDirectory,- getCustomCacheDirectory,+ setUserCacheDirectory,+ getUserCacheDirectory,};diff --git a/src/services/userPreference.ts b/src/services/userPreference.tsindex 6062a7679a..bf0890d8d9 100644--- a/src/services/userPreference.ts+++ b/src/services/userPreference.ts@@ -40,10 +40,10 @@ export function clearMuteUpdateNotificationVersion() {userPreferencesStore.delete('muteUpdateNotificationVersion');}-export function setCustomCacheDirectory(directory: string) {- userPreferencesStore.set('customCacheDirectory', directory);+export function setUserCacheDirectory(directory: string) {+ userPreferencesStore.set('userCacheDirectory', directory);}-export function getCustomCacheDirectory() {- return userPreferencesStore.get('customCacheDirectory');+export function getUserCacheDirectory() {+ return userPreferencesStore.get('userCacheDirectory');}diff --git a/src/stores/userPreferences.store.ts b/src/stores/userPreferences.store.tsindex 89556a3a01..9831d68257 100644--- a/src/stores/userPreferences.store.ts+++ b/src/stores/userPreferences.store.ts@@ -14,6 +14,9 @@ const userPreferencesSchema: Schema<UserPreferencesType> = {optOutOfCrashReports: {type: 'boolean',},+ userCacheDirectory: {+ type: 'string',+ },};export const userPreferencesStore = new Store({diff --git a/src/types/index.ts b/src/types/index.tsindex c4381c6197..404c9b84a2 100644--- a/src/types/index.ts+++ b/src/types/index.ts@@ -59,6 +59,7 @@ export interface UserPreferencesType {skipAppVersion: string;muteUpdateNotificationVersion: string;optOutOfCrashReports: boolean;+ userCacheDirectory: string;}export interface AppUpdateInfo {diff --git a/src/utils/ipcComms.ts b/src/utils/ipcComms.tsindex d6d1e7dcdb..bdc1b847be 100644--- a/src/utils/ipcComms.ts+++ b/src/utils/ipcComms.ts@@ -26,8 +26,8 @@ import {import { deleteTempFile, runFFmpegCmd } from '../services/ffmpeg';import { generateTempFilePath } from './temp';import {- getCustomCacheDirectory,- setCustomCacheDirectory,+ getUserCacheDirectory,+ setUserCacheDirectory,setOptOutOfCrashReports,} from '../services/userPreference';import { updateOptOutOfCrashReports } from '../main';@@ -185,11 +185,11 @@ export default function setupIpcComs(return getPlatform();});- ipcMain.handle('set-custom-cache-directory', (_, directory: string) => {- setCustomCacheDirectory(directory);+ ipcMain.handle('set-user-cache-directory', (_, directory: string) => {+ setUserCacheDirectory(directory);});- ipcMain.handle('get-custom-cache-directory', async () => {- return getCustomCacheDirectory();+ ipcMain.handle('get-user-cache-directory', async () => {+ return getUserCacheDirectory();});}