Documentation
¶
Index ¶
- func HasPrivateFileWriteCommitOutcome(err error) bool
- func MustPreserveReplacementSource(err error) bool
- func ReplaceFile(sourcePath, targetPath string) error
- func ReplaceFileWithBackup(sourcePath, targetPath, _ string) error
- func UserDataFile(appName, filename string) (string, error)
- func UserDataSubdir(appName string) (string, error)
- func WritePrivateFile(path string, body []byte, mode os.FileMode) error
- func WritePrivateFileWithSyncParentForTest(path string, body []byte, mode os.FileMode, syncParent func(string) error) error
- func WritePrivateFileWithUnresolvedReplacementForTest(path string, body []byte, mode os.FileMode, cause error) error
- func WriteSecretFile(path string, body []byte, force bool) (resultErr error)
- type ReplacementSourcePreservationError
- type SecretFileWriteError
- type WriteCommitOutcome
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HasPrivateFileWriteCommitOutcome ¶ added in v0.4.0
HasPrivateFileWriteCommitOutcome 报告错误是否由 private writer 标注 outcome。
func MustPreserveReplacementSource ¶ added in v0.4.0
MustPreserveReplacementSource 报告 wrapped/joined error 是否要求调用方保留 source。
func ReplaceFile ¶
ReplaceFile 用源文件替换目标路径;调用方应确保源文件已完整写入并关闭。
func ReplaceFileWithBackup ¶
ReplaceFileWithBackup 与 Windows 的 API 形状一致;非 Windows 的 rename 已原子替换目标, 不会产生旧文件备份。
func UserDataFile ¶ added in v0.6.0
UserDataFile 返回应用数据目录内的指定文件路径。
func UserDataSubdir ¶ added in v0.6.0
UserDataSubdir 返回当前用户 home 下的应用数据目录。所有平台均使用相同的 `~/APP_NAME` 语义;Windows 上的 home 由 os.UserHomeDir 解析为用户 profile。
func WritePrivateFileWithSyncParentForTest ¶ added in v0.4.0
func WritePrivateFileWithSyncParentForTest(path string, body []byte, mode os.FileMode, syncParent func(string) error) error
WritePrivateFileWithSyncParentForTest 使用真实 private writer,仅替换目录同步边界。 它用于稳定复现 replacement 已提交后的 durability failure;生产代码不得调用。
func WritePrivateFileWithUnresolvedReplacementForTest ¶ added in v0.4.0
func WritePrivateFileWithUnresolvedReplacementForTest(path string, body []byte, mode os.FileMode, cause error) error
WritePrivateFileWithUnresolvedReplacementForTest 使用真实 staging,并模拟旧目标已 移入 recovery backup、目标恢复未决的 replacement outcome。新旧 recovery artifacts 都必须保留,生产代码不得调用。
Types ¶
type ReplacementSourcePreservationError ¶ added in v0.4.0
type ReplacementSourcePreservationError interface {
error
PreserveReplacementSource()
}
ReplacementSourcePreservationError 标记一次替换错误后的 source 仍是恢复材料。 调用方必须保留 source,直至人工或后续恢复流程完成。
type SecretFileWriteError ¶ added in v0.4.0
type SecretFileWriteError struct {
// contains filtered or unexported fields
}
SecretFileWriteError 隐藏任意目标路径及底层可能携带的路径,同时保留 errors.Is/As。
func (*SecretFileWriteError) CommitOutcome ¶ added in v0.4.0
func (e *SecretFileWriteError) CommitOutcome() WriteCommitOutcome
func (*SecretFileWriteError) Error ¶ added in v0.4.0
func (e *SecretFileWriteError) Error() string
func (*SecretFileWriteError) Unwrap ¶ added in v0.4.0
func (e *SecretFileWriteError) Unwrap() error
type WriteCommitOutcome ¶ added in v0.4.0
type WriteCommitOutcome string
WriteCommitOutcome 标识 private-file replacement 是否已经提交到目标路径。
const ( WriteCommitOutcomeUnknown WriteCommitOutcome = "unknown" WriteCommitOutcomeNotCommitted WriteCommitOutcome = "not_committed" WriteCommitOutcomeCommitted WriteCommitOutcome = "committed" )
func PrivateFileWriteCommitOutcome ¶ added in v0.4.0
func PrivateFileWriteCommitOutcome(err error) WriteCommitOutcome
PrivateFileWriteCommitOutcome 返回 private writer 错误的稳定 commit outcome。 非本 writer 产生的错误返回 unknown。
func SecretFileWriteCommitOutcome ¶ added in v0.4.0
func SecretFileWriteCommitOutcome(err error) WriteCommitOutcome
SecretFileWriteCommitOutcome 返回 export writer 对目标路径提交状态的判断。