@@ -110,6 +110,28 @@ func uploadFileCmd(index int, web webapi.Service, filename, token string) tea.Cm
110110 childHashes : file .ArchiveFiles ,
111111 }
112112 } else if forceRescanFlag {
113+ // Fetch the existing file to check if it's an archive.
114+ var file entity.File
115+ if err := web .GetFile (sha256 , & file ); err != nil {
116+ return fileUploadedMsg {index : index , err : fmt .Errorf ("get file: %w" , err )}
117+ }
118+
119+ if file .IsArchive && len (file .ArchiveFiles ) > 0 {
120+ // Archive: rescan each child, not the container itself.
121+ for _ , childHash := range file .ArchiveFiles {
122+ if err := web .Rescan (childHash , token , osFlag , enableDetonationFlag , timeoutFlag ); err != nil {
123+ return fileUploadedMsg {index : index , err : fmt .Errorf ("rescan child %s: %w" , childHash [:12 ], err )}
124+ }
125+ }
126+ return fileUploadedMsg {
127+ index : index ,
128+ sha256 : sha256 ,
129+ size : file .Size ,
130+ isArchive : true ,
131+ childHashes : file .ArchiveFiles ,
132+ }
133+ }
134+
113135 err = web .Rescan (sha256 , token , osFlag , enableDetonationFlag , timeoutFlag )
114136 if err != nil {
115137 return fileUploadedMsg {index : index , err : fmt .Errorf ("rescan: %w" , err )}
@@ -153,6 +175,27 @@ func delayedPollCmd(index int, web webapi.Service, sha256 string) tea.Cmd {
153175
154176func rescanFileCmd (index int , web webapi.Service , sha256 , token string ) tea.Cmd {
155177 return func () tea.Msg {
178+ // Check if the hash is an archive container.
179+ var file entity.File
180+ if err := web .GetFile (sha256 , & file ); err != nil {
181+ return fileUploadedMsg {index : index , err : fmt .Errorf ("get file: %w" , err )}
182+ }
183+
184+ if file .IsArchive && len (file .ArchiveFiles ) > 0 {
185+ for _ , childHash := range file .ArchiveFiles {
186+ if err := web .Rescan (childHash , token , osFlag , enableDetonationFlag , timeoutFlag ); err != nil {
187+ return fileUploadedMsg {index : index , err : fmt .Errorf ("rescan child %s: %w" , childHash [:12 ], err )}
188+ }
189+ }
190+ return fileUploadedMsg {
191+ index : index ,
192+ sha256 : sha256 ,
193+ size : file .Size ,
194+ isArchive : true ,
195+ childHashes : file .ArchiveFiles ,
196+ }
197+ }
198+
156199 err := web .Rescan (sha256 , token , osFlag , enableDetonationFlag , timeoutFlag )
157200 if err != nil {
158201 return fileUploadedMsg {index : index , err : fmt .Errorf ("rescan: %w" , err )}
0 commit comments