Copy link to clipboard
Copied
having a wierd issue here. i believe it may be a bug in CF.
code:
<cfftp secure="true" action="open" server="#ftpserver#" port="#ftpport#" username="#username#" password="#password#" fingerprint="#fingerprint#" connection="myftp">
<cfftp action="getfile" connection="myftp" remotefile="testfile.txt" localfile="E:\tmp\testfile.txt" transfermode="binary" passive="true"/>
throws error
An error occurred during the sFTP getfile operation. Error: File Exists: E:\tmp\testfile.txt
Folder view shows a file testfile.txt 0 bytes. and it's locked (presumably by cf server)
It seems like the operation is creating the file stub, but has some problem writing to it, then complains that the file exists when cf created the file in the first place.
this is only in secure mode. in regular FTP mode, code runs perfectly.
Stack trace:
coldfusion.tagext.net.SftpHandler$SftpOperationException: An error occurred during the sFTP getfile operation.
at coldfusion.tagext.net.SftpHandler.checkError(SftpHandler.java:195)
at coldfusion.tagext.net.SftpHandler.getFile(SftpHandler.java:475)
at coldfusion.tagext.net.FtpTag.doStartTag(FtpTag.java:740)
at coldfusion.runtime.CfJspPage._emptyTcfTag(CfJspPage.java:2722)
at cffedexImport2ecfm385136567.runPage(E:\htdocs\Pmall_Admin\autoTasks\fedexImport.cfm:32)
at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:231)
at coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:416)
at coldfusion.filter.CfincludeFilter.invoke(CfincludeFilter.java:65)
at coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:381)
at coldfusion.filter.RequestMonitorFilter.invoke(RequestMonitorFilter.java:48)
at coldfusion.filter.MonitoringFilter.invoke(MonitoringFilter.java:40)
at coldfusion.filter.PathFilter.invoke(PathFilter.java:94)
at coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:70)
at coldfusion.filter.BrowserDebugFilter.invoke(BrowserDebugFilter.java:79)
at coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:28)
at coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:38)
at coldfusion.filter.NoCacheFilter.invoke(NoCacheFilter.java:46)
at coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:38)
at coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22)
at coldfusion.filter.CachingFilter.invoke(CachingFilter.java:62)
at coldfusion.CfmServlet.service(CfmServlet.java:200)
at coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:89)
at jrun.servlet.FilterChain.doFilter(FilterChain.java:86)
at coldfusion.monitor.event.MonitoringServletFilter.doFilter(MonitoringServletFilter.java:42)
at coldfusion.bootstrap.BootstrapFilter.doFilter(BootstrapFilter.java:46)
at jrun.servlet.FilterChain.doFilter(FilterChain.java:94)
at jrun.servlet.FilterChain.service(FilterChain.java:101)
at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:106)
at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)
at jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:286)
at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:543)
at jrun.servlet.jrpp.JRunProxyService.invokeRunnable(JRunProxyService.java:203)
at jrunx.scheduler.ThreadPool$DownstreamMetrics.invokeRunnable(ThreadPool.java:320)
at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:428)
at jrunx.scheduler.ThreadPool$UpstreamMetrics.invokeRunnable(ThreadPool.java:266)
at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)
Copy link to clipboard
Copied
additionally. running CF 9.0.1 CF user definitely has write permission since regular FTP works. Tried with a production SFTP server (Fedex) and local SFTP server (FreeFTPd)
thanks
Copy link to clipboard
Copied
True adding failIfExists="false" to your getFile command
Copy link to clipboard
Copied
well I'll be.....that "fixes" it. i still don't see why it fails in the first place though.
Copy link to clipboard
Copied
Because it is designed to work that way. FailIfExists defaults to yes. I suspect it is a fail-safe to keep from accidentally overwriting files. It would be easy enough to wrapp in a try/catch to handle. But it is not a bug. It works that way by design and is documented.
Copy link to clipboard
Copied
but i'm not overwriting anything. the local destination folder is completely blank. only after the cfftp get is there a 0byte stub file.
Copy link to clipboard
Copied
Ah, I missed that part. Perhaps it is a product of the way SFTP works. I would agree that that is a bug that should be reported.
http://cfbugs.adobe.com/cfbugreport/flexbugui/cfbugtracker/main.html
Copy link to clipboard
Copied
I'm having a similar issue with coldfusion 10 but the suggested solution does not help me.
I now get an error that says "The system cannot find the path foo.txt"
With the failifexists="true" (the default setting), it creates the file with zero length then fails. With failifexists="false", it doesn't seem to create the file at all and just errors on filenotfound.
I am doing CF Lockdown - but the coldfusion user absolutely has change privileges to that folder.
Copy link to clipboard
Copied
Hah, I figured out both of my problems....
My listDir operation was looking at a directory named "Out" but my getFile operation only said remotefile="#name#" and thus it actually could not find the remote file. I had to change it to remoteFile="Out/#name#"
Der!!!!