@@ -160,7 +160,7 @@ public async Task<byte[]> GetThumbnailAsync(uint size, IOperationContext operati
160160 byte [ ] thumbnail = ThumbnailExtractor . GetRemoteThumbnail ( remoteStoragePath , size ) ;
161161
162162 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 ) ;
164164
165165 return thumbnail ;
166166 }
@@ -230,8 +230,8 @@ public async Task LockAsync(LockMode lockMode, IOperationContext operationContex
230230 // Save the lock token and other lock info received from your remote storage on the client.
231231 // Supply the lock-token as part of each remote storage update in File.WriteAsync() method.
232232 // For demo purposes we just fill some generic data.
233- ServerLockInfo serverLockInfo = new ServerLockInfo ( )
234- {
233+ ServerLockInfo serverLockInfo = new ServerLockInfo ( )
234+ {
235235 LockToken = "ServerToken" ,
236236 Owner = Engine . CurrentUserPrincipal ,
237237 Exclusive = true ,
@@ -241,6 +241,42 @@ public async Task LockAsync(LockMode lockMode, IOperationContext operationContex
241241
242242 // Save lock-token and lock-mode.
243243 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+ }
244280 }
245281
246282 ///<inheritdoc>
@@ -258,7 +294,7 @@ public async Task<LockMode> GetLockModeAsync(IOperationContext operationContext,
258294 public async Task UnlockAsync ( IOperationContext operationContext , CancellationToken cancellationToken )
259295 {
260296 Logger . LogMessage ( $ "{ nameof ( ILock ) } .{ nameof ( UnlockAsync ) } ()", UserFileSystemPath , default , operationContext ) ;
261-
297+
262298 // Read the lock-token.
263299 if ( operationContext . Properties . TryGetLockInfo ( out ServerLockInfo lockInfo ) )
264300 {
0 commit comments