π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Remove custom cache directory
Manav Rathieeaa5165ab35
diff --git a/desktop/src/api/cache.ts b/desktop/src/api/cache.tsindex 86ba4378c3..bf7182fad2 100644--- a/desktop/src/api/cache.ts+++ b/desktop/src/api/cache.ts@@ -5,11 +5,7 @@ import { DiskCache } from "../services/diskCache";const ENTE_CACHE_DIR_NAME = "ente";-export const getCacheDirectory = async () => {- const customCacheDir = await getCustomCacheDirectory();- if (customCacheDir && existsSync(customCacheDir)) {- return customCacheDir;- }+const getCacheDirectory = async () => {const defaultSystemCacheDir = await ipcRenderer.invoke("get-path", "cache");return path.join(defaultSystemCacheDir, ENTE_CACHE_DIR_NAME);};@@ -40,13 +36,3 @@ export async function deleteDiskCache(cacheName: string) {return false;}}--export async function setCustomCacheDirectory(- directory: string,-): Promise<void> {- await ipcRenderer.invoke("set-custom-cache-directory", directory);-}--async function getCustomCacheDirectory(): Promise<string> {- return await ipcRenderer.invoke("get-custom-cache-directory");-}diff --git a/desktop/src/preload.ts b/desktop/src/preload.tsindex f39dae0986..ec9b0d997f 100644--- a/desktop/src/preload.ts+++ b/desktop/src/preload.ts@@ -28,12 +28,7 @@*/import { contextBridge } from "electron";-import {- deleteDiskCache,- getCacheDirectory,- openDiskCache,- setCustomCacheDirectory,-} from "./api/cache";+import { deleteDiskCache, openDiskCache } from "./api/cache";import { computeImageEmbedding, computeTextEmbedding } from "./api/clip";import {getAppVersion,@@ -144,6 +139,4 @@ contextBridge.exposeInMainWorld("ElectronAPIs", {computeImageEmbedding,computeTextEmbedding,getPlatform,- getCacheDirectory,- setCustomCacheDirectory,});diff --git a/desktop/src/services/userPreference.ts b/desktop/src/services/userPreference.tsindex e3c6db2904..8074ee4def 100644--- a/desktop/src/services/userPreference.ts+++ b/desktop/src/services/userPreference.ts@@ -31,11 +31,3 @@ export function clearSkipAppVersion() {export function clearMuteUpdateNotificationVersion() {userPreferencesStore.delete("muteUpdateNotificationVersion");}--export function setCustomCacheDirectory(directory: string) {- userPreferencesStore.set("customCacheDirectory", directory);-}--export function getCustomCacheDirectory(): string {- return userPreferencesStore.get("customCacheDirectory");-}diff --git a/desktop/src/stores/userPreferences.store.ts b/desktop/src/stores/userPreferences.store.tsindex e6fec425ae..7e17182ad1 100644--- a/desktop/src/stores/userPreferences.store.ts+++ b/desktop/src/stores/userPreferences.store.ts@@ -11,9 +11,6 @@ const userPreferencesSchema: Schema<UserPreferencesType> = {muteUpdateNotificationVersion: {type: "string",},- customCacheDirectory: {- type: "string",- },};export const userPreferencesStore = new Store({diff --git a/desktop/src/types/index.ts b/desktop/src/types/index.tsindex 208983826b..87f724b58a 100644--- a/desktop/src/types/index.ts+++ b/desktop/src/types/index.ts@@ -58,7 +58,6 @@ export interface UserPreferencesType {hideDockIcon: boolean;skipAppVersion: string;muteUpdateNotificationVersion: string;- customCacheDirectory: string;}export interface AppUpdateInfo {diff --git a/desktop/src/utils/ipcComms.ts b/desktop/src/utils/ipcComms.tsindex eec644aebb..c81b2b2ce1 100644--- a/desktop/src/utils/ipcComms.ts+++ b/desktop/src/utils/ipcComms.ts@@ -27,10 +27,6 @@ import {generateImageThumbnail,} from "../services/imageProcessor";import { logErrorSentry } from "../services/sentry";-import {- getCustomCacheDirectory,- setCustomCacheDirectory,-} from "../services/userPreference";import { getPlatform } from "./common/platform";import { createWindow } from "./createWindow";import { generateTempFilePath } from "./temp";@@ -183,12 +179,4 @@ export default function setupIpcComs(ipcMain.handle("get-platform", () => {return getPlatform();});-- ipcMain.handle("set-custom-cache-directory", (_, directory: string) => {- setCustomCacheDirectory(directory);- });-- ipcMain.handle("get-custom-cache-directory", async () => {- return getCustomCacheDirectory();- });}diff --git a/web/apps/photos/src/components/Sidebar/AdvancedSettings.tsx b/web/apps/photos/src/components/Sidebar/AdvancedSettings.tsxindex 5adc0361d3..e854d70d68 100644--- a/web/apps/photos/src/components/Sidebar/AdvancedSettings.tsx+++ b/web/apps/photos/src/components/Sidebar/AdvancedSettings.tsx@@ -16,7 +16,6 @@ import isElectron from "is-electron";import { AppContext } from "pages/_app";import { ClipExtractionStatus, ClipService } from "services/clipService";import { formatNumber } from "utils/number/format";-import CacheDirectory from "./Preferences/CacheDirectory";export default function AdvancedSettings({ open, onClose, onRootClose }) {const appContext = useContext(AppContext);@@ -77,22 +76,19 @@ export default function AdvancedSettings({ open, onClose, onRootClose }) {<Box px={"8px"}><Stack py="20px" spacing="24px">{isElectron() && (- <>- <CacheDirectory />- <Box>- <MenuSectionTitle- title={t("LABS")}- icon={<ScienceIcon />}+ <Box>+ <MenuSectionTitle+ title={t("LABS")}+ icon={<ScienceIcon />}+ />+ <MenuItemGroup>+ <EnteMenuItem+ endIcon={<ChevronRight />}+ onClick={openMlSearchSettings}+ label={t("ML_SEARCH")}/>- <MenuItemGroup>- <EnteMenuItem- endIcon={<ChevronRight />}- onClick={openMlSearchSettings}- label={t("ML_SEARCH")}- />- </MenuItemGroup>- </Box>- </>+ </MenuItemGroup>+ </Box>)}<Box><MenuItemGroup>diff --git a/web/apps/photos/src/components/Sidebar/Preferences/CacheDirectory.tsx b/web/apps/photos/src/components/Sidebar/Preferences/CacheDirectory.tsxdeleted file mode 100644index be23d9cbb9..0000000000--- a/web/apps/photos/src/components/Sidebar/Preferences/CacheDirectory.tsx+++ /dev/null@@ -1,60 +0,0 @@-import ElectronAPIs from "@ente/shared/electron";-import { addLogLine } from "@ente/shared/logging";-import { logError } from "@ente/shared/sentry";-import Box from "@mui/material/Box";-import { DirectoryPath } from "components/Directory";-import { EnteMenuItem } from "components/Menu/EnteMenuItem";-import { MenuItemGroup } from "components/Menu/MenuItemGroup";-import MenuSectionTitle from "components/Menu/MenuSectionTitle";-import { t } from "i18next";-import isElectron from "is-electron";-import { useEffect, useState } from "react";-import DownloadManager from "services/download";--export default function CacheDirectory() {- const [cacheDirectory, setCacheDirectory] = useState(undefined);-- useEffect(() => {- const main = async () => {- if (isElectron()) {- const customCacheDirectory =- await ElectronAPIs.getCacheDirectory();- setCacheDirectory(customCacheDirectory);- }- };- main();- }, []);-- const handleCacheDirectoryChange = async () => {- try {- if (!isElectron()) {- return;- }- const newFolder = await ElectronAPIs.selectDirectory();- if (!newFolder) {- return;- }- addLogLine(`Export folder changed to ${newFolder}`);- await ElectronAPIs.setCustomCacheDirectory(newFolder);- setCacheDirectory(newFolder);- await DownloadManager.reloadCaches();- } catch (e) {- logError(e, "handleCacheDirectoryChange failed");- }- };-- return (- <Box>- <MenuSectionTitle title={t("CACHE_DIRECTORY")} />- <MenuItemGroup>- <EnteMenuItem- variant="path"- onClick={handleCacheDirectoryChange}- labelComponent={- <DirectoryPath width={265} path={cacheDirectory} />- }- />- </MenuItemGroup>- </Box>- );-}diff --git a/web/apps/photos/src/services/download/index.ts b/web/apps/photos/src/services/download/index.tsindex 3d71ed8ad1..1d57d468fc 100644--- a/web/apps/photos/src/services/download/index.ts+++ b/web/apps/photos/src/services/download/index.ts@@ -130,11 +130,6 @@ class DownloadManagerImpl {this.progressUpdater = progressUpdater;}- async reloadCaches() {- this.thumbnailCache = await openThumbnailCache();- this.diskFileCache = isElectron() && (await openDiskFileCache());- }-private async getCachedThumbnail(fileID: number) {try {const cacheResp: Response = await this.thumbnailCache?.match(diff --git a/web/packages/shared/electron/types.ts b/web/packages/shared/electron/types.tsindex 0273e7c659..01cfe4452e 100644--- a/web/packages/shared/electron/types.ts+++ b/web/packages/shared/electron/types.ts@@ -105,6 +105,4 @@ export interface ElectronAPIsType {) => Promise<Float32Array>;computeTextEmbedding: (model: Model, text: string) => Promise<Float32Array>;getPlatform: () => Promise<"mac" | "windows" | "linux">;- setCustomCacheDirectory: (directory: string) => Promise<void>;- getCacheDirectory: () => Promise<string>;}