mirror of
https://github.com/MengMengCode/CLICD.git
synced 2026-08-07 14:14:44 +08:00
添加了子用户列表功能
This commit is contained in:
@@ -1479,11 +1479,20 @@ func (m *Manager) DestroyContainer(id int) error {
|
||||
}
|
||||
return fmt.Errorf("container still exists after cleanup with status %s", status)
|
||||
}
|
||||
snapshotDir := filepath.Join(snapshotBaseDir(), lxcName)
|
||||
// Remove snapshot physical files (by container ID, not lxcName)
|
||||
snapshotDir := filepath.Join(snapshotBaseDir(), strconv.Itoa(id))
|
||||
if err := safePathUnder(snapshotDir, snapshotBaseDir()); err == nil {
|
||||
os.RemoveAll(snapshotDir)
|
||||
}
|
||||
|
||||
// Also remove any legacy snapshot dir that used lxcName
|
||||
legacySnapshotDir := filepath.Join(snapshotBaseDir(), lxcName)
|
||||
if legacySnapshotDir != snapshotDir {
|
||||
if err := safePathUnder(legacySnapshotDir, snapshotBaseDir()); err == nil {
|
||||
os.RemoveAll(legacySnapshotDir)
|
||||
}
|
||||
}
|
||||
|
||||
if !config.RemoveContainer(id) {
|
||||
return fmt.Errorf("container destroyed but config entry was not removed: %d", id)
|
||||
}
|
||||
|
||||
@@ -45,7 +45,8 @@ func (m *Manager) CreateSnapshot(id int, createdBy string, scheduled bool, rotat
|
||||
|
||||
now := time.Now()
|
||||
snapshotID := fmt.Sprintf("snap-%d-%s", id, now.Format("20060102150405-000000000"))
|
||||
snapshotDir := filepath.Join(snapshotBaseDir(), lxcName, snapshotID)
|
||||
// Use container ID instead of lxcName to avoid collision when containers are recreated
|
||||
snapshotDir := filepath.Join(snapshotBaseDir(), strconv.Itoa(id), snapshotID)
|
||||
if err := safePathUnder(snapshotDir, snapshotBaseDir()); err != nil {
|
||||
return config.Snapshot{}, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user