public void RemoveFileLock(string fileId)
        {
            var expiryInfo = new FileLockExpiryInfo(fileId, DateTime.UtcNow);

            logger.LogDebug($"RemoveFileLock: (fileId: {fileId})");
            lock (@lock)
            {
                bool resetInterval = Equals(expiryDatesByFileId.First, expiryInfo);
                expiryDatesByFileId.Remove(expiryInfo);
                if (resetInterval)
                {
                    ResetInterval();
                }
            }
        }
        public void ResetFileLock(string fileId, TimeSpan fileLockDuration)
        {
            var expiryDate     = DateTime.UtcNow + fileLockDuration;
            var lockexpiryInfo = new FileLockExpiryInfo(fileId, expiryDate);

            logger.LogDebug($"ResetFileLock: (fileId: {fileId}, fileLockDuration: {fileLockDuration})");
            lock (@lock)
            {
                if (expiryDatesByFileId.Any() && expiryDatesByFileId.Contains(lockexpiryInfo))
                {
                    expiryDatesByFileId.Remove(lockexpiryInfo);
                }
                expiryDatesByFileId.Enqueue(lockexpiryInfo, expiryDate);
                if (Equals(expiryDatesByFileId.First, lockexpiryInfo))
                {
                    ResetInterval();
                }
            }
        }
Пример #3
0
 private bool Equals(FileLockExpiryInfo other)
 {
     return(string.Equals(FileId, other.FileId));
 }