OS independent file paths

This commit is contained in:
Sean Long
2020-04-17 16:25:00 -04:00
parent 2dd2216aa2
commit 70502cd881
13 changed files with 41 additions and 36 deletions

View File

@ -387,14 +387,14 @@ namespace Oqtane.Infrastructure
}
// add folder for user
var folder = folderRepository.GetFolder(user.SiteId, "Users\\");
var folder = folderRepository.GetFolder(user.SiteId, "Users");
if (folder != null)
folderRepository.AddFolder(new Folder
{
SiteId = folder.SiteId,
ParentId = folder.FolderId,
Name = "My Folder",
Path = folder.Path + newUser.UserId + "\\",
Path = Path.Combine(folder.Path, newUser.UserId.ToString()),
Order = 1,
IsSystem = true,
Permissions = new List<Permission>

View File

@ -103,7 +103,7 @@ namespace Oqtane.Infrastructure
case ".svg":
case ".js":
case ".css":
filename = sourceFolder + "\\" + entry.FullName.Replace("wwwroot", name).Replace("/", "\\");
filename = Path.Combine(sourceFolder, entry.FullName.Replace("wwwroot", name));
if (!Directory.Exists(Path.GetDirectoryName(filename)))
{
Directory.CreateDirectory(Path.GetDirectoryName(filename));

View File

@ -4,6 +4,7 @@ using System.Collections.Generic;
using Oqtane.Repository;
using Microsoft.AspNetCore.Hosting;
using Oqtane.Shared;
using System.IO;
namespace Oqtane.SiteTemplates
{
@ -131,16 +132,16 @@ namespace Oqtane.SiteTemplates
}
});
if (System.IO.File.Exists(_environment.WebRootPath + "\\images\\logo.png"))
if (System.IO.File.Exists(Path.Combine(_environment.WebRootPath, "images", "logo.png")))
{
string folderpath = _environment.ContentRootPath + "\\Content\\Tenants\\" + site.TenantId.ToString() + "\\Sites\\" + site.SiteId.ToString() + "\\";
string folderpath = Path.Combine(_environment.ContentRootPath, "Content", "Tenants", site.TenantId.ToString(), "Sites", site.SiteId.ToString());
System.IO.Directory.CreateDirectory(folderpath);
if (!System.IO.File.Exists(folderpath + "logo.png"))
if (!System.IO.File.Exists(Path.Combine(folderpath, "logo.png")))
{
System.IO.File.Copy(_environment.WebRootPath + "\\images\\logo.png", folderpath + "logo.png");
System.IO.File.Copy(Path.Combine(_environment.WebRootPath, "images", "logo.png"), Path.Combine(folderpath, "logo.png"));
}
Folder folder = _folderRepository.GetFolder(site.SiteId, "");
File file = _fileRepository.AddFile(new File { FolderId = folder.FolderId, Name = "logo.png", Extension = "png", Size = 8192, ImageHeight = 80, ImageWidth = 250 });
Oqtane.Models.File file = _fileRepository.AddFile(new Oqtane.Models.File { FolderId = folder.FolderId, Name = "logo.png", Extension = "png", Size = 8192, ImageHeight = 80, ImageWidth = 250 });
site.LogoFileId = file.FileId;
_siteRepository.UpdateSite(site);
}