mholt / photobak

Back up your content from Google Photos - DEPRECATED: use Timeliner
https://github.com/mholt/timeliner
307 stars 29 forks source link

Fix various bugs on program shutdown and races #3

Closed KonishchevDmitry closed 7 years ago

KonishchevDmitry commented 7 years ago

This PR fixes the following issues:

mholt commented 7 years ago

Wow, thanks for the PR, @KonishchevDmitry! I will look at this later today or this weekend (I have a pressing paper deadline).

mholt commented 7 years ago

I have started reviewing this, but if you want faster reviews, could you split this into multiple, smaller PRs? Those are much easier to review and will get through my queue sooner. :)

KonishchevDmitry commented 7 years ago

Thank you for looking on my changes, @mholt! I don't mind to wait some time if you don't have a time now to review this. Sorry, I understand that smaller PR is better PR, but actually I don't know how to split this one into a smaller ones because actually this PR is all about the single feature - delete temporary files on clean shutdown. I've started to implement it and noticed that I need to repair current clean shutdown implementation + introduce some special version of Repository.Close() (Repository.CloseUnsafeOnExit()) and more sophisticated Repository.downloading: it needs a mutex which should be locked every time the downloading file is creating, deleting or changing its destination and a channel to notify about completion of downloading process. As I've changed Repository.downloading, all subsequent changes become inseparable from each other.

The PR contains 3 commits - that's how I tried to reduce the size of changes you'll have to review, but I decided to not create a separate PR for each commit because I'd had to create the new PR only after you approve the previous one (since it depends on previous commit changes), but if you don't see the last commit, you likely will be confused why we need all this stuff that I introduced in the first commit.

So could you please try to look at the changes commit-by-commit?

KonishchevDmitry commented 7 years ago

I've managed to extract one commit from the latest one as https://github.com/mholt/photobak/pull/5. All other changes seem to be inseparable for me.

KonishchevDmitry commented 7 years ago

Thank you for your review! Yes, sure, I would be glad to help.