@@ -65,32 +65,55 @@ private static void Set(String workspacePath, ICollection<AutomationAsset> asset
65
65
66
66
if ( assetToAffect is AutomationVariable )
67
67
{
68
+ var variableToAffect = ( AutomationVariable ) assetToAffect ;
69
+
68
70
if ( assetToDelete != null )
69
71
{
70
- localAssets . Variables . Remove ( ( VariableJson ) assetToDelete ) ;
72
+ var variableToDelete = ( VariableJson ) assetToDelete ;
73
+
74
+ // Encrypted variable assets returned from the cloud have their values removed,
75
+ // so keep the old local asset value instead of overwriting the local asset value with null
76
+ if ( variableToAffect . Encrypted && variableToAffect . getValue ( ) == null ) {
77
+ variableToAffect . setValue ( variableToDelete . Value ) ;
78
+ }
79
+
80
+ localAssets . Variables . Remove ( variableToDelete ) ;
71
81
}
72
82
73
83
if ( replace )
74
84
{
75
- localAssets . Variables . Add ( new VariableJson ( ( AutomationVariable ) assetToAffect ) ) ;
85
+ localAssets . Variables . Add ( new VariableJson ( variableToAffect ) ) ;
76
86
}
77
87
}
78
88
79
89
else if ( assetToAffect is AutomationCredential )
80
90
{
91
+ var credToAffect = ( AutomationCredential ) assetToAffect ;
92
+
81
93
if ( assetToDelete != null )
82
94
{
83
- localAssets . PSCredentials . Remove ( ( CredentialJson ) assetToDelete ) ;
95
+ var credToDelete = ( CredentialJson ) assetToDelete ;
96
+
97
+ // PSCredential assets returned from the cloud have their passwords removed,
98
+ // so keep the old local asset password instead of overwriting the local asset password with null
99
+ if ( credToAffect . getPassword ( ) == null )
100
+ {
101
+ credToAffect . setPassword ( credToDelete . Password ) ;
102
+ }
103
+
104
+ localAssets . PSCredentials . Remove ( credToDelete ) ;
84
105
}
85
106
86
107
if ( replace )
87
108
{
88
- localAssets . PSCredentials . Add ( new CredentialJson ( ( AutomationCredential ) assetToAffect ) ) ;
109
+ localAssets . PSCredentials . Add ( new CredentialJson ( credToAffect ) ) ;
89
110
}
90
111
}
91
112
92
113
else if ( assetToAffect is AutomationConnection )
93
114
{
115
+ // TODO: support carry over of null fields from previous local asset
116
+
94
117
if ( assetToDelete != null )
95
118
{
96
119
localAssets . Connections . Remove ( ( ConnectionJson ) assetToDelete ) ;
0 commit comments