Исправление некоторых багов
This commit is contained in:
32
api.go
32
api.go
@@ -440,23 +440,23 @@ func (a *Agate) GetRemoteSnapshot(ctx context.Context, address string, snapshotI
|
||||
|
||||
if localParentID != "" {
|
||||
if err := a.manager.ExtractSnapshot(ctx, localParentID, newSnapshotDir, false); err != nil {
|
||||
a.options.Logger.Printf("Warning: failed to extract local parent snapshot %s: %v", localParentID, err)
|
||||
} else {
|
||||
localParentSnap, err := a.GetSnapshotDetails(ctx, localParentID)
|
||||
if err != nil {
|
||||
a.options.Logger.Printf("Warning: failed to get local parent details %s: %v", localParentID, err)
|
||||
} else {
|
||||
remoteFilesMap := make(map[string]struct{})
|
||||
for _, f := range remoteSnapshot.Files {
|
||||
remoteFilesMap[f.Path] = struct{}{}
|
||||
}
|
||||
return fmt.Errorf("failed to extract local parent snapshot %s for diff application: %w", localParentID, err)
|
||||
}
|
||||
|
||||
for _, localFile := range localParentSnap.Files {
|
||||
if _, exists := remoteFilesMap[localFile.Path]; !exists {
|
||||
pathToDelete := filepath.Join(newSnapshotDir, localFile.Path)
|
||||
if err := os.RemoveAll(pathToDelete); err != nil {
|
||||
a.options.Logger.Printf("Warning: failed to delete file %s during diff apply: %v", pathToDelete, err)
|
||||
}
|
||||
localParentSnap, err := a.GetSnapshotDetails(ctx, localParentID)
|
||||
if err != nil {
|
||||
a.options.Logger.Printf("Warning: failed to get local parent details %s: %v", localParentID, err)
|
||||
} else {
|
||||
remoteFilesMap := make(map[string]struct{})
|
||||
for _, f := range remoteSnapshot.Files {
|
||||
remoteFilesMap[f.Path] = struct{}{}
|
||||
}
|
||||
|
||||
for _, localFile := range localParentSnap.Files {
|
||||
if _, exists := remoteFilesMap[localFile.Path]; !exists {
|
||||
pathToDelete := filepath.Join(newSnapshotDir, localFile.Path)
|
||||
if err := os.RemoveAll(pathToDelete); err != nil {
|
||||
a.options.Logger.Printf("Warning: failed to delete file %s during diff apply: %v", pathToDelete, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user