mirror of
https://codeberg.org/VnPower/PixivFE
synced 2024-12-06 19:16:23 +01:00
34 lines
783 B
Go
34 lines
783 B
Go
package audit
|
|
|
|
import (
|
|
"log"
|
|
"os"
|
|
|
|
"codeberg.org/vnpower/pixivfe/v2/config"
|
|
"codeberg.org/vnpower/pixivfe/v2/i18n"
|
|
)
|
|
|
|
var optionSaveResponse bool
|
|
var MaxRecordedCount = 0
|
|
|
|
// Init initializes the audit package and sets up response saving if enabled.
|
|
// saveResponse is passed as a boolean from main.go.
|
|
// The response save location is taken from the global configuration.
|
|
func Init(saveResponse bool) error {
|
|
optionSaveResponse = saveResponse
|
|
|
|
if !optionSaveResponse {
|
|
return nil
|
|
}
|
|
|
|
MaxRecordedCount = 128
|
|
savePath := config.GlobalConfig.ResponseSaveLocation
|
|
|
|
if err := os.MkdirAll(savePath, 0o700); err != nil {
|
|
log.Printf("Error creating response save directory: %v", err)
|
|
return i18n.Errorf("failed to create response save directory: %w", err)
|
|
}
|
|
|
|
return nil
|
|
}
|