<h3 dir="auto">Apache Airflow Provider(s)</h3>
<p dir="auto">sftp</p>
<h3 dir="auto">Versions of Apache Airflow Providers</h3>
<p dir="auto">apache-airflow-providers-sftp==4.1.0</p>
<h3 dir="auto">Apache Airflow version</h3>
<p dir="auto">apache-airflow==2.4.3</p>
<h3 dir="auto">Operating System</h3>
<p dir="auto">NAME="Ubuntu" VERSION="20.04.2 LTS (Focal Fossa)"</p>
<h3 dir="auto">Deployment</h3>
<p dir="auto">Composer</p>
<h3 dir="auto">Deployment details</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">What happened</h3>
<p dir="auto">SFTPSensor is continuously running even when the files matching file pattern passed by the user are available in sftp location. This is happening because the variable <code class="notranslate">actual_file_to_check</code> holds just file name where as the method <code class="notranslate">get_mod_time</code> expects file name with path.</p>
<p dir="auto"></p><div class="Box Box--condensed my-2">
  <div class="Box-header f6">
    <p class="mb-0 text-bold">
      <a href="https://github.com/apache/airflow/blob/12c3c39d1a816c99c626fe4c650e88cf7b1cc1bc/airflow/providers/sftp/sensors/sftp.py#L70-L79">airflow/airflow/providers/sftp/sensors/sftp.py</a>
    </p>
    <p class="mb-0 color-fg-muted">
        Lines 70 to 79
      in
      <a data-pjax="true" class="commit-tease-sha" href="/apache/airflow/commit/12c3c39d1a816c99c626fe4c650e88cf7b1cc1bc">12c3c39</a>
    </p>
  </div>
  <div itemprop="text" class="Box-body p-0 blob-wrapper blob-wrapper-embedded data">
    <table class="highlight tab-size mb-0 js-file-line-container" data-tab-size="8" data-paste-markdown-skip="">

        <tbody><tr class="border-0">
          <td id="L70" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="70"></td>
          <td id="LC70" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     <span class="pl-s1">file_from_pattern</span> <span class="pl-c1">=</span> <span class="pl-s1">self</span>.<span class="pl-s1">hook</span>.<span class="pl-en">get_file_by_pattern</span>(<span class="pl-s1">self</span>.<span class="pl-s1">path</span>, <span class="pl-s1">self</span>.<span class="pl-s1">file_pattern</span>) </td>
        </tr>

        <tr class="border-0">
          <td id="L71" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="71"></td>
          <td id="LC71" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     <span class="pl-k">if</span> <span class="pl-s1">file_from_pattern</span>: </td>
        </tr>

        <tr class="border-0">
          <td id="L72" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="72"></td>
          <td id="LC72" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">         <span class="pl-s1">actual_file_to_check</span> <span class="pl-c1">=</span> <span class="pl-s1">file_from_pattern</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L73" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="73"></td>
          <td id="LC73" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     <span class="pl-k">else</span>: </td>
        </tr>

        <tr class="border-0">
          <td id="L74" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="74"></td>
          <td id="LC74" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">         <span class="pl-k">return</span> <span class="pl-c1">False</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L75" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="75"></td>
          <td id="LC75" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-k">else</span>: </td>
        </tr>

        <tr class="border-0">
          <td id="L76" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="76"></td>
          <td id="LC76" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     <span class="pl-s1">actual_file_to_check</span> <span class="pl-c1">=</span> <span class="pl-s1">self</span>.<span class="pl-s1">path</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L77" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="77"></td>
          <td id="LC77" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">  </td>
        </tr>

        <tr class="border-0">
          <td id="L78" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="78"></td>
          <td id="LC78" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-k">try</span>: </td>
        </tr>

        <tr class="border-0">
          <td id="L79" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="79"></td>
          <td id="LC79" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     <span class="pl-s1">mod_time</span> <span class="pl-c1">=</span> <span class="pl-s1">self</span>.<span class="pl-s1">hook</span>.<span class="pl-en">get_mod_time</span>(<span class="pl-s1">actual_file_to_check</span>) </td>
        </tr>
    </tbody></table>
  </div>
</div>
<p></p>
<h3 dir="auto">What you think should happen instead</h3>
<p dir="auto">SFTPSensor should stop execution as soon as it finds first file match.</p>
<h3 dir="auto">How to reproduce</h3>
<p dir="auto">Trigger SFTPSensor with file pattern as shown in the below code snippet.<br>
<code class="notranslate">checkForSFTPFiles = SFTPSensor( task_id="checkForSFTPFiles", path=f"{SFTP_ROOT_DIR}", file_pattern='Migrate*', poke_interval=10 )</code></p>
<h3 dir="auto">Anything else</h3>
<p dir="auto">Every time</p>
<h3 dir="auto">Are you willing to submit PR?</h3>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> Yes I am willing to submit a PR!</li>
</ul>
<h3 dir="auto">Code of Conduct</h3>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I agree to follow this project's <a href="https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md">Code of Conduct</a></li>
</ul>
<h3 dir="auto">Body</h3>
<p dir="auto">issue is described in PR <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="1337995923" data-permission-text="Title is private" data-url="https://github.com/apache/airflow/issues/25705" data-hovercard-type="pull_request" data-hovercard-url="/apache/airflow/pull/25705/hovercard" href="https://github.com/apache/airflow/pull/25705">#25705</a><br>
the author of the PR abandon it so anyone can try to submit a fix to the issue.</p>
<h3 dir="auto">Committer</h3>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I acknowledge that I am a maintainer/committer of the Apache Airflow project.</li>
</ul>