-
Notifications
You must be signed in to change notification settings - Fork 19
Uninstalling if cost of repair is larger than cost of content #55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
genail
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see comments
| repairCost *= installedVersionContentSummary.Chunks.Size; | ||
| } | ||
|
|
||
| if (repairCost < contentSize) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
repairCost seems to be a number of missing and broken files (x2). Is contentSize the content size in bytes?
This does not seem right.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Below that there is:
if (isNewVersionAvailable)
{
repairCost *= latestVersionContentSummary.Chunks.Size;
}
else
{
repairCost *= installedVersionContentSummary.Chunks.Size;
}repairCost is estimated to be equal to the sum of missing and broken files, multiplied by two and then multiplied by chunk size in the respective version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I didn't notice that.
I can't imagine it though. For instance if there's a large file broken, would the cost be the same as for small file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed it now. The cost calculation will now use actual file sizes.
genail
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please answer to my comment.
| repairCost *= installedVersionContentSummary.Chunks.Size; | ||
| } | ||
|
|
||
| if (repairCost < contentSize) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I didn't notice that.
I can't imagine it though. For instance if there's a large file broken, would the cost be the same as for small file?
genail
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possible NRE?
| { | ||
| return filesToRepair | ||
| .Select(f => contentSummary.Files.FirstOrDefault(e => e.Path == f.FileName)) | ||
| .Sum(f => f.Size); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will it work? Select() transforms enumerable to a new form (https://msdn.microsoft.com/en-us/library/bb548891(v=vs.110).aspx). When a file is not found, a null is returned. Sum() is dereferencing the value so it looks like NRE for me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a file is not found, default value of struct AppContentSummaryFile is returned. There won't be any NRE here.
No description provided.