Skip to content

Fix the return value for FileSystem.isReadOnly(). - #9800

Merged
Eric Snow (ericsnowcurrently) merged 2 commits into
microsoft:masterfrom
ericsnowcurrently:fs-fix-isReadOnly
Jan 28, 2020
Merged

Eric Snow (ericsnowcurrently) merged 2 commits into
microsoft:masterfrom
ericsnowcurrently:fs-fix-isReadOnly

Conversation

@ericsnowcurrently

Copy link
Copy Markdown

(for #8995)

The return value didn't get fixed when we changed isPathWritableAsync() to FileSystem.isDirReadonly(). Here we fix that and update the test. We now also fail for any errors except errno EACCES. The one consumer of isDirReadonly() has been adjusted accordingly, maintaining its does-not-fail behavior.

@ericsnowcurrently

Copy link
Copy Markdown
Author

BTW, I've already started a CI job for this PR. 😄

@codecov-io

Codecov (codecov-io) commented Jan 28, 2020 •

Copy link
Copy Markdown

Codecov Report

Merging #9800 into master will decrease coverage by <.01%.
The diff coverage is 18.18%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #9800      +/-   ##
==========================================
- Coverage   60.87%   60.86%   -0.01%     
==========================================
  Files         556      556              
  Lines       29996    29998       +2     
  Branches     4547     4547              
==========================================
- Hits        18259    18258       -1     
- Misses      10710    10713       +3     
  Partials     1027     1027
Impacted Files Coverage Δ
src/client/common/platform/fileSystem.ts 56.56% <10%> (-1.09%) ⬇️
src/client/common/installer/moduleInstaller.ts 94.52% <100%> (ø) ⬆️
src/datascience-ui/interactive-common/mainState.ts 61.97% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 172ba65...42f45c4. Read the comment docs.

} else if (settings.globalModuleInstallation) {
const fs = this.serviceContainer.get<IFileSystem>(IFileSystem);
if (await fs.isDirReadonly(path.dirname(pythonPath))) {
if (await fs.isDirReadonly(path.dirname(pythonPath)).catch(_err => true)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests for this?

@ericsnowcurrently

Copy link
Copy Markdown
Author

Kartik Raj (@karrtikr), otherwise okay?

@ericsnowcurrently

Copy link
Copy Markdown
Author

CI passed, BTW

@karrtikr Kartik Raj (karrtikr) left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

@sonarqubecloud

Copy link
Copy Markdown

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@ericsnowcurrently
Eric Snow (ericsnowcurrently) merged commit 5322fdc into microsoft:master Jan 28, 2020
@ericsnowcurrently
Eric Snow (ericsnowcurrently) deleted the fs-fix-isReadOnly branch January 28, 2020 22:35

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't submit my comments

throw err; // re-throw
}
await fs.close(fd);
await fs.unlink(filePath);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two could probably, be done in the back ground rather than awaiting.
Basically previously there was no await on cleaning resources, now there is, hence it's unnecessarily slower.
Suggestion is to use fs.close().ignorewait

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eric Snow (@ericsnowcurrently) Do you think it would be good to create a seprate PR to clean up the resources in the background, as opposed to awaiting on them and slowing the exit from this fn?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can submit one if you think its ok.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be great. Thanks!

Don Jayamanne (DonJayamanne) added a commit that referenced this pull request Jan 29, 2020
For #9800
#9800 (comment)

When we've detected that a directory is r/w, we can delete the temp file in the background without blocking the call to check if dir is readonly.
@lock lock Bot locked as resolved and limited conversation to collaborators Feb 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

no-changelog No news entry required

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants