@@ -30,6 +30,7 @@ import { useHardware } from '@/hooks/useHardware'
3030import LanguageSwitcher from '@/containers/LanguageSwitcher'
3131import { PlatformFeatures } from '@/lib/platform/const'
3232import { PlatformFeature } from '@/lib/platform/types'
33+ import { isRootDir } from '@/utils/path'
3334
3435// eslint-disable-next-line @typescript-eslint/no-explicit-any
3536export const Route = createFileRoute ( route . settings . general as any ) ( {
@@ -73,6 +74,11 @@ function General() {
7374 } , [ serviceHub ] )
7475
7576 const resetApp = async ( ) => {
77+ // Prevent resetting if data folder is root directory
78+ if ( isRootDir ( janDataFolder ?? '/' ) ) {
79+ toast . error ( t ( 'settings:general.couldNotResetRootDirectory' ) )
80+ return
81+ }
7682 pausePolling ( )
7783 // TODO: Loading indicator
7884 await serviceHub . app ( ) . factoryReset ( )
@@ -117,6 +123,9 @@ function General() {
117123 serviceHub . events ( ) . emit ( SystemEvent . KILL_SIDECAR )
118124 setTimeout ( async ( ) => {
119125 try {
126+ // Prevent relocating to root directory (e.g., C:\ or D:\ on Windows, / on Unix)
127+ if ( isRootDir ( selectedNewPath ) )
128+ throw new Error ( t ( 'settings:general.couldNotRelocateToRoot' ) )
120129 await serviceHub . app ( ) . relocateJanDataFolder ( selectedNewPath )
121130 setJanDataFolder ( selectedNewPath )
122131 // Only relaunch if relocation was successful
0 commit comments