Skip to content
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

Use DriveInfo constructor to get drive from path #4125

Merged
merged 1 commit into from
Jul 19, 2024

Conversation

HebaruSan
Copy link
Member

@HebaruSan HebaruSan commented Jul 19, 2024

Problem

Discord user HB Stratos reports that sometimes, a 20+ second delay occurs at the start of mod installation:

image

Cause

Based on the log file provided, the delay happens between here:

using (TransactionScope transaction = CkanTransaction.CreateTransactionScope())

and here:

CKAN/Core/CKANPathUtils.cs

Lines 135 to 139 in 1b5948f

log.DebugFormat("Storing {0} to {1} ({2} free)...",
CkanModule.FmtSize(bytesToStore),
where.FullName,
bytesFree.HasValue ? CkanModule.FmtSize(bytesFree.Value)
: "unknown bytes");

CKAN doesn't do any significant work itself in that interval, but I suspect that there is a hibernating external HDD attached to this user's system, and .GetDrive()'s loop over all the drives causes that drive to be woken up, which takes several seconds. When it's finally ready, the loop continues. That loop was implemented in #3631 because there was no property or function to get the drive associated with a path. However, reading up on the documentation a bit more, DriveInfo's constructor can apparently accept an arbitrary fully qualified path, and returns the associated drive, just as we wanted:

In testing, this even seems to work on Linux!

Changes

This should avoid waking up slumbering HDDs during mod installaiton.

@HebaruSan HebaruSan added Bug Something is not working as intended Core (ckan.dll) Issues affecting the core part of CKAN Performance Something's slower than it should be labels Jul 19, 2024
@HebaruSan HebaruSan merged commit de3672d into KSP-CKAN:master Jul 19, 2024
3 checks passed
@HebaruSan HebaruSan deleted the fix/get-drive branch July 19, 2024 02:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is not working as intended Core (ckan.dll) Issues affecting the core part of CKAN Performance Something's slower than it should be
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant