SWAT-engineering / SWAT-engineering/java-watch

Use an internal index to more accurately track renames on macOS

Open
#49 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Java
Stars
1
Forks
0
Avg merge
14h 40m
Merged PRs (30d)
1

Description

When a file is moved and we're using the native FSEvents API on macOS, it issues native events with flag ITEM_RENAMED set, but not flags ITEM_CREATED or ITEM_REMOVED. Typical cases include:

  1. Moving a file within the watch scope. In this case, there are two native events: one for the source (logically: delete), and one for the destination (logically: create).
  2. Moving a file into the watch scope. In this case, there is one native event, for the destination (logically: create).
  3. Moving a file out of the watch scope. In this case, there is one native event, for the source (logically: delete).

Because flags ITEM_CREATED and ITEM_REMOVED aren't set, the native events in cases 2 and 3 are indistinguishable. Currently, this is solved by asking the file system if the file exists: if it does, we assume it's case 2; if it doesn't, we assume it's case 3. However, this can be inaccurate (because things can have happened to the file between the native event was issued and asking the file system). A more accurate approach could be to maintain our own index.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the macOS FSEvents handling and how ITEM_RENAMED, ITEM_CREATED, and ITEM_REMOVED are currently interpreted. Reproduce the three move cases described in the issue, then define completion as distinguishing moves into, out of, and within the watch scope without relying only on a filesystem existence check.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, macos
Domain
operating-systems
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.