Exemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the DavContext class.
        /// </summary>
        /// <param name="httpContext"><see cref="HttpContext"/> instance.</param>
        public DavContext(HttpContext httpContext) : base(httpContext)
        {
            Logger         = WebDAVServer.FileSystemStorage.AspNet.Logger.Instance;
            RepositoryPath = ConfigurationManager.AppSettings["RepositoryPath"] ?? string.Empty;
            bool   isRoot = new DirectoryInfo(RepositoryPath).Parent == null;
            string configRepositoryPath = isRoot ? RepositoryPath : RepositoryPath.TrimEnd(Path.DirectorySeparatorChar);

            RepositoryPath = configRepositoryPath.StartsWith("~") ?
                             HttpContext.Current.Server.MapPath(configRepositoryPath) : configRepositoryPath;

            string attrStoragePath = (ConfigurationManager.AppSettings["AttrStoragePath"] ?? string.Empty).TrimEnd(Path.DirectorySeparatorChar);

            attrStoragePath = attrStoragePath.StartsWith("~") ?
                              HttpContext.Current.Server.MapPath(attrStoragePath) : attrStoragePath;

            if (!FileSystemInfoExtension.IsUsingFileSystemAttribute)
            {
                if (!string.IsNullOrEmpty(attrStoragePath))
                {
                    FileSystemInfoExtension.UseFileSystemAttribute(new FileSystemExtendedAttribute(attrStoragePath, this.RepositoryPath));
                }
                else if (!(new DirectoryInfo(RepositoryPath).IsExtendedAttributesSupported()))
                {
                    var tempPath = Path.Combine(Path.GetTempPath(), System.Reflection.Assembly.GetExecutingAssembly().GetName().Name);
                    FileSystemInfoExtension.UseFileSystemAttribute(new FileSystemExtendedAttribute(tempPath, this.RepositoryPath));
                }
            }


            if (!Directory.Exists(RepositoryPath))
            {
                WebDAVServer.FileSystemStorage.AspNet.Logger.Instance.LogError("Repository path specified in Web.config is invalid.", null);
            }
        }