@@ -273,30 +273,27 @@ def get_file(self):
273273 self .auth ["uid" ] = attrs ["attributes" ]["uid" ]
274274 dir_handle = mnt_info ["mountinfo" ]["fhandle" ]
275275
276- # Get the file handle
276+ # Get the file handle and file size
277277 dir_data = self .nfs3 .lookup (dir_handle , file_name , auth = self .auth )
278278 file_handle = dir_data ["resok" ]["object" ]["data" ]
279+ file_size = dir_data ["resok" ]["obj_attributes" ]["attributes" ]["size" ]
279280
280- # Get the file attributes (size)
281- file_attrs = self .nfs3 .getattr (file_handle , auth = self .auth )
282- file_size = file_attrs ["attributes" ]["size" ]
283-
284- # Handle files over 32768 bytes
281+ # Handle files over the default chunk size of 1024 * 1024
285282 offset = 0
286- chunk_size = 32768 # 32KB
287283 eof = False
288284 file_data_total = b''
289285
290286 # Loop until we have read the entire file
291- while offset < file_size :
292- file_data = self .nfs3 .read (file_handle , offset , chunk_size , auth = self .auth )
287+ while not eof :
288+ file_data = self .nfs3 .read (file_handle , offset , chunk_count = 1024 * 1024 , auth = self .auth )
293289
294290 if "resfail" in file_data :
295291 raise Exception ("Insufficient Permissions" )
296292
297293 else :
298294 # Get the data and append it to the total file data
299295 data = file_data ["resok" ]["data" ]
296+ eof = file_data ["resok" ]["eof" ]
300297 file_data_total += data
301298
302299 # Update the offset to read the next chunk
0 commit comments