• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

CFTTP Remove action doesn't actually delete file

Explorer ,
Mar 18, 2013 Mar 18, 2013

Copy link to clipboard

Copied

I'm about to throw my monitor through the wall on this one.  I'm working on a process to retrieve order files from an sFTP server, and I have to delete them off the server after downloading them.  The CFFTP action="remove" call is returning a success status code, but the file is not actually being deleted from the server.  I've tested this under both FTP and sFTP (the server supports both), and it's the same both ways.  I also tested deleting the file through an FTP client (SecureFX), and that way it DOES actually delete the file, so I'm inclined to think it's not the server somehow blocking the action.

Here's my code:

<cfset ftpfolder="/Outbox/orders">

<cfftp connection="ftpconn" server="#ftpserver#" username="#ftpuser#" password="#ftppw#" action="open" secure="true">

<cfftp connection="ftpconn" action="changedir" directory="#ftpfolder#">

<cfftp connection="ftpconn" action="listdir" directory="#ftpfolder#" name="orders">

<cfdump var="#orders#">

<cfloop query="orders">

          <cfif Right(path,4) EQ ".asc">

                    <cfftp connection="ftpconn" action="getfile" remotefile="#path#" localfile="#inputdir##name#" failifexists="no">

                    <cfftp connection="ftpconn" action="getcurrentdir">

                    <cfftp connection="ftpconn" action="remove" item="#cfftp.returnvalue##name#">

                    <cfdump var="#cfftp#">

          </cfif>

</cfloop>

<cfftp connection="ftpconn" action="listdir" directory="#ftpfolder#" name="noworders">

<cfdump var="#noworders#">

<cfftp connection="ftpconn" action="close">

The dumps of #orders# and #noworders# show me the directory listing before and after the delete, and they're constantly identical.  The dump of the cfftp after the remove consistently shows me this:

struct
ErrorCode0
ErrorTextSSH_FX_OK successful completion of the operation
ReturnValue0 SSH_FX_OK successful completion of the operation
SucceededYES

But the damn file is still there.  I had originally NOT had the getcurrentdir call in there, just specifying the directory statically in the remove statement, but it was the same result.


I read the cfftp.succeeded as meaning that I'm specifying a valid file name, but for some reason it's not going away.  I tried this under CF8 and CF10 to the same results.

Anybody seen this behavior before?  I guess another option would be to try spawning a separate process to delete the files, but that really sucks.

Views

2.4K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 19, 2013 Mar 19, 2013

Copy link to clipboard

Copied

LATEST

Finally found the ridiculous solution--the delete command is case-sensitive, while the other commands are not.  I had the path name incorrect ("/Outbox/orders" instead of "/Outbox/Orders"), and the listdir and getfile commands would work fine, but the remove command would not.  How ridiculous.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation