55using Parallel . Core . Database ;
66using Parallel . Core . Diagnostics ;
77using Parallel . Core . Models ;
8+ using Parallel . Core . Security ;
89using Parallel . Core . Settings ;
910using Parallel . Core . Utils ;
1011
@@ -36,13 +37,14 @@ public override async Task<int> PushFilesAsync(SystemFile[] files, IProgressRepo
3637 Task worker = System . Threading . Tasks . Parallel . ForEachAsync ( uploadFiles , ParallelConfig . Options , async ( file , ct ) =>
3738 {
3839 Interlocked . Increment ( ref queued ) ;
39- SemaphoreSlim lockedThread = threadPool . GetOrAdd ( file . CheckSum , _ => new SemaphoreSlim ( 1 , 1 ) ) ;
40+ if ( string . IsNullOrEmpty ( file . CheckSum ) && ! file . TryGenerateCheckSum ( ) ) return ;
41+ SemaphoreSlim lockedThread = threadPool . GetOrAdd ( file . CheckSum ! , _ => new SemaphoreSlim ( 1 , 1 ) ) ;
4042 await lockedThread . WaitAsync ( ct ) ;
4143
4244 try
4345 {
4446 Log . Debug ( $ "Pushing -> { file . LocalPath } ") ;
45- file . RemotePath = PathBuilder . GetObjectPath ( RemoteVault , file . CheckSum ) ;
47+ file . RemotePath = PathBuilder . GetObjectPath ( RemoteVault , file . CheckSum ! ) ;
4648 long result = await StorageProvider . UploadFileAsync ( file , false , ct ) ;
4749 if ( result <= 0 )
4850 {
@@ -63,7 +65,7 @@ public override async Task<int> PushFilesAsync(SystemFile[] files, IProgressRepo
6365 finally
6466 {
6567 lockedThread . Release ( ) ;
66- threadPool . TryRemove ( file . CheckSum , out _ ) ;
68+ threadPool . TryRemove ( file . CheckSum ! , out _ ) ;
6769 Interlocked . Increment ( ref completed ) ;
6870 Interlocked . Decrement ( ref queued ) ;
6971 }
@@ -101,7 +103,8 @@ public override async Task<int> PullFilesAsync(SystemFile[] files, IProgressRepo
101103 Task worker = System . Threading . Tasks . Parallel . ForEachAsync ( files , ParallelConfig . Options , async ( file , ct ) =>
102104 {
103105 Interlocked . Increment ( ref queued ) ;
104- SemaphoreSlim lockedThread = threadPool . GetOrAdd ( file . CheckSum , _ => new SemaphoreSlim ( 1 , 1 ) ) ;
106+ if ( string . IsNullOrEmpty ( file . CheckSum ) && ! file . TryGenerateCheckSum ( ) ) return ;
107+ SemaphoreSlim lockedThread = threadPool . GetOrAdd ( file . CheckSum ! , _ => new SemaphoreSlim ( 1 , 1 ) ) ;
105108 await lockedThread . WaitAsync ( ct ) ;
106109
107110 try
@@ -131,7 +134,7 @@ public override async Task<int> PullFilesAsync(SystemFile[] files, IProgressRepo
131134 finally
132135 {
133136 lockedThread . Release ( ) ;
134- threadPool . TryRemove ( file . CheckSum , out _ ) ;
137+ threadPool . TryRemove ( file . CheckSum ! , out _ ) ;
135138 Interlocked . Increment ( ref completed ) ;
136139 Interlocked . Decrement ( ref queued ) ;
137140 }
0 commit comments