예제 #1
0
            /// <summary>
            /// Commits the insertion into the cache. Once this is called the entry
            /// will be available to clients of the cache.
            /// </summary>
            /// <param name="debugInfo">Debug object for debugging.</param>
            /// <returns>The final resource created.</returns>
            /// <exception cref="IOException">
            /// On errors during the commit.
            /// </exception>
            public IBinaryResource Commit(object debugInfo)
            {
                // The temp resource must be ours!
                FileInfo targetFile = (FileInfo)_parent.GetContentFileFor(_resourceId);

                try
                {
                    FileUtils.Rename(_temporaryFile, targetFile);
                }
                catch (RenameException)
                {
                    CacheErrorCategory category = CacheErrorCategory.WRITE_RENAME_FILE_OTHER;
                    _parent._cacheErrorLogger.LogError(
                        category,
                        typeof(DefaultDiskStorage),
                        "commit");

                    throw;
                }

                if (targetFile.Exists)
                {
                    targetFile.LastWriteTime = _parent._clock.Now;
                }

                return(FileBinaryResource.CreateOrNull(targetFile));
            }
 /// <summary>
 /// Log an error of the specified category.
 /// </summary>
 /// <param name="category">Error category.</param>
 /// <param name="clazz">Class reporting the error.</param>
 /// <param name="message">An optional error message.</param>
 public void LogError(
     CacheErrorCategory category,
     Type clazz,
     string message)
 {
 }