python - pysftp: how to get remote folder size -


how size of remote folder when using pysftp?

the object return stat seems doesn't looks right, code:

fdstat = sftpclient.stat(remotepath); print(fdstat.st_size); 

output:

drwxr-xr-x   1 0        99           4096 21 sep 11:13 ? 4096 

=> folder remotepath huge , it's size larger 4096.

the .stat method returns same information *nix ls command. size here represents size of data, directory (= metadata contained files) occupies on disk. it's not size of contained files.

there's no direct way obtain total size of files in directory using single call in pysftp or sftp protocol in general.

all can list directory (recursively if needed) , sum sizes of individual files.


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -