Skip to content

Commit

Permalink
fix: logout, disallow vd path as cache
Browse files Browse the repository at this point in the history
  • Loading branch information
Dwynr committed Aug 28, 2024
1 parent ca18bc3 commit 25e7076
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
9 changes: 8 additions & 1 deletion src/components/mounts/virtualDrive/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,12 @@ export const VirtualDrive = memo(() => {
return
}

if (path.paths[0].startsWith(desktopConfig.virtualDriveConfig.mountPoint)) {
errorToast(t("mounts.virtualDrive.errors.invalidCachePath"))

return
}

if (!(await window.desktopAPI.isPathReadable(path.paths[0])) || !(await window.desktopAPI.isPathWritable(path.paths[0]))) {
errorToast(t("mounts.virtualDrive.errors.cachePathNotReadableWritable"))

Expand Down Expand Up @@ -506,7 +512,8 @@ export const VirtualDrive = memo(() => {
setDesktopConfig,
setEnablingVirtualDrive,
t,
cacheSizeQuery
cacheSizeQuery,
desktopConfig.virtualDriveConfig.mountPoint
])

const onReadOnlyChange = useCallback(
Expand Down
22 changes: 11 additions & 11 deletions src/lib/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,17 @@ export async function setup(config?: FilenSDKConfig, connectToSocket: boolean =
* @returns {Promise<void>}
*/
export async function logout(): Promise<void> {
await clearLocalForage()

if (IS_DESKTOP) {
await Promise.all([
window.desktopAPI.stopS3Server(),
window.desktopAPI.stopWebDAVServer(),
window.desktopAPI.stopVirtualDrive(),
window.desktopAPI.stopSync()
])
}

const cookieConsent = window.localStorage.getItem("cookieConsent")
const defaultNoteType = window.localStorage.getItem("defaultNoteType")
const videoPlayerVolume = window.localStorage.getItem("videoPlayerVolume")
Expand Down Expand Up @@ -156,18 +167,7 @@ export async function logout(): Promise<void> {
window.localStorage.setItem("i18nextLng", i18nextLng)
}

await clearLocalForage()

if (IS_DESKTOP) {
await Promise.all([
window.desktopAPI.stopS3Server(),
window.desktopAPI.stopWebDAVServer(),
window.desktopAPI.stopVirtualDrive(),
window.desktopAPI.stopSync()
])

await new Promise<void>(resolve => setTimeout(resolve, 1000))

await window.desktopAPI.restart()
} else {
window.location.reload()
Expand Down

0 comments on commit 25e7076

Please sign in to comment.