From 2fe1e8b2fe102f128721f150e54881f11a919c29 Mon Sep 17 00:00:00 2001 From: yami Date: Sat, 15 Jul 2023 03:42:00 +0530 Subject: [PATCH] added custom temp folder --- changelog.md | 32 +++++++++++++----- electron/main.ts | 11 +++++++ src/Components/Settings.tsx | 65 +++++++++++++++++++++++++++++++++++++ 3 files changed, 99 insertions(+), 9 deletions(-) diff --git a/changelog.md b/changelog.md index 00873a6..e240e3d 100644 --- a/changelog.md +++ b/changelog.md @@ -2,18 +2,32 @@ **Due to release changes, existing users (v2.11.5 and below) might need to manually update the app.** - +- Option to hide extra data when hovering bookmark/history. Added "path" to extra data. +- Double click in center of screen to enter zen mode. +- Auto refresh reader side-list option. +- Custom temp folder. Might improve extracting speed in some cases. ## Changed -- UI Changes in settings. -- Reverted theme selector. -- Moved force low brightness to other settings. - - +- UI Changes. + - Symmetric theme selector and more. + - Slider/range UI change. + - Fade and scale in effect on anilist popups. +- Moved file saving to backend, single handler. +- Moved un-zipper to backend. +- Don't show variable same as property name when linking in theme maker. +- Issue link in settings. +- Replaced RGB sliders in "color filters" with color input. +- Show EPUB chapter name on title when "Epub : Load By Chapter" selected. +- Show image count instead of "No Directories" on home locations tab. + +## Fixed + +- Multiple settings rewrite on opening reader. +- EPUB progress saving issue, maybe. #134. +- EPUB chapter not auto focusing when reading in zen mode. #177. +- Error after refreshing reader side-list and changing chapter if any folder is changed in default location. --- diff --git a/electron/main.ts b/electron/main.ts index ffa59e2..734aa00 100644 --- a/electron/main.ts +++ b/electron/main.ts @@ -25,6 +25,11 @@ if (IS_PORTABLE) { ////18/05/23 - decided to not use it anymore as it make scrolling laggy if (fs.existsSync(path.join(app.getPath("userData"), "DISABLE_HARDWARE_ACCELERATION"))) app.disableHardwareAcceleration(); +if (fs.existsSync(path.join(app.getPath("userData"), "TEMP_PATH"))) { + const tempPath = fs.readFileSync(path.join(app.getPath("userData"), "TEMP_PATH"), "utf-8"); + if (fs.existsSync(tempPath)) app.setPath("temp", tempPath); + else fs.rmSync(tempPath); +} // change path in `settings.tsx as well if changing log path log.transports.file.resolvePath = () => path.join(app.getPath("userData"), "logs/main.log"); @@ -394,6 +399,12 @@ const registerListener = () => { deleteOptionInExplorerMenu_epub(); }); } + ipcMain.handle("changeTempPath", (e, newPath: string) => { + app.setPath("temp", newPath); + const lockFile = path.join(app.getPath("userData"), "TEMP_PATH"); + if (newPath === process.env.TEMP && fs.existsSync(lockFile)) fs.rmSync(lockFile); + fs.writeFileSync(lockFile, newPath); + }); if (process.platform === "linux") { ipcMain.on("showInExplorer", (e, filePath) => { if (!fs.lstatSync(filePath).isDirectory()) filePath = path.dirname(filePath); diff --git a/src/Components/Settings.tsx b/src/Components/Settings.tsx index 4ce3744..a6fc955 100644 --- a/src/Components/Settings.tsx +++ b/src/Components/Settings.tsx @@ -32,6 +32,7 @@ const Settings = (): ReactElement => { const [currentTab, setCurrentTab] = useState(0); const [anilistUsername, setAnilistUsername] = useState("Error"); + const [tempFolder, setTempFolder] = useState(window.electron.app.getPath("temp")); // disabled hardware acceleration const [HAValue, setHAValue] = useState( @@ -58,6 +59,19 @@ const Settings = (): ReactElement => { } }, [isSettingOpen]); + useEffect(() => { + if (tempFolder !== window.electron.app.getPath("temp")) + try { + if (window.fs.existsSync(tempFolder)) { + window.electron.ipcRenderer.invoke("changeTempPath", tempFolder).then(() => { + window.logger.log("Temp path changed to", tempFolder); + }); + } else throw new Error("Folder does not exist : " + tempFolder); + } catch (reason) { + window.logger.error("Unable to change temp path.", reason); + } + }, [tempFolder]); + useEffect(() => { if (anilistToken) window.al.getUserName().then((name) => { @@ -1028,6 +1042,56 @@ const Settings = (): ReactElement => { +
+

Custom Temp Folder

+
+ Folder where app will extract archives or epub or render pdf. It can have big + effect on extracting speed depending on type of drive (ssd, faster drives) or + storage left (10GB+ recommended). +
Defaults to temp folder provided by OS. +
+
+ + + +
+

Other Settings

@@ -1505,6 +1569,7 @@ const Settings = (): ReactElement => { . +
  • Double click in center 20% of window to toggle zen mode.