Skip to content

Commit 4ee7514

Browse files
committed
RDBug 5795841:[PSH] Failed to upload zero size of file to Azure File: Attempted to divide by zero
1 parent e4a3b55 commit 4ee7514

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/Common/Storage/Commands.Storage/File/StorageFileDataManagementCmdletBase.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ protected TransferContext GetTransferContext(ProgressRecord record, long totalTr
9191
{
9292
if (record != null)
9393
{
94-
record.PercentComplete = (int)(transferProgress.BytesTransferred * 100 / totalTransferLength);
94+
// Size of the source file might be 0, when it is, directly treat the progress as 100 percent.
95+
record.PercentComplete = (totalTransferLength == 0) ? 100 : (int)(transferProgress.BytesTransferred * 100 / totalTransferLength);
9596
record.StatusDescription = string.Format(CultureInfo.CurrentCulture, Resources.FileTransmitStatus, record.PercentComplete);
9697
this.OutputStream.WriteProgress(record);
9798
}

0 commit comments

Comments
 (0)