Fixing null reference when no Urls are set in Warmup

--HG--
branch : 1.x
This commit is contained in:
Sebastien Ros
2011-03-31 16:28:56 -07:00
parent 15366e89e5
commit 224c8294ba
2 changed files with 8 additions and 6 deletions

View File

@@ -45,11 +45,13 @@ namespace Orchard.Warmup.Controllers {
var warmupPart = Services.WorkContext.CurrentSite.As<WarmupSettingsPart>();
if(TryUpdateModel(warmupPart)) {
using (var urlReader = new StringReader(warmupPart.Urls)) {
string relativeUrl;
while (null != (relativeUrl = urlReader.ReadLine())) {
if(!Uri.IsWellFormedUriString(relativeUrl, UriKind.Relative) || !(relativeUrl.StartsWith("/"))) {
AddModelError("Urls", T("{0} is an invalid warmup url.", relativeUrl));
if (!String.IsNullOrEmpty(warmupPart.Urls)) {
using (var urlReader = new StringReader(warmupPart.Urls)) {
string relativeUrl;
while (null != (relativeUrl = urlReader.ReadLine())) {
if (!Uri.IsWellFormedUriString(relativeUrl, UriKind.Relative) || !(relativeUrl.StartsWith("/"))) {
AddModelError("Urls", T("{0} is an invalid warmup url.", relativeUrl));
}
}
}
}

View File

@@ -30,7 +30,7 @@ namespace Orchard.FileSystems.VirtualPath {
&& !HostingEnvironment.VirtualPathProvider.FileExists(virtualPath)) {
// if trying to monitor a directory or file inside a directory which doesn't exist
// monitor first existing parent directory
new Token(virtualPath);
return new Token(virtualPath);
}
BindSignal(virtualPath);