@@ -273,19 +273,38 @@ 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
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+ # 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
285+ offset = 0
286+ chunk_size = 32768 # 32KB
287+ eof = False
288+ file_data_total = b''
289+
290+ # 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 )
285293
286- # Write the data to the local file
294+ if "resfail" in file_data :
295+ raise Exception ("Insufficient Permissions" )
296+
297+ else :
298+ # Get the data and append it to the total file data
299+ data = file_data ["resok" ]["data" ]
300+ file_data_total += data
301+
302+ # Update the offset to read the next chunk
303+ offset += len (data )
304+
305+ # Write the complete file data to the local file
287306 with open (local_file_path , "wb+" ) as local_file :
288- local_file .write (data )
307+ local_file .write (file_data_total )
289308
290309 self .logger .highlight (f"File successfully downloaded to { local_file_path } from { remote_file_path } " )
291310
0 commit comments