-// sortedClients is a utility function that takes a map of *ClientConn and returns a sorted slice of the values.
-// The purpose of this is to ensure that the ordering of client connections is deterministic so that test assertions work.
-func sortedClients(unsortedClients map[uint16]*ClientConn) (clients []*ClientConn) {
- for _, c := range unsortedClients {
- clients = append(clients, c)
+ case dlFldrActionSendFile:
+ if _, err := io.ReadFull(rwc, fileSize); err != nil {
+ return err
+ }
+
+ filePath := filepath.Join(fullPath, fu.FormattedPath())
+
+ hlFile, err := newFileWrapper(s.FS, filePath, 0)
+ if err != nil {
+ return err
+ }
+
+ rLogger.Info("Starting file transfer", "path", filePath, "fileNum", i+1, "fileSize", binary.BigEndian.Uint32(fileSize))
+
+ incWriter, err := hlFile.incFileWriter()
+ if err != nil {
+ return err
+ }
+
+ rForkWriter := io.Discard
+ iForkWriter := io.Discard
+ if s.Config.PreserveResourceForks {
+ iForkWriter, err = hlFile.infoForkWriter()
+ if err != nil {
+ return err
+ }
+
+ rForkWriter, err = hlFile.rsrcForkWriter()
+ if err != nil {
+ return err
+ }
+ }
+ if err := receiveFile(rwc, incWriter, rForkWriter, iForkWriter, fileTransfer.bytesSentCounter); err != nil {
+ return err
+ }
+
+ if err := os.Rename(filePath+".incomplete", filePath); err != nil {
+ return err
+ }
+ }
+
+ // Tell client to send next fileWrapper
+ if _, err := rwc.Write([]byte{0, dlFldrActionNextFile}); err != nil {
+ return err
+ }
+ }
+ }
+ rLogger.Info("Folder upload complete")