Support comment reply.

This commit is contained in:
2025-07-04 15:24:23 +08:00
parent 1f22367cc4
commit 54ab93ea7b
11 changed files with 243 additions and 92 deletions

View File

@@ -1,6 +1,7 @@
package utils
import (
"errors"
"os"
"runtime"
)
@@ -19,7 +20,16 @@ func GetStoragePath() string {
}
if _, err := os.Stat(path); os.IsNotExist(err) {
if err := os.MkdirAll(path, os.ModePerm); err != nil {
panic("failed to create storage directory")
if errors.Is(err, os.ErrPermission) {
// Fallback to home directory if permission is denied
userDir, _ := os.UserHomeDir()
path = userDir + "/.nysoure"
if _, err := os.Stat(path); os.IsNotExist(err) {
if err := os.MkdirAll(path, os.ModePerm); err != nil {
panic("Failed to create storage directory: " + err.Error())
}
}
}
}
}
return path