public Stream OpenRead(string logicalPath) { // If configured to only use remote configuration, don't use the local copy for Config and Query if (Configuration.UseRemoteConfiguration) { if (logicalPath.StartsWith("Config\\", StringComparison.OrdinalIgnoreCase) || logicalPath.StartsWith("Query\\", StringComparison.OrdinalIgnoreCase)) { return(RemoteProvider.OpenRead(logicalPath)); } } // Read the local copy first, if found if (LocalProvider.Attributes(logicalPath).Exists) { return(LocalProvider.OpenRead(logicalPath)); } // If there's a remote copy, use that if (LocalProvider.Attributes(logicalPath).Exists == false && RemoteProvider.Attributes(logicalPath).Exists == true) { if (Configuration.ShouldDownload) { // Download the file if configured to Trace.WriteLine($"DOWNLOAD: {logicalPath}"); using (Stream target = LocalProvider.OpenWrite(logicalPath)) { using (Stream source = RemoteProvider.OpenRead(logicalPath)) { source.CopyTo(target); } } return(LocalProvider.OpenRead(logicalPath)); } return(RemoteProvider.OpenRead(logicalPath)); } // If neither location had the item, throw throw new IOException($"\"{logicalPath}\" did not exist in {LocalProvider.Description} or {RemoteProvider.Description}"); }
public Stream OpenWrite(string logicalPath) { // Always write in the local location return(LocalProvider.OpenWrite(logicalPath)); }