@@ -160,7 +160,7 @@ public async Task<byte[]> GetThumbnailAsync(uint size, IOperationContext operati
160
160
byte [ ] thumbnail = ThumbnailExtractor . GetRemoteThumbnail ( remoteStoragePath , size ) ;
161
161
162
162
string thumbnailResult = thumbnail != null ? "Success" : "Not Impl" ;
163
- Logger . LogMessage ( $ "{ nameof ( IFileSystemItem ) } .{ nameof ( GetThumbnailAsync ) } (): { thumbnailResult } ", UserFileSystemPath ) ;
163
+ Logger . LogDebug ( $ "{ nameof ( IFileSystemItem ) } .{ nameof ( GetThumbnailAsync ) } (): { thumbnailResult } ", UserFileSystemPath , default , operationContext ) ;
164
164
165
165
return thumbnail ;
166
166
}
@@ -230,8 +230,8 @@ public async Task LockAsync(LockMode lockMode, IOperationContext operationContex
230
230
// Save the lock token and other lock info received from your remote storage on the client.
231
231
// Supply the lock-token as part of each remote storage update in File.WriteAsync() method.
232
232
// For demo purposes we just fill some generic data.
233
- ServerLockInfo serverLockInfo = new ServerLockInfo ( )
234
- {
233
+ ServerLockInfo serverLockInfo = new ServerLockInfo ( )
234
+ {
235
235
LockToken = "ServerToken" ,
236
236
Owner = Engine . CurrentUserPrincipal ,
237
237
Exclusive = true ,
@@ -241,6 +241,42 @@ public async Task LockAsync(LockMode lockMode, IOperationContext operationContex
241
241
242
242
// Save lock-token and lock-mode.
243
243
operationContext . Properties . SetLockInfo ( serverLockInfo ) ;
244
+
245
+
246
+ if ( lockMode == LockMode . Auto )
247
+ {
248
+ // Start the timer to unlock if the file is not locked.
249
+ System . Timers . Timer timer = new System . Timers . Timer ( 10000 ) ;
250
+ timer . AutoReset = true ;
251
+ timer . Elapsed += async ( object sender , System . Timers . ElapsedEventArgs e ) =>
252
+ {
253
+ try
254
+ {
255
+ if ( cancellationToken . IsCancellationRequested ) return ;
256
+
257
+ if ( operationContext . Properties . TryGetLockInfo ( out ServerLockInfo serverLockInfo ) &&
258
+ FilterHelper . IsLockedWithOwnerFile ( UserFileSystemPath ) && ! FilterHelper . IsOwnerFileExists ( UserFileSystemPath ) )
259
+ {
260
+ await Engine . ClientNotifications ( UserFileSystemPath ) . UnlockAsync ( true , cancellationToken ) ;
261
+ PlaceholderItem . UpdateUI ( UserFileSystemPath ) ;
262
+ // Stop the timer.
263
+ timer . Dispose ( ) ;
264
+ }
265
+ }
266
+ catch ( TaskCanceledException )
267
+ {
268
+ // Stop the timer.
269
+ timer . Dispose ( ) ;
270
+
271
+ Logger . LogDebug ( "Checking lock canceled" , UserFileSystemPath , default , operationContext ) ;
272
+ }
273
+ catch ( Exception ex )
274
+ {
275
+ Logger . LogError ( "Checking lock failed" , UserFileSystemPath , default , ex , operationContext ) ;
276
+ }
277
+ } ;
278
+ timer . Start ( ) ;
279
+ }
244
280
}
245
281
246
282
///<inheritdoc>
@@ -258,7 +294,7 @@ public async Task<LockMode> GetLockModeAsync(IOperationContext operationContext,
258
294
public async Task UnlockAsync ( IOperationContext operationContext , CancellationToken cancellationToken )
259
295
{
260
296
Logger . LogMessage ( $ "{ nameof ( ILock ) } .{ nameof ( UnlockAsync ) } ()", UserFileSystemPath , default , operationContext ) ;
261
-
297
+
262
298
// Read the lock-token.
263
299
if ( operationContext . Properties . TryGetLockInfo ( out ServerLockInfo lockInfo ) )
264
300
{
0 commit comments