Skip to content

Add LockFile#21

Merged
Tyrrrz merged 6 commits intoprimefrom
copilot/add-lockfile
Apr 14, 2026
Merged

Add LockFile#21
Tyrrrz merged 6 commits intoprimefrom
copilot/add-lockfile

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 14, 2026

Ports LockFile from Onova into PowerKit as a general-purpose utility.

Changes

  • PowerKit/LockFile.cs — file-based exclusive lock; TryAcquire opens the file with FileShare.None and returns null on IOException (the exception .NET raises when the file is already held)
  • PowerKit.Tests/LockFileTests.cs — covers successful acquisition, blocked re-acquisition while held, and re-acquisition after disposal

Usage

using var lockFile = LockFile.TryAcquire("/path/to/lock");
if (lockFile is null)
{
    // another process holds the lock
}

Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/72a664dd-2122-4767-ab00-e3b28dd0b458

Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
@Tyrrrz Tyrrrz marked this pull request as ready for review April 14, 2026 15:24
Copilot AI review requested due to automatic review settings April 14, 2026 15:24
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR ports Onova’s LockFile helper into PowerKit, adding a small file-based exclusive lock primitive plus tests to validate acquisition and release behavior.

Changes:

  • Added LockFile utility with TryAcquire(path) semantics.
  • Added unit tests covering acquisition, contention, and reacquisition after disposal.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
PowerKit/LockFile.cs Introduces the file-based locking utility and acquisition API.
PowerKit.Tests/LockFileTests.cs Adds tests validating basic lock acquisition/contended acquisition/disposal behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread PowerKit/LockFile.cs Outdated
Comment thread PowerKit/LockFile.cs
Comment thread PowerKit.Tests/LockFileTests.cs Outdated
Tyrrrz and others added 3 commits April 14, 2026 18:39
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants