Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
47 changes: 27 additions & 20 deletions 47 src/System.Management.Automation/namespaces/FileSystemProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3115,16 +3115,19 @@ void WriteErrorHelper(Exception exception)
{
_removedFiles++;
Comment thread
SteveL-MSFT marked this conversation as resolved.
_removedBytes += fileBytesSize;
double speed = _removedBytes / 1024 / 1024 / _removeStopwatch.Elapsed.TotalSeconds;
var progress = new ProgressRecord(
REMOVE_FILE_ACTIVITY_ID,
StringUtil.Format(FileSystemProviderStrings.RemovingLocalFileActivity, _removedFiles, _totalFiles),
StringUtil.Format(FileSystemProviderStrings.RemovingLocalBytesStatus, Utils.DisplayHumanReadableFileSize(_removedBytes), Utils.DisplayHumanReadableFileSize(_totalBytes), speed)
);
var percentComplete = _totalBytes != 0 ? (int)Math.Min(_removedBytes * 100 / _totalBytes, 100) : 100;
progress.PercentComplete = percentComplete;
progress.RecordType = ProgressRecordType.Processing;
WriteProgress(progress);
if (_removeStopwatch.Elapsed.TotalSeconds > ProgressBarDurationThreshold)
Comment thread
SteveL-MSFT marked this conversation as resolved.
{
double speed = _removedBytes / 1024 / 1024 / _removeStopwatch.Elapsed.TotalSeconds;
var progress = new ProgressRecord(
REMOVE_FILE_ACTIVITY_ID,
StringUtil.Format(FileSystemProviderStrings.RemovingLocalFileActivity, _removedFiles, _totalFiles),
StringUtil.Format(FileSystemProviderStrings.RemovingLocalBytesStatus, Utils.DisplayHumanReadableFileSize(_removedBytes), Utils.DisplayHumanReadableFileSize(_totalBytes), speed)
);
var percentComplete = _totalBytes != 0 ? (int)Math.Min(_removedBytes * 100 / _totalBytes, 100) : 100;
progress.PercentComplete = percentComplete;
progress.RecordType = ProgressRecordType.Processing;
WriteProgress(progress);
}
Comment thread
SteveL-MSFT marked this conversation as resolved.
}
}
}
Expand Down Expand Up @@ -3994,16 +3997,19 @@ private void CopyFileInfoItem(FileInfo file, string destinationPath, bool force,
{
_copiedFiles++;
_copiedBytes += file.Length;
double speed = (double)(_copiedBytes / 1024 / 1024) / _copyStopwatch.Elapsed.TotalSeconds;
var progress = new ProgressRecord(
COPY_FILE_ACTIVITY_ID,
StringUtil.Format(FileSystemProviderStrings.CopyingLocalFileActivity, _copiedFiles, _totalFiles),
StringUtil.Format(FileSystemProviderStrings.CopyingLocalBytesStatus, Utils.DisplayHumanReadableFileSize(_copiedBytes), Utils.DisplayHumanReadableFileSize(_totalBytes), speed)
);
var percentComplete = _totalBytes != 0 ? (int)Math.Min(_copiedBytes * 100 / _totalBytes, 100) : 100;
progress.PercentComplete = percentComplete;
progress.RecordType = ProgressRecordType.Processing;
WriteProgress(progress);
if (_copyStopwatch.Elapsed.TotalSeconds > ProgressBarDurationThreshold)
Comment thread
SteveL-MSFT marked this conversation as resolved.
{
double speed = (double)(_copiedBytes / 1024 / 1024) / _copyStopwatch.Elapsed.TotalSeconds;
var progress = new ProgressRecord(
COPY_FILE_ACTIVITY_ID,
StringUtil.Format(FileSystemProviderStrings.CopyingLocalFileActivity, _copiedFiles, _totalFiles),
StringUtil.Format(FileSystemProviderStrings.CopyingLocalBytesStatus, Utils.DisplayHumanReadableFileSize(_copiedBytes), Utils.DisplayHumanReadableFileSize(_totalBytes), speed)
);
var percentComplete = _totalBytes != 0 ? (int)Math.Min(_copiedBytes * 100 / _totalBytes, 100) : 100;
progress.PercentComplete = percentComplete;
progress.RecordType = ProgressRecordType.Processing;
WriteProgress(progress);
}
}
}
else
Expand Down Expand Up @@ -4945,6 +4951,7 @@ private bool PathIsReservedDeviceName(string destinationPath, string errorId)
private long _removedFiles;
private readonly Stopwatch _removeStopwatch = new();

private const double ProgressBarDurationThreshold = 2.0;
#endregion CopyItem

#endregion ContainerCmdletProvider members
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.