async _performFileTransfer(normalizedPath, targetPath, remotePeer, parent) {
		let stream = null;
		let transferTimeout = null;
		let fileStream = null;
		
		try {
			// Normalize paths
			const realPath = (targetPath || normalizedPath).replace(/\\/g, '/');
			const filePath = ph.join(this.dataDirectory, realPath);
			const tmpPath = ph.join(this.dataDirectory, realPath.split('/').map(p => p + '.tmp').join('/'));
			
			// Validate target path is within data directory
			if (!filePath.startsWith(this.dataDirectory)) {
				throw new Error('File destination outside data directory');
			}

			// Create temporary directory for downloading
			logT('transfer', 'Creating temporary directory', ph.dirname(tmpPath));
			await mkdirp(ph.dirname(tmpPath));
			
			// Connect to peer if specified, otherwise try to find peer with file
			let peerToUse = remotePeer;
			if (!peerToUse) {
				logTE('transfer', 'No peer specified for transfer');
				return false;
			}
			
			// Get peer object
			const peerObj = this.peers.get(peerToUse)?.peer;
			if (!peerObj) {
				throw new Error(`Peer ${peerToUse} not found`);
			}
			
			// Open a direct stream to the peer for file transfer
			stream = await this.node.dialProtocol(peerObj, `${this.protocol}/file`);
			
			// Set up a timeout for the transfer
			transferTimeout = setTimeout(() => {
				logTE('transfer', 'Transfer timed out', normalizedPath);
				if (stream) {
					stream.abort(new Error('Transfer timeout'))
						.catch(err => logTE('transfer', 'Error aborting stream on timeout', err));
				}
			}, 60000); // 60-second timeout
			
			// Send the initial message with file info
			const fileInfoMsg = {
				filename: normalizedPath,
			};
			
			// Convert to buffer and send
			const fileInfoBuffer = Buffer.from(JSON.stringify(fileInfoMsg));
			await stream.sink([fileInfoBuffer]);

			let metadata;

			// Track if we received any data
			let dataReceived = false;
			let bytesReceived = 0;
			let expectedSize = 'unknown';

			for await (let chunk of stream.source) {
				chunk = chunk.subarray();

				if (!metadata) {
					metadata = JSON.parse(Buffer.from(chunk).toString());

					// Clear timeout since we got initial response
					clearTimeout(transferTimeout);
					transferTimeout = null;
					
					// Handle error response
					if (metadata.error) {
						const errorMsg = metadata.message || metadata.error;
						throw new Error(`Error from peer: ${errorMsg}`);
					}

					if (metadata.type === 'directory' && Array.isArray(metadata.files)) {
						return await this._handleDirectoryDownload(
							normalizedPath, 
							realPath, 
							filePath, 
							tmpPath, 
							metadata.files, 
							peerToUse
						);
					}

					if (metadata.type === 'file') {
						expectedSize = metadata.size || 'unknown';
						logT('transfer', `Starting file transfer (${expectedSize} bytes) for ${normalizedPath}`);
						// Create write stream with increased buffer size for better performance
						fileStream = fs.createWriteStream(tmpPath, {
							highWaterMark: 64 * 1024 // 64KB buffer
						});			
					} else {
						throw new Error('Unknown metadata type');
					}
				} else {
					if (metadata.type === 'file') {
								
						dataReceived = true;
						bytesReceived += chunk.length;
						
						// Periodic progress logging for large files
						if (bytesReceived > 1024 * 1024 && bytesReceived % (5 * 1024 * 1024) < chunk.length) {
							logT('transfer', `Downloaded ${(bytesReceived/1024/1024).toFixed(2)}MB of ${normalizedPath}`);
						}
						
						const success = fileStream.write(chunk);
						
						// Handle backpressure
						if (!success) {
							await new Promise(resolve => fileStream.once('drain', resolve));
						}
					} else {
						throw new Error('Unknown metadata type');
					}
				}
			}

			if (fileStream) {
				if (!dataReceived) {
					throw new Error('No data received for file');
				}

				await new Promise((resolve, reject) => {
					fileStream.end(err => {
						if (err) reject(err);
						else resolve();
					});
				});

				const renameCallback = async () => {
					try {
						await mkdirp(ph.dirname(filePath));
						fs.renameSync(tmpPath, filePath);
						logT('transfer', 'Successfully moved file from tmp to destination', filePath);
						return true;
					} catch (err) {
						logTE('transfer', 'Error moving file from tmp to destination', err);
						return false;
					}
				};
				
				// Return rename callback or execute it based on parent flag
				return parent ? renameCallback : await renameCallback();
			}
		} catch (err) {
			logTE('transfer', 'Error in transfer', normalizedPath, err);
			return false;
		} finally {
			// Clean up resources
			if (transferTimeout) {
				clearTimeout(transferTimeout);
			}
			if (fileStream) {
				fileStream.destroy();
			}
			if (stream) {
				try {
					await stream.close();
				} catch (err) {
					// Ignore errors during cleanup
				}
			}
		}

		return false;
	}
Perform a file transfer operation
@param {string} normalizedPath - Normalized file path
@param {string} targetPath - Target file path
@param {string} remotePeer - Remote peer ID
@param {boolean} parent - Whether this is a parent directory transfer
@returns {Promise<boolean|Function>} Success or rename callback
@private