From 8b176e20f95337377824dbb991b080903b848b1d Mon Sep 17 00:00:00 2001 From: Harmon Date: Tue, 12 Jan 2021 14:01:13 -0600 Subject: [PATCH] Reuse previously determined file size in API.chunked_upload Fixes file size determination with file parameter --- tweepy/api.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tweepy/api.py b/tweepy/api.py index c69fd44..d62b222 100644 --- a/tweepy/api.py +++ b/tweepy/api.py @@ -296,8 +296,7 @@ class API: chunk_size = kwargs.pop('chunk_size', DEFAULT_CHUNKSIZE) chunk_size = max(min(chunk_size, MAX_CHUNKSIZE), MIN_CHUNKSIZE) - fsize = os.path.getsize(filename) - segments = int(fsize / chunk_size / 1024.0) + (1 if fsize % chunk_size > 0 else 0) + segments = int(file_size / chunk_size / 1024.0) + (1 if file_size % chunk_size > 0 else 0) for segment_index in range(segments): # The APPEND command returns an empty response body -- 2.25.1