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

[Electron] Don't stat for electron save dialog #7197

Merged
merged 1 commit into from
Feb 26, 2020

Conversation

thegecko
Copy link
Member

Signed-off-by: Rob Moran [email protected]

What it does

When using the fileDialogService.showSaveDialog() function in Electron, a messageService message is shown if the file input doesn't yet exist:

Cannot access resource at <file>.

This is because there is an explicit stat check for the file to see if it is readable/writable, but it's possible it doesn't yet exist.

This looks like it may be a copy-paste error from the OpenDialog(), but I can update this PR if the checks need to be kept for when the file already exists.

How to test

Using the electron version, save an existing file as a new file which doesn't exist and observe the message.

Review checklist

Reminder for reviewers

@akosyakov akosyakov added electron issues related to the electron target filesystem issues related to the filesystem labels Feb 24, 2020
Copy link
Contributor

@kittaakos kittaakos left a comment

Choose a reason for hiding this comment

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

Nice catch, it is broken. But your fix is partial:

const uri = FileUri.create(filename);
const exists = await this.fileSystem.exists(uri.toString());
if (!exists) {
    resolve(uri);
    return;
}
const canAccess = await this.canReadWrite(uri);
resolve(canAccess ? uri : undefined);

And please fix the other bug in the showOpenDialog. Thoughts? Thanks!

@thegecko
Copy link
Member Author

@kittaakos Sure I'll update the PR.

I don't think the open dialog is broken, though. I would expect the file to be opened would already need exist?

@kittaakos
Copy link
Contributor

I don't think the open dialog is broken, though

It is, it resolves to a promise, but we never await. The this.canReadWrite(uris) condition will be always true. Please fix them together.

@thegecko thegecko force-pushed the electron-save-warning branch from b3c1ae6 to f60c7da Compare February 24, 2020 11:28
@thegecko
Copy link
Member Author

Updated

@thegecko
Copy link
Member Author

@kittaakos happy with this change?

@kittaakos
Copy link
Contributor

I am trying it now...

Copy link
Contributor

@kittaakos kittaakos left a comment

Choose a reason for hiding this comment

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

Nice! 👍 It was completely broken. Thank you for the fix, @thegecko

@thegecko
Copy link
Member Author

Thanks @kittaakos !

@thegecko thegecko merged commit e945f2e into eclipse-theia:master Feb 26, 2020
@thegecko thegecko deleted the electron-save-warning branch February 26, 2020 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
electron issues related to the electron target filesystem issues related to the filesystem
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants