mirror of
https://github.com/wgh136/nysoure.git
synced 2025-09-27 12:17:24 +00:00
Support comment reply.
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user