修复部署验收回归问题
This commit is contained in:
1 parent
b78003b33f
commit
35be101cc2
3 files changed
+61
-27
No files matched your search
@@ -338,7 +338,7 @@ func (s *TransactionStore) Recover() error {
|
||||
return ErrTransactionPhase
|
||||
}
|
||||
}
|
||||
return nil
|
||||
return cleanupEmptyTransactionStaging(transactions)
|
||||
}
|
||||
|
||||
func (s *TransactionStore) beforePhase(phase TransactionPhase) error {
|
||||
@@ -619,6 +619,31 @@ func secureTransactionStagingDirectory(transactions string) (string, error) {
|
||||
return directory, nil
|
||||
}
|
||||
|
||||
func cleanupEmptyTransactionStaging(transactions string) error {
|
||||
directory := filepath.Join(filepath.Dir(transactions), "transaction-staging")
|
||||
info, err := os.Lstat(directory)
|
||||
if os.IsNotExist(err) {
|
||||
return nil
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if info.Mode()&os.ModeSymlink != 0 || !info.IsDir() {
|
||||
return ErrTransactionInvalid
|
||||
}
|
||||
entries, err := os.ReadDir(directory)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(entries) != 0 {
|
||||
return nil
|
||||
}
|
||||
if err := os.Remove(directory); err != nil {
|
||||
return err
|
||||
}
|
||||
return atomicfile.SyncDirectory(filepath.Dir(transactions))
|
||||
}
|
||||
|
||||
func validateTransactionDirectory(directory string) error {
|
||||
if err := ensureDirectory(directory); err != nil {
|
||||
return err
|
||||
|
||||
Reference in new issue
Block a user