@@ -527,43 +527,31 @@ func (m *model) extractFile() {
527527 }
528528}
529529
530- func (m * model ) compressFile () {
530+ func (m * model ) compressSelectedFiles () {
531531 panel := & m .fileModel .filePanels [m .filePanelFocusIndex ]
532532
533533 if len (panel .element ) == 0 {
534534 return
535535 }
536+ var filesToCompress []string
537+ var firstFile string
536538
537539 if len (panel .selected ) == 0 {
538- fileName := filepath .Base (panel .element [panel .cursor ].location )
539- zipName , err := getZipArchiveName (fileName )
540- if err != nil {
541- slog .Error ("Error in compressing files during rename duplicate" , "error" , err )
542- return
543- }
544-
545- src := panel .element [panel .cursor ].location
546- dst := filepath .Join (filepath .Dir (src ), zipName )
547- if err := zipSources ([]string {src }, dst ); err != nil {
548- slog .Error ("Error in zipping files" , "error" , err )
549- return
550- }
540+ firstFile = panel .element [panel .cursor ].location
541+ filesToCompress = append (filesToCompress , firstFile )
551542 } else {
552- first := panel .selected [0 ]
553- base := filepath .Base (first )
554- zipName , err := getZipArchiveName (base )
555- if err != nil {
556- slog .Error ("Error in compressing files during rename duplicate" , "error" , err )
557- return
558- }
559-
560- currentDir := filepath .Dir (panel .element [panel .cursor ].location )
561- dst := filepath .Join (currentDir , zipName )
562-
563- if err := zipSources (panel .selected , dst ); err != nil {
564- slog .Error ("Error in zipping files" , "error" , err )
565- return
566- }
543+ firstFile = panel .selected [0 ]
544+ filesToCompress = panel .selected
545+ }
546+ zipName , err := getZipArchiveName (filepath .Base (firstFile ))
547+ if err != nil {
548+ slog .Error ("Error in getZipArchiveName" , "error" , err )
549+ return
550+ }
551+ zipPath := filepath .Join (panel .location , zipName )
552+ if err := zipSources (filesToCompress , zipPath ); err != nil {
553+ slog .Error ("Error in zipping files" , "error" , err )
554+ return
567555 }
568556}
569557
0 commit comments