]> git.r.bdr.sh - rbdr/mobius/commitdiff
Ran 'golangci-lint run -E gocritic,whitespace --fix' 🤞
authorJeff Halter <redacted>
Thu, 20 Apr 2023 00:21:18 +0000 (17:21 -0700)
committerJeff Halter <redacted>
Thu, 20 Apr 2023 00:21:18 +0000 (17:21 -0700)
cmd/mobius-hotline-client/main.go
cmd/mobius-hotline-server/main.go
hotline/client.go
hotline/file_store.go
hotline/files.go
hotline/flattened_file_object.go
hotline/server.go
hotline/transaction_handlers.go
hotline/transaction_handlers_test.go
hotline/ui.go

index 33100bf02457e75e7d7b6948800734cb916ecca5..72b581bb7634ad3508b473a0857d7a79daf3ee1b 100644 (file)
@@ -74,7 +74,6 @@ func main() {
        client := hotline.NewUIClient(*configDir, logger)
        client.DebugBuf = db
        client.UI.Start()
-
 }
 
 func newZapCore(level zapcore.Level, syncer zapcore.WriteSyncer) zapcore.Core {
index 4fa28c2a32e617aa2e01ad176fe20240765892ec..c5eea27749661b9c457ad2a49f7e084b47bee7b3 100644 (file)
@@ -87,7 +87,6 @@ func main() {
                                logger.Fatal(err)
                        }
                        logger.Infow("Config dir initialized at " + *configDir)
-
                } else {
                        logger.Infow("Existing config dir found.  Skipping initialization.")
                }
@@ -232,7 +231,6 @@ func copyDir(src, dst string) error {
                        }
                        f.Close()
                }
-
        }
 
        return nil
index fa204e2760887d636fb20d6d09509a40e2aebdb4..3598a002d999161f0321f93becac3e8ba4f25a0f 100644 (file)
@@ -317,7 +317,6 @@ func handleGetFileNameList(c *Client, t *Transaction) (res []Transaction, err er
                        node.SetReference(&fn)
                        root.AddChild(node)
                }
-
        }
 
        centerFlex := tview.NewFlex().
index 3c46faeb2d8e115eab6d70bc719194e7366bb383..1525e2e473fd6c84d0eddd8e95bc5945c62043ed 100644 (file)
@@ -80,7 +80,6 @@ func (mfs *MockFileStore) Stat(name string) (os.FileInfo, error) {
        args := mfs.Called(name)
        if args.Get(0) == nil {
                return nil, args.Error(1)
-
        }
        return args.Get(0).(os.FileInfo), args.Error(1)
 }
index 1eeef593b8536709708932245264da992a7d38aa..9c3efe2e182cc5ff45caa9c1c50e914d5c814f29 100644 (file)
@@ -78,14 +78,13 @@ func getFileNameList(path string, ignoreList []string) (fields []Field, err erro
                                }
 
                                binary.BigEndian.PutUint32(fnwi.FileSize[:], c)
-                               copy(fnwi.Type[:], []byte("fldr")[:])
-                               copy(fnwi.Creator[:], fileCreator[:])
+                               copy(fnwi.Type[:], []byte("fldr"))
+                               copy(fnwi.Creator[:], fileCreator)
                        } else {
                                binary.BigEndian.PutUint32(fnwi.FileSize[:], uint32(rFile.Size()))
-                               copy(fnwi.Type[:], []byte(fileTypeFromFilename(rFile.Name()).TypeCode)[:])
-                               copy(fnwi.Creator[:], []byte(fileTypeFromFilename(rFile.Name()).CreatorCode)[:])
+                               copy(fnwi.Type[:], []byte(fileTypeFromFilename(rFile.Name()).TypeCode))
+                               copy(fnwi.Creator[:], []byte(fileTypeFromFilename(rFile.Name()).CreatorCode))
                        }
