@@ -1818,7 +1818,6 @@ private async void ProcessOperationQueue(CancellationToken cancellationToken, bo
1818
1818
const uint FILE_ACTION_RENAMED_NEW_NAME = 0x00000005 ;
1819
1819
1820
1820
var sampler = new IntervalSampler ( 200 ) ;
1821
- var updateList = new HashSet < string > ( ) ;
1822
1821
bool anyEdits = false ;
1823
1822
1824
1823
try
@@ -1828,8 +1827,8 @@ private async void ProcessOperationQueue(CancellationToken cancellationToken, bo
1828
1827
if ( operationEvent . Wait ( 200 , cancellationToken ) )
1829
1828
{
1830
1829
operationEvent . Reset ( ) ;
1830
+ var updateList = new HashSet < string > ( ) ;
1831
1831
1832
- processQueue :
1833
1832
while ( operationQueue . TryDequeue ( out var operation ) )
1834
1833
{
1835
1834
if ( cancellationToken . IsCancellationRequested ) break ;
@@ -1867,16 +1866,7 @@ private async void ProcessOperationQueue(CancellationToken cancellationToken, bo
1867
1866
}
1868
1867
}
1869
1868
1870
- foreach ( var entry in updateList . ToList ( ) )
1871
- {
1872
- await UpdateFileOrFolderAsync ( entry , hasSyncStatus ) ;
1873
- updateList . Remove ( entry ) ;
1874
-
1875
- if ( sampler . CheckNow ( ) && operationQueue . Any ( i => i . Action != FILE_ACTION_MODIFIED ) )
1876
- {
1877
- goto processQueue ;
1878
- }
1879
- }
1869
+ await UpdateFilesOrFoldersAsync ( updateList , hasSyncStatus ) ;
1880
1870
}
1881
1871
1882
1872
if ( anyEdits )
@@ -2030,7 +2020,7 @@ private async Task AddFileOrFolderAsync(string fileOrFolderPath, string dateRetu
2030
2020
await AddFileOrFolderAsync ( listedItem ) ;
2031
2021
}
2032
2022
2033
- private async Task UpdateFileOrFolderAsync ( ListedItem item , bool hasSyncStatus = false )
2023
+ private async Task < ( ListedItem Item , CloudDriveSyncStatusUI SyncUI , long ? Size , DateTimeOffset Created , DateTimeOffset Modified ) ? > UpdateFileOrFolderAsync ( ListedItem item , bool hasSyncStatus = false )
2034
2024
{
2035
2025
IStorageItem storageItem = null ;
2036
2026
if ( item . PrimaryItemAttribute == StorageItemTypes . File )
@@ -2043,33 +2033,31 @@ private async Task UpdateFileOrFolderAsync(ListedItem item, bool hasSyncStatus =
2043
2033
}
2044
2034
if ( storageItem != null )
2045
2035
{
2046
- var syncStatus = hasSyncStatus ? await CheckCloudDriveSyncStatusAsync ( storageItem ) : CloudDriveSyncStatus . NotSynced ;
2047
- await CoreApplication . MainView . DispatcherQueue . EnqueueAsync ( async ( ) =>
2036
+ CloudDriveSyncStatusUI syncUI = hasSyncStatus ? CloudDriveSyncStatusUI . FromCloudDriveSyncStatus ( await CheckCloudDriveSyncStatusAsync ( storageItem ) ) : null ;
2037
+ long ? size = null ;
2038
+ DateTimeOffset created = default , modified = default ;
2039
+
2040
+ if ( storageItem . IsOfType ( StorageItemTypes . File ) )
2048
2041
{
2049
- if ( hasSyncStatus )
2050
- {
2051
- item . SyncStatusUI = CloudDriveSyncStatusUI . FromCloudDriveSyncStatus ( syncStatus ) ;
2052
- }
2042
+ var properties = await storageItem . AsBaseStorageFile ( ) . GetBasicPropertiesAsync ( ) ;
2043
+ size = ( long ) properties . Size ;
2044
+ modified = properties . DateModified ;
2045
+ created = properties . ItemDate ;
2046
+ }
2047
+ else if ( storageItem . IsOfType ( StorageItemTypes . Folder ) )
2048
+ {
2049
+ var properties = await storageItem . AsBaseStorageFolder ( ) . GetBasicPropertiesAsync ( ) ;
2050
+ modified = properties . DateModified ;
2051
+ created = properties . ItemDate ;
2052
+ }
2053
2053
2054
- if ( storageItem . IsOfType ( StorageItemTypes . File ) )
2055
- {
2056
- var properties = await storageItem . AsBaseStorageFile ( ) . GetBasicPropertiesAsync ( ) ;
2057
- item . FileSizeBytes = ( long ) properties . Size ;
2058
- item . FileSize = ByteSizeLib . ByteSize . FromBytes ( item . FileSizeBytes ) . ToBinaryString ( ) . ConvertSizeAbbreviation ( ) ;
2059
- item . ItemDateModifiedReal = properties . DateModified ;
2060
- item . ItemDateCreatedReal = properties . ItemDate ;
2061
- }
2062
- else if ( storageItem . IsOfType ( StorageItemTypes . Folder ) )
2063
- {
2064
- var properties = await storageItem . AsBaseStorageFolder ( ) . GetBasicPropertiesAsync ( ) ;
2065
- item . ItemDateModifiedReal = properties . DateModified ;
2066
- item . ItemDateCreatedReal = properties . ItemDate ;
2067
- }
2068
- } ) ;
2054
+ return ( item , syncUI , size , created , modified ) ;
2069
2055
}
2056
+
2057
+ return null ;
2070
2058
}
2071
2059
2072
- private async Task UpdateFileOrFolderAsync ( string path , bool hasSyncStatus = false )
2060
+ private async Task UpdateFilesOrFoldersAsync ( IEnumerable < string > paths , bool hasSyncStatus = false )
2073
2061
{
2074
2062
try
2075
2063
{
@@ -2082,12 +2070,31 @@ private async Task UpdateFileOrFolderAsync(string path, bool hasSyncStatus = fal
2082
2070
2083
2071
try
2084
2072
{
2085
- var matchingItem = filesAndFolders . FirstOrDefault ( x => x . ItemPath . Equals ( path , StringComparison . OrdinalIgnoreCase ) ) ;
2073
+ var matchingItems = filesAndFolders . Where ( x => paths . Any ( p => p . Equals ( x . ItemPath , StringComparison . OrdinalIgnoreCase ) ) ) ;
2074
+ var results = await Task . WhenAll ( matchingItems . Select ( x => UpdateFileOrFolderAsync ( x , hasSyncStatus ) ) ) ;
2086
2075
2087
- if ( matchingItem != null )
2076
+ await CoreApplication . MainView . DispatcherQueue . EnqueueAsync ( ( ) =>
2088
2077
{
2089
- await UpdateFileOrFolderAsync ( matchingItem , hasSyncStatus ) ;
2090
- }
2078
+ foreach ( var result in results )
2079
+ {
2080
+ if ( result . HasValue )
2081
+ {
2082
+ var item = result . Value . Item ;
2083
+ item . ItemDateModifiedReal = result . Value . Modified ;
2084
+ item . ItemDateCreatedReal = result . Value . Created ;
2085
+
2086
+ if ( result . Value . SyncUI != null )
2087
+ {
2088
+ item . SyncStatusUI = result . Value . SyncUI ;
2089
+ }
2090
+
2091
+ if ( result . Value . Size . HasValue )
2092
+ {
2093
+ item . FileSize = ByteSizeLib . ByteSize . FromBytes ( item . FileSizeBytes ) . ToBinaryString ( ) . ConvertSizeAbbreviation ( ) ;
2094
+ }
2095
+ }
2096
+ }
2097
+ } ) ;
2091
2098
}
2092
2099
finally
2093
2100
{
0 commit comments