@@ -99,6 +99,7 @@ type Options struct {
9999 MulticastAddress string
100100 ShowQrCode bool
101101 Exclude []string
102+ ExcludeFile []string
102103 Quiet bool
103104 DisableClipboard bool
104105 ExtendedClipboard bool
@@ -770,6 +771,12 @@ func isChild(parentPath, childPath string) bool {
770771// This function retrieves the important file information
771772// for every file that will be transferred
772773func GetFilesInfo (fnames []string , zipfolder bool , ignoreGit bool , exclusions []string ) (filesInfo []FileInfo , emptyFolders []FileInfo , totalNumberFolders int , err error ) {
774+ return GetFilesInfoWithExactExclusions (fnames , zipfolder , ignoreGit , exclusions , nil )
775+ }
776+
777+ // GetFilesInfoWithExactExclusions retrieves file information while applying
778+ // both the legacy substring exclusions and exact relative-path exclusions.
779+ func GetFilesInfoWithExactExclusions (fnames []string , zipfolder bool , ignoreGit bool , exclusions , exactExclusions []string ) (filesInfo []FileInfo , emptyFolders []FileInfo , totalNumberFolders int , err error ) {
773780 // fnames: the relative/absolute paths of files/folders that will be transferred
774781 totalNumberFolders = 0
775782 var paths []string
@@ -845,7 +852,7 @@ func GetFilesInfo(fnames []string, zipfolder bool, ignoreGit bool, exclusions []
845852 }
846853 fpath = filepath .Dir (fpath )
847854 dest := filepath .Base (fpath ) + ".zip"
848- err = utils .ZipDirectory (dest , fpath , ignoredPaths , exclusions )
855+ err = utils .ZipDirectoryWithExactExclusions (dest , fpath , ignoredPaths , exclusions , exactExclusions )
849856 if err != nil {
850857 return
851858 }
@@ -891,6 +898,13 @@ func GetFilesInfo(fnames []string, zipfolder bool, ignoreGit bool, exclusions []
891898 if strings .HasSuffix (absPathWithSeparator , string (os .PathSeparator )+ string (os .PathSeparator )) {
892899 absPathWithSeparator = strings .TrimSuffix (absPathWithSeparator , string (os .PathSeparator ))
893900 }
901+ relPath , relErr := filepath .Rel (absPath , pathName )
902+ if relErr == nil && exactPathExcluded (exactExclusions , relPath ) {
903+ if info .IsDir () {
904+ return filepath .SkipDir
905+ }
906+ return nil
907+ }
894908 remoteFolder := strings .TrimPrefix (filepath .Dir (pathName ), absPathWithSeparator )
895909 if ! info .IsDir () {
896910 fInfo := FileInfo {
@@ -929,6 +943,9 @@ func GetFilesInfo(fnames []string, zipfolder bool, ignoreGit bool, exclusions []
929943 }
930944
931945 } else {
946+ if exactPathExcluded (exactExclusions , stat .Name ()) {
947+ continue
948+ }
932949 fInfo := FileInfo {
933950 Name : stat .Name (),
934951 FolderRemote : "./" ,
@@ -949,6 +966,16 @@ func GetFilesInfo(fnames []string, zipfolder bool, ignoreGit bool, exclusions []
949966 return
950967}
951968
969+ func exactPathExcluded (exclusions []string , candidate string ) bool {
970+ candidate = utils .NormalizeRelativePath (candidate )
971+ for _ , exclusion := range exclusions {
972+ if candidate == utils .NormalizeRelativePath (exclusion ) {
973+ return true
974+ }
975+ }
976+ return false
977+ }
978+
952979func (c * Client ) sendCollectFiles (filesInfo []FileInfo ) (err error ) {
953980 c .FilesToTransfer = filesInfo
954981 totalFilesSize := int64 (0 )
0 commit comments