-
                } else if file.IsDir() {
                        dir, err := os.ReadDir(filepath.Join(path, file.Name()))
                        if err != nil {
@@ -100,8 +99,8 @@ func getFileNameList(path string, ignoreList []string) (fields []Field, err erro
                        }
 
                        binary.BigEndian.PutUint32(fnwi.FileSize[:], c)
-                       copy(fnwi.Type[:], []byte("fldr")[:])
-                       copy(fnwi.Creator[:], fileCreator[:])
+                       copy(fnwi.Type[:], []byte("fldr"))
+                       copy(fnwi.Creator[:], fileCreator)
                } else {
                        // the Hotline protocol does not support fileWrapper sizes > 4GiB due to the 4 byte field size, so skip them
                        if fileInfo.Size() > 4294967296 {
@@ -113,16 +112,16 @@ func getFileNameList(path string, ignoreList []string) (fields []Field, err erro
                                return nil, err
                        }
 
-                       copy(fnwi.FileSize[:], hlFile.totalSize()[:])
-                       copy(fnwi.Type[:], hlFile.ffo.FlatFileInformationFork.TypeSignature[:])
-                       copy(fnwi.Creator[:], hlFile.ffo.FlatFileInformationFork.CreatorSignature[:])
+                       copy(fnwi.FileSize[:], hlFile.totalSize())
+                       copy(fnwi.Type[:], hlFile.ffo.FlatFileInformationFork.TypeSignature)
+                       copy(fnwi.Creator[:], hlFile.ffo.FlatFileInformationFork.CreatorSignature)
                }
 
                strippedName := strings.Replace(file.Name(), ".incomplete", "", -1)
 
                nameSize := make([]byte, 2)
                binary.BigEndian.PutUint16(nameSize, uint16(len(strippedName)))
-               copy(fnwi.NameSize[:], nameSize[:])
+               copy(fnwi.NameSize[:], nameSize)
 
                fnwi.name = []byte(strippedName)
 
index 63a189a3df88fba06baf1efe1e2ca6e6c9966c66..c57de19fea4063a91e5f5b9a8e1a27cf009550f7 100644 (file)
@@ -110,7 +110,7 @@ func (ffo *flattenedFileObject) TransferSize(offset int64) []byte {
        resForkSize := binary.BigEndian.Uint32(ffo.FlatFileResForkHeader.DataSize[:])
 
        size := make([]byte, 4)
-       binary.BigEndian.PutUint32(size[:], dataSize+resForkSize+uint32(payloadSize)-uint32(offset))
+       binary.BigEndian.PutUint32(size, dataSize+resForkSize+uint32(payloadSize)-uint32(offset))
 
        return size
 }
index 4b36cf67dff2a2de05d69f59a0045aa9d5685a5b..500087a96159b171626b23198e978181c5b2ecc1 100644 (file)
@@ -105,7 +105,6 @@ func (s *Server) ListenAndServe(ctx context.Context, cancelRoot context.CancelFu
                ln, err := net.Listen("tcp", fmt.Sprintf("%s:%v", "", s.Port+1))
                if err != nil {
                        s.Logger.Fatal(err)
-
                }
 
                s.Logger.Fatal(s.ServeFileTransfers(ctx, ln))
@@ -740,7 +739,7 @@ func (s *Server) NewPrivateChat(cc *ClientConn) []byte {
 
        randID := make([]byte, 4)
        rand.Read(randID)
-       data := binary.BigEndian.Uint32(randID[:])
+       data := binary.BigEndian.Uint32(randID)
 
        s.PrivateChats[data] = &PrivateChat{
                ClientConn: make(map[uint16]*ClientConn),
index 813d25c072185ab9f80f32915a702d28a7777da5..137b2a0583ce2288f180cc07f37a572b1654360e 100644 (file)
@@ -808,7 +808,7 @@ func HandleUpdateUser(cc *ClientConn, t *Transaction) (res []Transaction, err er
                        }
 
                        newAccess := accessBitmap{}
-                       copy(newAccess[:], getField(FieldUserAccess, &subFields).Data[:])
+                       copy(newAccess[:], getField(FieldUserAccess, &subFields).Data)
 
                        // Prevent account from creating new account with greater permission
                        for i := 0; i < 64; i++ {
@@ -846,7 +846,7 @@ func HandleNewUser(cc *ClientConn, t *Transaction) (res []Transaction, err error
        }
 
        newAccess := accessBitmap{}
-       copy(newAccess[:], t.GetField(FieldUserAccess).Data[:])
+       copy(newAccess[:], t.GetField(FieldUserAccess).Data)
 
        // Prevent account from creating new account with greater permission
        for i := 0; i < 64; i++ {
@@ -1605,7 +1605,6 @@ func HandleUploadFile(cc *ClientConn, t *Transaction) (res []Transaction, err er
 
        // client has requested to resume a partially transferred file
        if transferOptions != nil {
-
                fileInfo, err := cc.Server.FS.Stat(fullFilePath + incompleteFileSuffix)
                if err != nil {
                        return res, err
index 751590e7aff710809a7996d80f5b0ffec592c337..ff1a53c37d08ea2243d38428e112779e4f9a5d48 100644 (file)
@@ -1056,7 +1056,6 @@ func TestHandleNewFolder(t *testing.T) {
        }
        for _, tt := range tests {
                t.Run(tt.name, func(t *testing.T) {
-
                        gotRes, err := HandleNewFolder(tt.args.cc, tt.args.t)
                        if (err != nil) != tt.wantErr {
                                t.Errorf("HandleNewFolder() error = %v, wantErr %v", err, tt.wantErr)
@@ -1175,7 +1174,6 @@ func TestHandleUploadFile(t *testing.T) {
                        }
 
                        tranAssertEqual(t, tt.wantRes, gotRes)
-
                })
        }
 }
@@ -3781,7 +3779,6 @@ func TestHandleGetNewsArtNameList(t *testing.T) {
                                return
                        }
                        tranAssertEqual(t, tt.wantRes, gotRes)
-
                })
        }
 }
@@ -3942,7 +3939,7 @@ func TestHandleNewNewsFldr(t *testing.T) {
                //              },
                //      },
                //      wantErr: assert.Error,
-               //},
+               // },
        }
        for _, tt := range tests {
                t.Run(tt.name, func(t *testing.T) {
index 45c452cbbeaea6d2aec2788e0c7e60573b8daa63..a60aad28ddf82f6728f750174c1ee31d58b11b40 100644 (file)
@@ -350,7 +350,6 @@ func (ui *UI) renderServerUI() *tview.Flex {
 
                // Post news
                if event.Key() == tcell.KeyCtrlP {
-
                        newsFlex := tview.NewFlex()
                        newsFlex.SetBorderPadding(0, 0, 1, 1)
                        newsPostTextArea := tview.NewTextView()