Skip to content

Lock file creation fails when path is a file (Not a directory error) #1887

@yaoduan

Description

@yaoduan

Bug Description

When attempting to reindex a file (e.g., `viking://user/wangyd/memories/profile.md`), the lock acquisition fails with error:

```
[POINT] Failed to create lock file: plugin error: failed to open file: Not a directory (os error 20)
```

Root Cause

In `openviking/storage/transaction/path_lock.py:67`:

```python
def _get_lock_path(self, path: str) -> str:
path = path.rstrip("/")
return f"{path}/{LOCK_FILE_NAME}" # LOCK_FILE_NAME = ".path.ovlock"
```

This generates lock path `/local/default/user/wangyd/memories/profile.md/.path.ovlock` for a file path, but `profile.md` is a file, not a directory. Creating a file under a file path causes "Not a directory" OS error.

Expected Behavior

For file paths, the lock file should be placed in the parent directory or use a different naming scheme.

Environment

  • OpenViking version: 0.3.14
  • Platform: macOS (darwin)
  • Python: 3.14

Steps to Reproduce

  1. Start OpenViking server
  2. Run `ov reindex 'viking://user/wangyd/memories/profile.md' --wait`
  3. Observe error: `LockAcquisitionError: Failed to acquire point lock for ['/local/default/user/wangyd/memories/profile.md']`

Suggested Fix

Modify `_get_lock_path` to detect if path is a file and place lock file in parent directory (e.g., `/path/to/.file.md.ovlock`).

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

Backlog

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions