0

Looking at corrupted files on FTP server I think about verifying files uploaded with TIdFtp.Put by downloading them just after upload and comparing byte-to byte.

I think that TIdFtp may be theoretically caching data and return it from cache instead of actually downloading.

Please allay or confirm my concerns.

Paul
  • 25,812
  • 38
  • 124
  • 247

1 Answers1

2

No, there is no caching, as there is no such thing in the FTP protocol in general. TIdFTP deals only with live data.

Are you, perhaps, uploading binary files in ASCII mode? If so, that would alter line break characters (CR and LF) during transmission. That is a common mistake to make, since ASCII is FTP's default mode. Make sure you are setting the TIdFTP.TransferType property as needed before transferring a file. ASCII mode should only be used for text files, if used at all.

And FWIW, you may not need to download a file to verify its bytes. If the server supports any X<Hash> commands (where Hash can be SHA512, SHA256, SHA1, MD5, or CRC) , TIdFTP has VerifyFile() methods to use them. That calculates a hash of a local file and then compares it to a hash calculated by the server for a remote file. No transfer of file data is needed.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
  • Thank you for your answer. There is nothing wrong with Indy or data being set. Customers just have very expensive, slow and unstable Internet connections by default and I have to put up with it. I am sending all the files in binary mode, even the text-based ones. I have to work with any FTP server. This time it is Pure-FTPd. Not all files are corrupted, but just about 5...7 of 1000...2000. There are skipped and unprintable characters right in the middle of XML. I will give a try to VerifyFile(). – Paul Nov 24 '18 at 18:15