Skip to content

Commit

Permalink
Revert "chore: update"
Browse files Browse the repository at this point in the history
This reverts commit 73ec907.
  • Loading branch information
hyoban committed Jan 22, 2025
1 parent 73ec907 commit 8a13db9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions apps/main/src/lib/cleaner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { logger } from "~/logger"
import { getMainWindow } from "~/window"

import { t } from "./i18n"
import { store } from "./store"
import { store, StoreKey } from "./store"

const require = createRequire(import.meta.url)
const fastFolderSize = require("fast-folder-size") as any as typeof import("fast-folder-size")
Expand Down Expand Up @@ -101,7 +101,7 @@ export const clearCacheCronJob = () => {
}
timer = setInterval(
async () => {
const hasLimit = store.get("cacheSizeLimit")
const hasLimit = store.get(StoreKey.CacheSizeLimit)

if (!hasLimit) {
return
Expand Down
4 changes: 4 additions & 0 deletions apps/main/src/lib/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,7 @@ type StoreData = {
} | null
}
export const store = new Store<StoreData>({ name: "db" })

export enum StoreKey {
CacheSizeLimit = "cacheSizeLimit",
}
8 changes: 4 additions & 4 deletions apps/main/src/tipc/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { app, BrowserWindow, clipboard, dialog, shell } from "electron"

import { registerMenuAndContextMenu } from "~/init"
import { clearAllData, getCacheSize } from "~/lib/cleaner"
import { store } from "~/lib/store"
import { store, StoreKey } from "~/lib/store"
import { registerAppTray } from "~/lib/tray"
import { logger, revealLogFile } from "~/logger"
import { cleanupOldRender, loadDynamicRenderEntry } from "~/updater/hot-updater"
Expand Down Expand Up @@ -290,7 +290,7 @@ ${content}
shell.openPath(dir)
}),
getCacheLimit: t.procedure.action(async () => {
return store.get("cacheSizeLimit")
return store.get(StoreKey.CacheSizeLimit)
}),

clearCache: t.procedure.action(async () => {
Expand Down Expand Up @@ -318,9 +318,9 @@ ${content}
limitCacheSize: t.procedure.input<number>().action(async ({ input }) => {
logger.info("set limitCacheSize", input)
if (input === 0) {
store.delete("cacheSizeLimit")
store.delete(StoreKey.CacheSizeLimit)
} else {
store.set("cacheSizeLimit", input)
store.set(StoreKey.CacheSizeLimit, input)
}
}),

Expand Down

0 comments on commit 8a13db9

Please sign in to comment.