-
Notifications
You must be signed in to change notification settings - Fork 20
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
Conversation
There was a problem hiding this 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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
No description provided.