예제 #1
0
        private String _cacheFolder; //absolute path of the cache folder

        /// <summary>
        /// Save 'content' into the cache folder, identified by 'url', and set the file's time to 'remote Time'.
        /// </summary>
        /// <param name="url">URL to a cached file, excluding the server-side time stamp, e.g. /MG1VAI3T_MP_0$$$_$_$_N02400$$$$G8FM01_.xml.</param>
        /// <param name="content">content to save for future access to the url.</param>
        /// <param name="remoteTime">modification time of the file on the server-side (for story#138618: remote time will be null).</param>
        public void PutFile(String url, byte[] content, String remoteTime)
        {
            lock (this)
            {
                try
                {
                    String localFilename = URLToLocalFileName(url);
                    bool   success       = HandleFiles.writeToFile(HandleFiles.getFile(localFilename), content, false, true, ClientManager.Instance.GetWriteClientCacheMaxRetryTime());
                    if (!success)
                    {
                        throw (new CacheManagerException(string.Format("Failed to save the file {0} in cache directory. Check log for details", localFilename)));
                    }
                    if (remoteTime != null)
                    {
                        HandleFiles.setFileTime(localFilename, remoteTime);
                    }
                }
                catch (Exception e)
                {
                    Misc.WriteStackTrace(e, Console.Error);
                    throw (e);
                }
            }
        }