File tree Expand file tree Collapse file tree 1 file changed +22
-8
lines changed
src/Files.App/Actions/Content/Archives/Decompress Expand file tree Collapse file tree 1 file changed +22
-8
lines changed Original file line number Diff line number Diff line change @@ -91,15 +91,29 @@ protected async Task DecompressArchiveHereAsync(bool smart = false)
9191 if ( zipFile is null )
9292 return true ;
9393
94- return zipFile . ArchiveFileData . Select ( file =>
94+ static string ? GetFirstMeaningfulSegment ( string ? fileName )
9595 {
96- var pathCharIndex = file . FileName . IndexOfAny ( [ '/' , '\\ ' ] ) ;
97- if ( pathCharIndex == - 1 )
98- return file . FileName ;
99- else
100- return file . FileName . Substring ( 0 , pathCharIndex ) ;
101- } )
102- . Distinct ( ) . Count ( ) > 1 ;
96+ if ( string . IsNullOrEmpty ( fileName ) )
97+ return null ;
98+
99+ var parts = fileName . Split ( [ '/' , '\\ ' ] , StringSplitOptions . RemoveEmptyEntries ) ;
100+ foreach ( var part in parts )
101+ {
102+ if ( part is "." or ".." )
103+ continue ;
104+ return part ;
105+ }
106+
107+ return null ;
108+ }
109+
110+ var topLevelEntries = zipFile . ArchiveFileData
111+ . Select ( file => GetFirstMeaningfulSegment ( file . FileName ) )
112+ . Where ( x => ! string . IsNullOrEmpty ( x ) )
113+ . Distinct ( )
114+ . Count ( ) ;
115+
116+ return topLevelEntries > 1 ;
103117 } ) ;
104118
105119 if ( smart && currentFolder is not null && isMultipleItems )
You can’t perform that action at this time.
0 commit comments