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

File creation fix #427

Merged
merged 14 commits into from
Aug 25, 2020
Merged

File creation fix #427

merged 14 commits into from
Aug 25, 2020

Conversation

MiSikora
Copy link
Contributor

@MiSikora MiSikora commented Aug 17, 2020

📄 Context

There are open issues - #422, #414.

📝 Changes

FileFactory is now IO safe and typesafe. I removed the interface in favor of a concrete implementation. It was internal anyway and it was misleading in tests of ChuckerInterceptor because fake implementation did not take into account stuff like createNewFile(), that was the cause of #422.

One more thing that I changed in the implementation of the factory is that access to the parent directory. It is now lazy, so it should help with #413 since the cache directory will no longer be accessed during initialization. It won't fix it as there are other files being used on the main thread but it is one step forward.

I'm not particularly happy about the fact that TeeSource accepts now File? as an input parameter but I didn't want to overcomplicate things by introducing another source that just counts bytes downloaded. - This isn't the case anymore. See #427 (comment).

📎 Related PR

I copied the test for the file factory from #423.

🚫 Breaking

No.

🛠️ How to test

In practice not sure. Maybe @CodeBreak524 can test with a dependency from my branch on JitPack (com.github.MiSikora.chucker:library:file-creation-fix-SNAPSHOT). I didn't write new tests for ChuckerInterceptor as old ones cover this case due to using real file factory in tests.

⏱️ Next steps

Closes #422
Closes #414
Closes #423

Copy link
Collaborator

@vbuberen vbuberen left a comment

Choose a reason for hiding this comment

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

Thanks for such a good change. Looks good to me.
Only a few minor comments with suggestions for micro-optimizations.

Also, I see a typo in PR description with wrong PR mentioned in the first part in that was the cause of #420. Please update it as well to have proper history descriptions.

@MiSikora
Copy link
Contributor Author

Ok, I applied your suggestions. I would appreciate it if you can give feedback on #427 (comment) from @koral-- and how you'd like to handle it.

@MiSikora MiSikora marked this pull request as draft August 20, 2020 12:26
@MiSikora
Copy link
Contributor Author

Coverted it to a draft because I discovered some issues.

@MiSikora MiSikora marked this pull request as ready for review August 20, 2020 12:45
@MiSikora
Copy link
Contributor Author

MiSikora commented Aug 20, 2020

In cbedcbc I decoupled tee operation from reporting functionality. Reporting is now a part of the ReportingSink class. My main motivation was that TeeSource started to become too complex and had too many responsibilities.

I can remove it from this PR and make a different one with just this commit if you want me to. Or remove it completely but I'm happy now with how reporting bytes and copying bytes is no longer coupled.

Copy link
Collaborator

@vbuberen vbuberen left a comment

Choose a reason for hiding this comment

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

In general, looks good to me.

Replied to mentioned comment as well.

@MiSikora
Copy link
Contributor Author

MiSikora commented Aug 23, 2020

I added the suggested changes. CI fails for now because I added a functional interface and #438 needs to be merged first. I'll rebase after. Unless you think that () -> File? and a type alias will suffice.

@cortinico
Copy link
Member

CI fails for now because I added a functional interface and #438 needs to be merged first. I'll rebase after. Unless you think that () -> File? and a type alias will suffice.

Since we're on 1.4, let's go with a functional interface 👌

Copy link
Member

@cortinico cortinico left a comment

Choose a reason for hiding this comment

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

Left some nits. Overall the change looks good to me.

Thank you very much for taking the time to do this change @MiSikora 🙏
I'd love to get a pass also from @vbuberen if possible before merging 👌

@MiSikora
Copy link
Contributor Author

MiSikora commented Aug 24, 2020

Great, thanks! I added one test for a missing cache in the first place.

Copy link
Collaborator

@vbuberen vbuberen left a comment

Choose a reason for hiding this comment

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

LGTM!

@vbuberen vbuberen merged commit 5415940 into ChuckerTeam:develop Aug 25, 2020
@MiSikora MiSikora deleted the file-creation-fix branch August 25, 2020 08:13
@cortinico cortinico added this to the 3.3.0 milestone Aug 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

IOException when app uses 3rd party SDK Potential NPE during AndroidCacheFileFactory initialization
4 participants