Skip to content

Commit

Permalink
feat: Add scripts to remove the JSON persistent storage.
Browse files Browse the repository at this point in the history
  • Loading branch information
pawelsa committed May 23, 2026
1 parent fa0ae48 commit ac3dc3c
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
26 changes: 26 additions & 0 deletions delete-storage.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
@echo off
REM delete-storage.bat
REM Deletes the Millions JSON storage for resetting app state
REM The storage file location is chosen by StorageFile.java

SET "STORAGE_FOLDER_NAME=Millions"
SET "STORAGE_FILE=storage.json"

REM Use %APPDATA% if set, otherwise fallback to %USERPROFILE%
IF DEFINED APPDATA (
SET "STORAGE_DIR=%APPDATA%\%STORAGE_FOLDER_NAME%"
) ELSE (
SET "STORAGE_DIR=%USERPROFILE%\%STORAGE_FOLDER_NAME%"
)

SET "STORAGE_PATH=%STORAGE_DIR%\%STORAGE_FILE%"

IF EXIST "%STORAGE_PATH%" (
ECHO Deleting storage at %STORAGE_PATH% ...
DEL /F "%STORAGE_PATH%"
ECHO Storage deleted.
) ELSE (
ECHO Storage not found at %STORAGE_PATH%.
)

PAUSE
42 changes: 42 additions & 0 deletions delete-storage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env bash
# delete-storage.sh
# Deletes the Millions JSON storage for resetting app state
# The storage file location is chosen by StorageFile.java

set -e

STORAGE_FOLDER_NAME="Millions"
STORAGE_FILE="storage.json"

OS=$(uname | tr '[:upper:]' '[:lower:]')
HOME_DIR="$HOME"

# Determine database folder path based on OS
if [[ "$OS" == *"darwin"* ]]; then
# macOS
STORAGE_DIR="$HOME_DIR/Library/Application Support/$STORAGE_FOLDER_NAME"
elif [[ "$OS" == *"linux"* ]]; then
# Linux / Unix
STORAGE_DIR="$HOME_DIR/.local/share/$STORAGE_FOLDER_NAME"
elif [[ "$OS" == *"mingw"* || "$OS" == *"cygwin"* || "$OS" == *"msys"* ]]; then
# Windows (Git Bash, Cygwin, MSYS)
if [[ -n "$APPDATA" ]]; then
STORAGE_DIR="$APPDATA/$STORAGE_FOLDER_NAME"
else
STORAGE_DIR="$HOME_DIR/$STORAGE_FOLDER_NAME"
fi
else
echo "Unsupported OS: $OS"
exit 1
fi

STORAGE_PATH="$STORAGE_DIR/$STORAGE_FILE"

if [[ -f "$STORAGE_PATH" ]]; then
echo "Deleting storage at $STORAGE_PATH ..."
rm "$STORAGE_PATH"
echo "Storage deleted."
else
echo "Storage not found at $STORAGE_PATH"
fi

0 comments on commit ac3dc3c

Please sign in to comment.