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

[Xamarin.Android.Build.Tasks] Fix CollectNonEmptyDirectories to handle file collisions. #5038

Merged
merged 1 commit into from
Aug 25, 2020

Conversation

dellis1972
Copy link
Contributor

Context Redth/ResizetizerNT#23

The CollectNonEmptyDirectories task is responsible for
creating a cache file files.cache. This file contains
a list of all the resource files for that particular
directory.

We hit a problem when using ResizetizerNT and a
google-services.json file where the files.cache for
one would be overwritten by the other. This is because of
a simple assuption within the Task itself. That if the
"directory" was not in the Intermediate lp directory
(for libraries) then we could just create the files.cache
file in the parent directory. This woud be the root of
the IntermediateOutputPath.

The problem with ResizetizerNT and google-services.json is that
they are BOTH outside of the lp directory. They also only create
a directory structure which is one level deep. So .. will ALWAYS
end up in the IntermediateOutputPath. The other issue is that they
were both using the same file name. #facepalm.

The files.cache should instead be handled in the same manner as
the stamp file. In that if the file is NOT in the lp directory
we should use a unique filename. In this case we can use the same
technique and use the directory hash. This way the two directories
do not collide with each other.

@brendanzagaeski
Copy link
Contributor

Draft release notes

During the finalization of this PR for merging, when you get a chance, you can add a short release note for it to Documentation/release-notes/5038.md as part of the PR. Here's the template to fill out. Thanks!

#### Application behavior on device and emulator

- [GitHub PR 5038](https://github.com/xamarin/xamarin-android/pull/5038):
  ...

…e file collisions.

Context Redth/ResizetizerNT#23

The `CollectNonEmptyDirectories` task is responsible for
creating a cache file `files.cache`. This file contains
a list of all the resource files for that particular
directory.

We hit a problem when using `ResizetizerNT` and a
`google-services.json` file where the `files.cache` for
one would be overwritten by the other.  This is because of
a simple assuption within the Task itself. That if the
"directory" was not in the Intermediate `lp` directory
(for libraries) then we could just create the `files.cache`
file in the parent directory. This woud be the root of
the `IntermediateOutputPath`.

The problem with `ResizetizerNT` and `google-services.json` is that
they are BOTH outside of the `lp` directory. They also only create
a directory structure which is one level deep. So `..` will ALWAYS
end up in the `IntermediateOutputPath`. The other issue is that they
were both using the same file name. #facepalm.

The `files.cache` should instead be handled in the same manner as
the `stamp` file. In that if the file is NOT in the `lp` directory
we should use a unique filename. In this case we can use the same
technique and use the directory hash. This way the two directories
do not collide with each other.
Copy link
Member

@jonathanpeppers jonathanpeppers left a comment

Choose a reason for hiding this comment

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

The BCL test failures are expected: https://discordapp.com/channels/732297728826277939/732297837953679412/746334964462780476

Something broke with the he-IL calendar's new year.

The one performance test looks OK, I didn't see any regression in the .binlog: Exceeded expected time of 7250ms, actual 7274.528ms.

Copy link
Contributor

@brendanzagaeski brendanzagaeski left a comment

Choose a reason for hiding this comment

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

Release note approved. Thanks for the correction on the error message. In the final collated release notes, I'll plan to adjust the formatting to put the example error message up front and limit the resolution details for compactness. Feel free to comment back if anything looks bad about this adjustment though.

- [GitHub PR 5038](https://github.com/xamarin/xamarin-android/pull/5038):
  Errors similar to _error APT2260: resource drawable/icon (aka
  com.contoso.androidapp:drawable/icon) not found_ could prevent
  building projects that were using ResizetizerNT and
  `google-services.json` together.

  The build system has now been updated to ensure each resource
  directory has its own unique cache file.

@dellis1972 dellis1972 merged commit f14890f into dotnet:master Aug 25, 2020
@dellis1972 dellis1972 deleted the FixFilesCache branch August 25, 2020 16:07
jonpryor pushed a commit that referenced this pull request Aug 27, 2020
…e file collisions. (#5038)

Context Redth/ResizetizerNT#23

The `CollectNonEmptyDirectories` task is responsible for
creating a cache file `files.cache`. This file contains
a list of all the resource files for that particular
directory.

We hit a problem when using `ResizetizerNT` and a
`google-services.json` file where the `files.cache` for
one would be overwritten by the other.  This is because of
a simple assuption within the Task itself. That if the
"directory" was not in the Intermediate `lp` directory
(for libraries) then we could just create the `files.cache`
file in the parent directory. This woud be the root of
the `IntermediateOutputPath`.

The problem with `ResizetizerNT` and `google-services.json` is that
they are BOTH outside of the `lp` directory. They also only create
a directory structure which is one level deep. So `..` will ALWAYS
end up in the `IntermediateOutputPath`. The other issue is that they
were both using the same file name. #facepalm.

The `files.cache` should instead be handled in the same manner as
the `stamp` file. In that if the file is NOT in the `lp` directory
we should use a unique filename. In this case we can use the same
technique and use the directory hash. This way the two directories
do not collide with each other.
@github-actions github-actions bot locked and limited conversation to collaborators Jan 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants