@@ -3115,16 +3115,19 @@ void WriteErrorHelper(Exception exception)
31153115 {
31163116 _removedFiles ++ ;
31173117 _removedBytes += fileBytesSize ;
3118- double speed = _removedBytes / 1024 / 1024 / _removeStopwatch . Elapsed . TotalSeconds ;
3119- var progress = new ProgressRecord (
3120- REMOVE_FILE_ACTIVITY_ID ,
3121- StringUtil . Format ( FileSystemProviderStrings . RemovingLocalFileActivity , _removedFiles , _totalFiles ) ,
3122- StringUtil . Format ( FileSystemProviderStrings . RemovingLocalBytesStatus , Utils . DisplayHumanReadableFileSize ( _removedBytes ) , Utils . DisplayHumanReadableFileSize ( _totalBytes ) , speed )
3123- ) ;
3124- var percentComplete = _totalBytes != 0 ? ( int ) Math . Min ( _removedBytes * 100 / _totalBytes , 100 ) : 100 ;
3125- progress . PercentComplete = percentComplete ;
3126- progress . RecordType = ProgressRecordType . Processing ;
3127- WriteProgress ( progress ) ;
3118+ if ( _removeStopwatch . Elapsed . TotalSeconds > ProgressBarDurationThreshold )
3119+ {
3120+ double speed = _removedBytes / 1024 / 1024 / _removeStopwatch . Elapsed . TotalSeconds ;
3121+ var progress = new ProgressRecord (
3122+ REMOVE_FILE_ACTIVITY_ID ,
3123+ StringUtil . Format ( FileSystemProviderStrings . RemovingLocalFileActivity , _removedFiles , _totalFiles ) ,
3124+ StringUtil . Format ( FileSystemProviderStrings . RemovingLocalBytesStatus , Utils . DisplayHumanReadableFileSize ( _removedBytes ) , Utils . DisplayHumanReadableFileSize ( _totalBytes ) , speed )
3125+ ) ;
3126+ var percentComplete = _totalBytes != 0 ? ( int ) Math . Min ( _removedBytes * 100 / _totalBytes , 100 ) : 100 ;
3127+ progress . PercentComplete = percentComplete ;
3128+ progress . RecordType = ProgressRecordType . Processing ;
3129+ WriteProgress ( progress ) ;
3130+ }
31283131 }
31293132 }
31303133 }
@@ -3994,16 +3997,19 @@ private void CopyFileInfoItem(FileInfo file, string destinationPath, bool force,
39943997 {
39953998 _copiedFiles ++ ;
39963999 _copiedBytes += file . Length ;
3997- double speed = ( double ) ( _copiedBytes / 1024 / 1024 ) / _copyStopwatch . Elapsed . TotalSeconds ;
3998- var progress = new ProgressRecord (
3999- COPY_FILE_ACTIVITY_ID ,
4000- StringUtil . Format ( FileSystemProviderStrings . CopyingLocalFileActivity , _copiedFiles , _totalFiles ) ,
4001- StringUtil . Format ( FileSystemProviderStrings . CopyingLocalBytesStatus , Utils . DisplayHumanReadableFileSize ( _copiedBytes ) , Utils . DisplayHumanReadableFileSize ( _totalBytes ) , speed )
4002- ) ;
4003- var percentComplete = _totalBytes != 0 ? ( int ) Math . Min ( _copiedBytes * 100 / _totalBytes , 100 ) : 100 ;
4004- progress . PercentComplete = percentComplete ;
4005- progress . RecordType = ProgressRecordType . Processing ;
4006- WriteProgress ( progress ) ;
4000+ if ( _copyStopwatch . Elapsed . TotalSeconds > ProgressBarDurationThreshold )
4001+ {
4002+ double speed = ( double ) ( _copiedBytes / 1024 / 1024 ) / _copyStopwatch . Elapsed . TotalSeconds ;
4003+ var progress = new ProgressRecord (
4004+ COPY_FILE_ACTIVITY_ID ,
4005+ StringUtil . Format ( FileSystemProviderStrings . CopyingLocalFileActivity , _copiedFiles , _totalFiles ) ,
4006+ StringUtil . Format ( FileSystemProviderStrings . CopyingLocalBytesStatus , Utils . DisplayHumanReadableFileSize ( _copiedBytes ) , Utils . DisplayHumanReadableFileSize ( _totalBytes ) , speed )
4007+ ) ;
4008+ var percentComplete = _totalBytes != 0 ? ( int ) Math . Min ( _copiedBytes * 100 / _totalBytes , 100 ) : 100 ;
4009+ progress . PercentComplete = percentComplete ;
4010+ progress . RecordType = ProgressRecordType . Processing ;
4011+ WriteProgress ( progress ) ;
4012+ }
40074013 }
40084014 }
40094015 else
@@ -4945,6 +4951,7 @@ private bool PathIsReservedDeviceName(string destinationPath, string errorId)
49454951 private long _removedFiles ;
49464952 private readonly Stopwatch _removeStopwatch = new ( ) ;
49474953
4954+ private const double ProgressBarDurationThreshold = 2.0 ;
49484955 #endregion CopyItem
49494956
49504957 #endregion ContainerCmdletProvider members
0 commit comments