Lee-W commented on code in PR #66584:
URL: https://github.com/apache/airflow/pull/66584#discussion_r3287365568


##########
providers/standard/src/airflow/providers/standard/triggers/file.py:
##########
@@ -132,3 +132,83 @@ async def run(self) -> AsyncIterator[TriggerEvent]:
                 yield TriggerEvent(True)
                 return
             await asyncio.sleep(self.poke_interval)
+
+
+class DirectoryFileDeleteTrigger(BaseEventTrigger):
+    """
+    Fire once when ``filename`` appears in ``directory``, then delete it.
+
+    Functionally equivalent to ``FileDeleteTrigger`` for a single file, but
+    sibling triggers that point at the same ``directory`` and ``poke_interval``
+    share a single underlying directory scan in the triggerer; each instance
+    only fires for its own ``filename``. This is useful when many assets are
+    driven by per-flag-file events landing in a shared inbox directory.
+
+    :param directory: Directory to scan.
+    :param filename: File name (without directory) whose appearance fires this
+        trigger. The matched file is deleted before the event is yielded.
+    :param poke_interval: Time to wait between scans.
+    """
+
+    def __init__(self, *, directory: str, filename: str, poke_interval: float 
= 5.0) -> None:
+        super().__init__()
+        self.directory = directory
+        self.filename = filename
+        self.poke_interval = poke_interval
+
+    def serialize(self) -> tuple[str, dict[str, Any]]:
+        """Serialize DirectoryFileDeleteTrigger arguments and classpath."""
+        return (
+            
"airflow.providers.standard.triggers.file.DirectoryFileDeleteTrigger",
+            {
+                "directory": self.directory,
+                "filename": self.filename,
+                "poke_interval": self.poke_interval,
+            },
+        )
+
+    def shared_stream_key(self) -> Hashable | None:
+        """All triggers on the same directory + cadence share one scan."""
+        return ("directory-scan", self.directory, self.poke_interval)

Review Comment:
   Thanks! It's now `os.path.realpath`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to