实现 StartUpgrade
This commit is contained in:
@@ -45,7 +45,7 @@ func (ct CompressionType) Matches(filename string) bool {
|
||||
// 此函数假定它拥有对 destPath 的完全控制权,并会在失败时将其彻底删除。
|
||||
func DecompressAtomic(sourcePath, destPath string) error {
|
||||
action := func() error {
|
||||
return decompress(sourcePath, destPath)
|
||||
return Decompress(sourcePath, destPath)
|
||||
}
|
||||
|
||||
onRollback := func(err error) {
|
||||
@@ -55,9 +55,9 @@ func DecompressAtomic(sourcePath, destPath string) error {
|
||||
return ExecuteWithLock(action, onRollback)
|
||||
}
|
||||
|
||||
// decompress 是解压操作的核心实现,它本身不是线程安全的,也不提供回滚。
|
||||
// Decompress 是解压操作的核心实现,它本身不是线程安全的,也不提供回滚。
|
||||
// 它应该被 DecompressAtomic 或其他调用方在 ExecuteWithLock 的回调中执行。
|
||||
func decompress(sourcePath, destPath string) error {
|
||||
func Decompress(sourcePath, destPath string) error {
|
||||
// 确保目标目录存在
|
||||
if err := os.MkdirAll(destPath, 0755); err != nil {
|
||||
return fmt.Errorf("创建目标目录 %s 失败: %w", destPath, err)
|
||||
|
||||
Reference in New Issue
Block a user