NetTalk Central
NetTalk FTP => FTP - Ask For Help => Topic started by: rupertvz on July 10, 2018, 11:17:13 PM
-
Hi Guys,
I am following the NetTalk example to download a directory (all files) from an FTP server.
It is working well ...
How do I delete the files as being downloaded? To make sure we don't download duplicate files ...
-
use the DeleteFile(RemoteFileName) command;
http://www.capesoft.com/docs/NetTalk10/NetTalkFTP.Htm#Commands
Cheers
Bruce
-
Thanks Bruce,
I just need to confirm that the file was successfully downloaded, before deleting the remote-file.
Looking at the "GetNextFile" routine in the example app:
I've added the line below? (is this the correct place for adding the line)
GetNextFile Routine
data
found long
code
loop until records (ThisFTPControl.DirListingQ) = 0
QueueProgress += 1
get (ThisFTPControl.DirListingQ ,1)
If ThisFTPControl.DirListingQ.Attrib <> 0
conversation = '-- Ignoring Not-A-file : ' & clip(ThisFTPControl.DirListingQ.Name) & '<13,10>' & Conversation
delete (ThisFTPControl.DirListingQ)
cycle
end
conversation = '-- Fetching file : ' & clip(ThisFTPControl.DirListingQ.Name) & '<13,10>' & Conversation
ThisFTPControl.GetRemoteFile(clip (ThisFTPControl.DirListingQ.Name),clip(pParms.pLocalFileName) & '\' & ThisFTPControl.DirListingQ.Name)
?status{prop:text} = clip(pParms.pLocalFileName) & '\' & ThisFTPControl.DirListingQ.Name
ThisFTPControl.DeleteFile(ThisFTPControl.DirListingQ.Name)
delete (ThisFTPControl.DirListingQ)
found = 1
break
end
-
The GetRemoteFile command is asynchronous.
So the call there will _start_ it downloading.
Clearly you're not waiting for the result of the download, and not checking to see the file was "complete" (whatever that means), before scheduling the DeleteFile command. So the file will then be deleted regardless of the success of fail of the GetRemoteFile command.
I'd recommend inspecting the example to see where a file has been completely received, and then doing your tests, and call to DeleteFile there.
cheers
Bruce
-
Hi Bruce,
I am deleting the remote file as follows:
ThisFTPControl.DeleteFile(ThisFTPControl.DirListingQ.Name)
This is working, but next time I run the "GetDirectoryOverFtp" procedure, it picks up the same file name.
Which implies that the file was not initially deleted.
However, trying to the delete the file again, gives me:
"File Access Error.File Unavailable"
"No such File or Directory"
"The error number was -41 / 550 which means a general FTP error occured"
If the file was indeed deleted the first time round, why in a new thread does it pickup the same filename from the queue
"ThisFTPControl.DirListingQ.Name" ?
-
are you freeing the Queue between calls?
-
Hi Bruce,
I suspect the issue is related to deleting the file "too early", while the file in still in process somehow.
I am deleting the file in:
ThisFTPControl.Done PROCEDURE
After parent call
I check whether the file has been successfully saved to local disk, then delete the file.
The remote-file is successfully deleted, but the file-access error for this particular file pops up after a subsequent file is processed in the "done" procedure.
Is this the correct embed for deleting a remote file?
-
yes it's the correct embed.
I presume you wait for the DELETE to be DONE before you do the next command?
cheers
Bruce