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

Shared checkout cache locking for concurrent invocations #4

Merged
merged 9 commits into from
Apr 8, 2019

Conversation

werner77
Copy link
Contributor

@werner77 werner77 commented Apr 5, 2019

No description provided.

Copy link

@jhildensperger jhildensperger left a comment

Choose a reason for hiding this comment

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

Is it worth adding some tests for this feature?

}
}

private static func releaseLock(lockFileURL: URL) {
_ = try? FileManager.default.removeItem(at: lockFileURL)

Choose a reason for hiding this comment

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

Would it be an error if removeItem fails? Maybe it would be good throw here?

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 factored the FileLock out to a separate class and implemented test cases for it. The problem with adding throws is that there is no really good way to recover from the error in case the file cannot be removed.

The most obvious reason would be that the file is already gone, in which case the error is not really an error. In all other cases (e.g. file system problems) there is no real way to recover (except maybe crashing the application). The lock will be released automatically when the process dies because of the way shlock works.

Choose a reason for hiding this comment

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

If no recovery is possible, would it make sense to crash with a message, versus a silent failure?

@werner77 werner77 merged commit 87862d6 into master Apr 8, 2019
@werner77 werner77 deleted the feature/cache-locking branch April 8, 2019 14:10
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.

3 participants