@@ -969,158 +969,157 @@ public async Task LoadExtendedItemPropertiesAsync(ListedItem item)
969
969
970
970
try
971
971
{
972
- await Task . Run ( async ( ) =>
973
- {
974
- if ( itemLoadQueue . TryGetValue ( item . ItemPath , out var canceled ) && canceled )
975
- return ;
972
+ cts . Token . ThrowIfCancellationRequested ( ) ;
973
+ if ( itemLoadQueue . TryGetValue ( item . ItemPath , out var canceled ) && canceled )
974
+ return ;
976
975
977
- item . ItemPropertiesInitialized = true ;
978
- var wasSyncStatusLoaded = false ;
979
- var loadGroupHeaderInfo = false ;
980
- ImageSource ? groupImage = null ;
981
- GroupedCollection < ListedItem > ? gp = null ;
976
+ item . ItemPropertiesInitialized = true ;
977
+ var wasSyncStatusLoaded = false ;
978
+ var loadGroupHeaderInfo = false ;
979
+ ImageSource ? groupImage = null ;
980
+ GroupedCollection < ListedItem > ? gp = null ;
982
981
983
- try
982
+ try
983
+ {
984
+ var isFileTypeGroupMode = folderSettings . DirectoryGroupOption == GroupOption . FileType ;
985
+ BaseStorageFile ? matchingStorageFile = null ;
986
+ if ( item . Key is not null && FilesAndFolders . IsGrouped && FilesAndFolders . GetExtendedGroupHeaderInfo is not null )
984
987
{
985
- var isFileTypeGroupMode = folderSettings . DirectoryGroupOption == GroupOption . FileType ;
986
- BaseStorageFile ? matchingStorageFile = null ;
987
- if ( item . Key is not null && FilesAndFolders . IsGrouped && FilesAndFolders . GetExtendedGroupHeaderInfo is not null )
988
- {
989
- gp = FilesAndFolders . GroupedCollection ? . ToList ( ) . Where ( x => x . Model . Key == item . Key ) . FirstOrDefault ( ) ;
990
- loadGroupHeaderInfo = gp is not null && ! gp . Model . Initialized && gp . GetExtendedGroupHeaderInfo is not null ;
991
- }
988
+ gp = FilesAndFolders . GroupedCollection ? . ToList ( ) . Where ( x => x . Model . Key == item . Key ) . FirstOrDefault ( ) ;
989
+ loadGroupHeaderInfo = gp is not null && ! gp . Model . Initialized && gp . GetExtendedGroupHeaderInfo is not null ;
990
+ }
992
991
993
- cts . Token . ThrowIfCancellationRequested ( ) ;
994
- _ = LoadThumbnailAsync ( item ) ;
992
+ cts . Token . ThrowIfCancellationRequested ( ) ;
993
+ await LoadThumbnailAsync ( item ) ;
995
994
996
- if ( item . IsLibrary || item . PrimaryItemAttribute == StorageItemTypes . File || item . IsArchive )
995
+ cts . Token . ThrowIfCancellationRequested ( ) ;
996
+ if ( item . IsLibrary || item . PrimaryItemAttribute == StorageItemTypes . File || item . IsArchive )
997
+ {
998
+ if ( ! item . IsShortcut && ! item . IsHiddenItem && ! FtpHelpers . IsFtpPath ( item . ItemPath ) )
997
999
{
998
- if ( ! item . IsShortcut && ! item . IsHiddenItem && ! FtpHelpers . IsFtpPath ( item . ItemPath ) )
1000
+ matchingStorageFile = await GetFileFromPathAsync ( item . ItemPath , cts . Token ) ;
1001
+ if ( matchingStorageFile is not null )
999
1002
{
1000
- matchingStorageFile = await GetFileFromPathAsync ( item . ItemPath , cts . Token ) ;
1001
- if ( matchingStorageFile is not null )
1002
- {
1003
- cts . Token . ThrowIfCancellationRequested ( ) ;
1003
+ cts . Token . ThrowIfCancellationRequested ( ) ;
1004
1004
1005
- var syncStatus = await CheckCloudDriveSyncStatusAsync ( matchingStorageFile ) ;
1006
- var fileFRN = await FileTagsHelper . GetFileFRN ( matchingStorageFile ) ;
1007
- var fileTag = FileTagsHelper . ReadFileTag ( item . ItemPath ) ;
1008
- var itemType = ( item . ItemType == "Folder" . GetLocalizedResource ( ) ) ? item . ItemType : matchingStorageFile . DisplayType ;
1005
+ var syncStatus = await CheckCloudDriveSyncStatusAsync ( matchingStorageFile ) ;
1006
+ var fileFRN = await FileTagsHelper . GetFileFRN ( matchingStorageFile ) ;
1007
+ var fileTag = FileTagsHelper . ReadFileTag ( item . ItemPath ) ;
1008
+ var itemType = ( item . ItemType == "Folder" . GetLocalizedResource ( ) ) ? item . ItemType : matchingStorageFile . DisplayType ;
1009
1009
1010
- cts . Token . ThrowIfCancellationRequested ( ) ;
1010
+ cts . Token . ThrowIfCancellationRequested ( ) ;
1011
1011
1012
- await dispatcherQueue . EnqueueOrInvokeAsync ( ( ) =>
1013
- {
1014
- item . FolderRelativeId = matchingStorageFile . FolderRelativeId ;
1015
- item . ItemType = itemType ;
1016
- item . SyncStatusUI = CloudDriveSyncStatusUI . FromCloudDriveSyncStatus ( syncStatus ) ;
1017
- item . FileFRN = fileFRN ;
1018
- item . FileTags = fileTag ;
1019
- item . IsElevationRequired = CheckElevationRights ( item ) ;
1020
- } ,
1021
- Microsoft . UI . Dispatching . DispatcherQueuePriority . Low ) ;
1022
-
1023
- SetFileTag ( item ) ;
1024
- wasSyncStatusLoaded = true ;
1025
- }
1012
+ await dispatcherQueue . EnqueueOrInvokeAsync ( ( ) =>
1013
+ {
1014
+ item . FolderRelativeId = matchingStorageFile . FolderRelativeId ;
1015
+ item . ItemType = itemType ;
1016
+ item . SyncStatusUI = CloudDriveSyncStatusUI . FromCloudDriveSyncStatus ( syncStatus ) ;
1017
+ item . FileFRN = fileFRN ;
1018
+ item . FileTags = fileTag ;
1019
+ item . IsElevationRequired = CheckElevationRights ( item ) ;
1020
+ } ,
1021
+ Microsoft . UI . Dispatching . DispatcherQueuePriority . Low ) ;
1022
+
1023
+ SetFileTag ( item ) ;
1024
+ wasSyncStatusLoaded = true ;
1026
1025
}
1027
1026
}
1028
- else
1027
+ }
1028
+ else
1029
+ {
1030
+ if ( ! item . IsShortcut && ! item . IsHiddenItem && ! FtpHelpers . IsFtpPath ( item . ItemPath ) )
1029
1031
{
1030
- if ( ! item . IsShortcut && ! item . IsHiddenItem && ! FtpHelpers . IsFtpPath ( item . ItemPath ) )
1032
+ BaseStorageFolder matchingStorageFolder = await GetFolderFromPathAsync ( item . ItemPath , cts . Token ) ;
1033
+ if ( matchingStorageFolder is not null )
1031
1034
{
1032
- BaseStorageFolder matchingStorageFolder = await GetFolderFromPathAsync ( item . ItemPath , cts . Token ) ;
1033
- if ( matchingStorageFolder is not null )
1035
+ if ( matchingStorageFolder . DisplayName != item . Name && ! matchingStorageFolder . DisplayName . StartsWith ( "$R" , StringComparison . Ordinal ) )
1034
1036
{
1035
- if ( matchingStorageFolder . DisplayName != item . Name && ! matchingStorageFolder . DisplayName . StartsWith ( "$R" , StringComparison . Ordinal ) )
1036
- {
1037
- cts . Token . ThrowIfCancellationRequested ( ) ;
1038
- await dispatcherQueue . EnqueueOrInvokeAsync ( ( ) =>
1039
- {
1040
- item . ItemNameRaw = matchingStorageFolder . DisplayName ;
1041
- } ) ;
1042
- await fileListCache . SaveFileDisplayNameToCache ( item . ItemPath , matchingStorageFolder . DisplayName ) ;
1043
- if ( folderSettings . DirectorySortOption == SortOption . Name && ! isLoadingItems )
1044
- {
1045
- await OrderFilesAndFoldersAsync ( ) ;
1046
- await ApplyFilesAndFoldersChangesAsync ( ) ;
1047
- }
1048
- }
1049
-
1050
- cts . Token . ThrowIfCancellationRequested ( ) ;
1051
- var syncStatus = await CheckCloudDriveSyncStatusAsync ( matchingStorageFolder ) ;
1052
- var fileFRN = await FileTagsHelper . GetFileFRN ( matchingStorageFolder ) ;
1053
- var fileTag = FileTagsHelper . ReadFileTag ( item . ItemPath ) ;
1054
- var itemType = ( item . ItemType == "Folder" . GetLocalizedResource ( ) ) ? item . ItemType : matchingStorageFolder . DisplayType ;
1055
1037
cts . Token . ThrowIfCancellationRequested ( ) ;
1056
-
1057
1038
await dispatcherQueue . EnqueueOrInvokeAsync ( ( ) =>
1058
1039
{
1059
- item . FolderRelativeId = matchingStorageFolder . FolderRelativeId ;
1060
- item . ItemType = itemType ;
1061
- item . SyncStatusUI = CloudDriveSyncStatusUI . FromCloudDriveSyncStatus ( syncStatus ) ;
1062
- item . FileFRN = fileFRN ;
1063
- item . FileTags = fileTag ;
1064
- } ,
1065
- Microsoft . UI . Dispatching . DispatcherQueuePriority . Low ) ;
1066
-
1067
- SetFileTag ( item ) ;
1068
- wasSyncStatusLoaded = true ;
1040
+ item . ItemNameRaw = matchingStorageFolder . DisplayName ;
1041
+ } ) ;
1042
+ await fileListCache . SaveFileDisplayNameToCache ( item . ItemPath , matchingStorageFolder . DisplayName ) ;
1043
+ if ( folderSettings . DirectorySortOption == SortOption . Name && ! isLoadingItems )
1044
+ {
1045
+ await OrderFilesAndFoldersAsync ( ) ;
1046
+ await ApplyFilesAndFoldersChangesAsync ( ) ;
1047
+ }
1069
1048
}
1070
- }
1071
- }
1072
1049
1073
- if ( loadGroupHeaderInfo && isFileTypeGroupMode )
1074
- groupImage = await GetItemTypeGroupIcon ( item , matchingStorageFile ) ;
1075
- }
1076
- catch ( Exception )
1077
- {
1078
- }
1079
- finally
1080
- {
1081
- if ( ! wasSyncStatusLoaded )
1082
- {
1083
- cts . Token . ThrowIfCancellationRequested ( ) ;
1084
- await FilesystemTasks . Wrap ( async ( ) =>
1085
- {
1050
+ cts . Token . ThrowIfCancellationRequested ( ) ;
1051
+ var syncStatus = await CheckCloudDriveSyncStatusAsync ( matchingStorageFolder ) ;
1052
+ var fileFRN = await FileTagsHelper . GetFileFRN ( matchingStorageFolder ) ;
1086
1053
var fileTag = FileTagsHelper . ReadFileTag ( item . ItemPath ) ;
1054
+ var itemType = ( item . ItemType == "Folder" . GetLocalizedResource ( ) ) ? item . ItemType : matchingStorageFolder . DisplayType ;
1055
+ cts . Token . ThrowIfCancellationRequested ( ) ;
1087
1056
1088
1057
await dispatcherQueue . EnqueueOrInvokeAsync ( ( ) =>
1089
1058
{
1090
- // Reset cloud sync status icon
1091
- item . SyncStatusUI = new CloudDriveSyncStatusUI ( ) ;
1092
-
1059
+ item . FolderRelativeId = matchingStorageFolder . FolderRelativeId ;
1060
+ item . ItemType = itemType ;
1061
+ item . SyncStatusUI = CloudDriveSyncStatusUI . FromCloudDriveSyncStatus ( syncStatus ) ;
1062
+ item . FileFRN = fileFRN ;
1093
1063
item . FileTags = fileTag ;
1094
1064
} ,
1095
1065
Microsoft . UI . Dispatching . DispatcherQueuePriority . Low ) ;
1096
1066
1097
1067
SetFileTag ( item ) ;
1098
- } ) ;
1068
+ wasSyncStatusLoaded = true ;
1069
+ }
1099
1070
}
1100
- else
1071
+ }
1072
+
1073
+ if ( loadGroupHeaderInfo && isFileTypeGroupMode )
1074
+ groupImage = await GetItemTypeGroupIcon ( item , matchingStorageFile ) ;
1075
+ }
1076
+ catch ( Exception )
1077
+ {
1078
+ }
1079
+ finally
1080
+ {
1081
+ if ( ! wasSyncStatusLoaded )
1082
+ {
1083
+ cts . Token . ThrowIfCancellationRequested ( ) ;
1084
+ await FilesystemTasks . Wrap ( async ( ) =>
1101
1085
{
1102
- // Try loading thumbnail for cloud files in case they weren't cached the first time
1103
- if ( item . SyncStatusUI . SyncStatus != CloudDriveSyncStatus . NotSynced && item . SyncStatusUI . SyncStatus != CloudDriveSyncStatus . Unknown )
1086
+ var fileTag = FileTagsHelper . ReadFileTag ( item . ItemPath ) ;
1087
+
1088
+ await dispatcherQueue . EnqueueOrInvokeAsync ( ( ) =>
1104
1089
{
1105
- _ = Task . Run ( async ( ) => {
1106
- await Task . Delay ( 500 ) ;
1107
- await LoadThumbnailAsync ( item ) ;
1108
- } ) ;
1109
- }
1110
- }
1090
+ // Reset cloud sync status icon
1091
+ item . SyncStatusUI = new CloudDriveSyncStatusUI ( ) ;
1111
1092
1112
- if ( loadGroupHeaderInfo )
1093
+ item . FileTags = fileTag ;
1094
+ } ,
1095
+ Microsoft . UI . Dispatching . DispatcherQueuePriority . Low ) ;
1096
+
1097
+ SetFileTag ( item ) ;
1098
+ } ) ;
1099
+ }
1100
+ else
1101
+ {
1102
+ // Try loading thumbnail for cloud files in case they weren't cached the first time
1103
+ if ( item . SyncStatusUI . SyncStatus != CloudDriveSyncStatus . NotSynced && item . SyncStatusUI . SyncStatus != CloudDriveSyncStatus . Unknown )
1113
1104
{
1114
- cts . Token . ThrowIfCancellationRequested ( ) ;
1115
- await SafetyExtensions . IgnoreExceptions ( ( ) =>
1116
- dispatcherQueue . EnqueueOrInvokeAsync ( ( ) =>
1117
- {
1118
- gp . Model . ImageSource = groupImage ;
1119
- gp . InitializeExtendedGroupHeaderInfoAsync ( ) ;
1120
- } ) ) ;
1105
+ _ = Task . Run ( async ( ) => {
1106
+ await Task . Delay ( 500 ) ;
1107
+ await LoadThumbnailAsync ( item ) ;
1108
+ } ) ;
1121
1109
}
1122
1110
}
1123
- } , cts . Token ) ;
1111
+
1112
+ if ( loadGroupHeaderInfo )
1113
+ {
1114
+ cts . Token . ThrowIfCancellationRequested ( ) ;
1115
+ await SafetyExtensions . IgnoreExceptions ( ( ) =>
1116
+ dispatcherQueue . EnqueueOrInvokeAsync ( ( ) =>
1117
+ {
1118
+ gp . Model . ImageSource = groupImage ;
1119
+ gp . InitializeExtendedGroupHeaderInfoAsync ( ) ;
1120
+ } ) ) ;
1121
+ }
1122
+ }
1124
1123
}
1125
1124
catch ( OperationCanceledException )
1126
1125
{
0 commit comments