MCPcopy Create free account
hub / github.com/Prejudice-Studio/Twilight / regCodeRandomAlgorithmOptions

Function regCodeRandomAlgorithmOptions

internal/api/config_admin.go:863–884  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

861 }
862 }
863 if cfg.SystemUpdateRepoURL != protected {
864 return "", errProtectedRepoURL
865 }
866 return content, nil
867}
868
869func writeConfigBackupBytes(configFile, backupDir string, content []byte) (store.BackupInfo, error) {
870 if len(content) == 0 {
871 return store.BackupInfo{}, store.ErrNotFound
872 }
873 if err := os.MkdirAll(backupDir, 0o700); err != nil {
874 return store.BackupInfo{}, err
875 }
876 now := time.Now().UTC()
877 base := strings.TrimSuffix(filepath.Base(configFile), filepath.Ext(configFile))
878 if base == "" || base == "." {
879 base = "config"
880 }
881 name := base + "_" + now.Format("20060102_150405") + "_" + strconv.FormatInt(now.UnixNano()%1e9, 10) + ".toml"
882 path := filepath.Join(backupDir, name)
883 if err := os.WriteFile(path, content, 0o600); err != nil {
884 return store.BackupInfo{}, err
885 }
886 return store.BackupInfo{Name: name, Path: path, Size: int64(len(content)), CreatedAt: now.Unix()}, nil
887}

Callers 2

configSectionDefsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected