Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@jonahwilliams
Copy link
Contributor

OpenFile seems to mostly do the right thing with absolute and relative paths on windows. Not sure what the other use cases might be? we could always do an ifdef.

Fixes flutter/flutter#102805

@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!).

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@jonahwilliams jonahwilliams marked this pull request as draft April 29, 2022 05:01
@zanderso zanderso requested a review from chinmaygarde April 29, 2022 05:14
@jonahwilliams
Copy link
Contributor Author

Sorry, added more changes 😓

WriteFileAtomically also had an issue with a sharing violating while trying to copy the temp file to the intended destination. I debugged this a bit and didn't find any obvious leaked fds but could have missed something. I don't actually think copying a file is atomic in windows, so I removed the temp file copy and impellerc works on windows now

@jonahwilliams jonahwilliams marked this pull request as ready for review April 29, 2022 05:27

auto temp_file =
OpenFile(temp_file_path.c_str(), true, FilePermission::kReadWrite);
OpenFile(file_path.c_str(), true, FilePermission::kReadWrite);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think what we want here is to use ReplaceFile instead of MoveFile below.

This does not do an atomic write.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adding this back I wasn't able to make ReplaceFile work. Really nothing in this method is atomic for windows though ...

Copy link
Contributor

Choose a reason for hiding this comment

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

ReplaceFile is supposed to be atomic.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I mean this entire method, if anything fails we just leave a temp file laying around. Atomic-ish?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That said, I'm gonna say we don't need atomic writes for a shader compiler

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should be called WriteAtomicallyIfItSucceeds

Copy link
Contributor

Choose a reason for hiding this comment

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

That's fine - the point is that the final write to the destination file is atomic. As long as that's the case we should be good.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the point of what though, that never worked. This is a PR to make impellerc work on windows. If you want to fix WriteFileAtomically for windows that is certainly worthwhile at some point but I don't think its a good use of my time

Copy link
Contributor

Choose a reason for hiding this comment

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

(talked offline - I misunderstood that this was not used yet - I'm fine if we just file a bug with a TODO here to make this be atomic on Windows)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jonahwilliams
Copy link
Contributor Author

I'm removing the needs tests tag since my un-disabling a test I have sort of added a test :)

Copy link
Contributor

@dnfield dnfield left a comment

Choose a reason for hiding this comment

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

LGTM.

I believe we don't need an exception here because the unit test was updated after the bot requested a test so we're good.

@jonahwilliams jonahwilliams added the waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land. label Apr 29, 2022
@fluttergithubbot fluttergithubbot merged commit 38fabd1 into flutter:main Apr 29, 2022
@jonahwilliams jonahwilliams deleted the fix_impellerc_windows_file branch April 29, 2022 22:29
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Apr 29, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Apr 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

impellerc cannot open input file in parent or sibling directories on windows

4 participants