@@ -1818,7 +1818,6 @@ private async void ProcessOperationQueue(CancellationToken cancellationToken, bo
18181818 const uint FILE_ACTION_RENAMED_NEW_NAME = 0x00000005 ;
18191819
18201820 var sampler = new IntervalSampler ( 200 ) ;
1821- var updateList = new HashSet < string > ( ) ;
18221821 bool anyEdits = false ;
18231822
18241823 try
@@ -1828,8 +1827,8 @@ private async void ProcessOperationQueue(CancellationToken cancellationToken, bo
18281827 if ( operationEvent . Wait ( 200 , cancellationToken ) )
18291828 {
18301829 operationEvent . Reset ( ) ;
1830+ var updateList = new HashSet < string > ( ) ;
18311831
1832- processQueue :
18331832 while ( operationQueue . TryDequeue ( out var operation ) )
18341833 {
18351834 if ( cancellationToken . IsCancellationRequested ) break ;
@@ -1867,16 +1866,7 @@ private async void ProcessOperationQueue(CancellationToken cancellationToken, bo
18671866 }
18681867 }
18691868
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 ) ;
18801870 }
18811871
18821872 if ( anyEdits )
@@ -2030,7 +2020,7 @@ private async Task AddFileOrFolderAsync(string fileOrFolderPath, string dateRetu
20302020 await AddFileOrFolderAsync ( listedItem ) ;
20312021 }
20322022
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 )
20342024 {
20352025 IStorageItem storageItem = null ;
20362026 if ( item . PrimaryItemAttribute == StorageItemTypes . File )
@@ -2043,33 +2033,31 @@ private async Task UpdateFileOrFolderAsync(ListedItem item, bool hasSyncStatus =
20432033 }
20442034 if ( storageItem != null )
20452035 {
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 ) )
20482041 {
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+ }
20532053
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 ) ;
20692055 }
2056+
2057+ return null ;
20702058 }
20712059
2072- private async Task UpdateFileOrFolderAsync ( string path , bool hasSyncStatus = false )
2060+ private async Task UpdateFilesOrFoldersAsync ( IEnumerable < string > paths , bool hasSyncStatus = false )
20732061 {
20742062 try
20752063 {
@@ -2082,12 +2070,31 @@ private async Task UpdateFileOrFolderAsync(string path, bool hasSyncStatus = fal
20822070
20832071 try
20842072 {
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 ) ) ) ;
20862075
2087- if ( matchingItem != null )
2076+ await CoreApplication . MainView . DispatcherQueue . EnqueueAsync ( ( ) =>
20882077 {
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+ } ) ;
20912098 }
20922099 finally
20932100 {
0 commit comments