File tree Expand file tree Collapse file tree
thingsboard_gateway/connectors/ftp Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -59,6 +59,9 @@ def has_hash(self):
5959 return True if self ._hash else False
6060
6161 def get_current_hash (self , ftp ):
62+ # ftplib resets transfer type to ASCII after calling NLST (via retrlines).
63+ # SIZE requires binary mode, so we restore it explicitly before calling ftp.size().
64+ ftp .sendcmd ("TYPE I" )
6265 return crc32 ((ftp .voidcmd (f'MDTM { self ._path_to_file } ' ) + str (ftp .size (self .path_to_file ))).encode ('utf-8' ))
6366
6467 def set_new_hash (self , file_hash ):
@@ -72,4 +75,7 @@ def convert_bytes_to_mb(bts):
7275 return round (r , 2 )
7376
7477 def check_size_limit (self , ftp ):
78+ # ftplib resets transfer type to ASCII after calling NLST (via retrlines).
79+ # SIZE requires binary mode, so we restore it explicitly before calling ftp.size().
80+ ftp .sendcmd ("TYPE I" )
7581 return self .convert_bytes_to_mb (ftp .size (self .path_to_file )) < self ._max_size
You can’t perform that action at this time.
0 commit comments