@@ -273,19 +273,31 @@ def get_file(self):
273273 self .auth ["uid" ] = attrs ["attributes" ]["uid" ]
274274 dir_handle = mnt_info ["mountinfo" ]["fhandle" ]
275275
276- # Get the file handle and read the file data
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_data = self .nfs3 .read (file_handle , auth = self .auth )
280279
281- if "resfail" in file_data :
282- raise Exception ("Insufficient Permissions" )
283- else :
284- data = file_data ["resok" ]["data" ]
280+ # Handle files over the default chunk size of 1024 * 1024
281+ offset = 0
282+ eof = False
285283
286- # Write the data to the local file
284+ # Loop until we have read the entire file
287285 with open (local_file_path , "wb+" ) as local_file :
288- local_file .write (data )
286+ while not eof :
287+ file_data = self .nfs3 .read (file_handle , offset , auth = self .auth )
288+
289+ if "resfail" in file_data :
290+ raise Exception ("Insufficient Permissions" )
291+
292+ else :
293+ # Get the data and append it to the total file data
294+ data = file_data ["resok" ]["data" ]
295+ eof = file_data ["resok" ]["eof" ]
296+
297+ # Update the offset to read the next chunk
298+ offset += len (data )
299+ # Write the file data to the local file
300+ local_file .write (data )
289301
290302 self .logger .highlight (f"File successfully downloaded to { local_file_path } from { remote_file_path } " )
291303
0 commit comments