@@ -50,6 +50,8 @@ public class ChocolateyPackageService : IChocolateyPackageService
50
50
private readonly IAutomaticUninstallerService _autoUninstallerService ;
51
51
private readonly IXmlService _xmlService ;
52
52
private readonly IConfigTransformService _configTransformService ;
53
+ private readonly IDictionary < string , FileStream > _pendingLocks = new Dictionary < string , FileStream > ( ) ;
54
+
53
55
private readonly IList < string > _proBusinessMessages = new List < string > {
54
56
@"
55
57
Are you ready for the ultimate experience? Check out Pro / Business!
@@ -1158,6 +1160,7 @@ public void set_pending(PackageResult packageResult, ChocolateyConfiguration con
1158
1160
1159
1161
var pendingFile = _fileSystem . combine_paths ( packageDirectory , ApplicationParameters . PackagePendingFileName ) ;
1160
1162
_fileSystem . write_file ( pendingFile , "{0}" . format_with ( packageResult . Name ) ) ;
1163
+ _pendingLocks . Add ( packageResult . Name . to_lower ( ) , _fileSystem . open_file_exclusive ( pendingFile ) ) ;
1161
1164
}
1162
1165
1163
1166
public void remove_pending ( PackageResult packageResult , ChocolateyConfiguration config )
@@ -1177,6 +1180,15 @@ public void remove_pending(PackageResult packageResult, ChocolateyConfiguration
1177
1180
}
1178
1181
1179
1182
var pendingFile = _fileSystem . combine_paths ( packageDirectory , ApplicationParameters . PackagePendingFileName ) ;
1183
+ var lockName = packageResult . Name . to_lower ( ) ;
1184
+ if ( _pendingLocks . ContainsKey ( lockName ) )
1185
+ {
1186
+ var fileLock = _pendingLocks [ lockName ] ;
1187
+ _pendingLocks . Remove ( lockName ) ;
1188
+ fileLock . Close ( ) ;
1189
+ fileLock . Dispose ( ) ;
1190
+ }
1191
+
1180
1192
if ( _fileSystem . file_exists ( pendingFile ) ) _fileSystem . delete_file ( pendingFile ) ;
1181
1193
}
1182
1194
0 commit comments