11using MediaBrowser . Controller . Subtitles ;
22using SharpCompress . Archives ;
3+ using SharpCompress . Common ;
34using subbuzz . Configuration ;
45using subbuzz . Extensions ;
56using subbuzz . Helpers ;
@@ -66,7 +67,7 @@ public async Task<FileList> GetArchiveFiles(RequestSub link, CancellationToken c
6667 {
6768 try
6869 {
69- res . AddRange ( ReadArchive ( resp . Content ) ) ;
70+ res . AddRange ( ReadArchive ( resp . Content , resp . Info . FileName . GetPathExtension ( ) ) ) ;
7071 }
7172 catch
7273 {
@@ -157,12 +158,16 @@ public void AddResponseToCache(RequestCached link, Response resp)
157158 }
158159 }
159160
160- private FileList ReadArchive ( Stream content , string baseKey = null )
161+ private FileList ReadArchive ( Stream content , string ext , string baseKey = null )
161162 {
162163 var res = new FileList ( ) ;
163164
164165 using ( IArchive arcreader = ArchiveFactory . Open ( content ) )
165166 {
167+ // NOTE: fix issue with sharpcompress not able to detect properly tar archives
168+ if ( arcreader . Type == ArchiveType . Tar && ext . ToLower ( ) != "tar" )
169+ throw new InvalidOperationException ( "Decompress only tar files with tar extension" ) ;
170+
166171 foreach ( IArchiveEntry entry in arcreader . Entries )
167172 {
168173 if ( ! entry . IsDirectory )
@@ -181,7 +186,7 @@ private FileList ReadArchive(Stream content, string baseKey = null)
181186 try
182187 {
183188 // try to extract internal archives
184- res . AddRange ( ReadArchive ( info . Content , info . Name ) ) ;
189+ res . AddRange ( ReadArchive ( info . Content , info . Ext , info . Name ) ) ;
185190 info . Dispose ( ) ;
186191 }
187192 catch
0 commit comments