예제 #1
0
        /// <inheritdoc/>
        public async Task OpenAsync(IOperationContext operationContext, IResultContext context)
        {
            Logger.LogMessage("IFile.OpenAsync()", UserFileSystemPath);

            // Auto-lock the file.
            string userFileSystemFilePath = UserFileSystemPath;

            if (Engine.ChangesProcessingEnabled && FsPath.Exists(userFileSystemFilePath))
            {
                if (Program.Settings.AutoLock &&
                    !FsPath.AvoidAutoLock(userFileSystemFilePath) &&
                    !await Lock.IsLockedAsync(userFileSystemFilePath) &&
                    FsPath.IsWriteLocked(userFileSystemFilePath) &&
                    !new PlaceholderFile(userFileSystemFilePath).IsNew())
                {
                    try
                    {
                        await new RemoteStorageRawItem(userFileSystemFilePath, Logger).LockAsync(LockMode.Auto);
                    }
                    catch (ClientLockFailedException ex)
                    {
                        // Lock file is blocked by the concurrent thread. This is a normal behaviour.
                        Logger.LogMessage(ex.Message, userFileSystemFilePath);
                    }
                }
            }
        }