Merge pull request #223 from sbwalker/master

Removed Repository methods which are not used and are not valid because they do not adhere to tenant scope boundaries
This commit is contained in:
Shaun Walker
2020-02-23 10:48:29 -05:00
committed by GitHub
18 changed files with 51 additions and 58 deletions

View File

@ -145,6 +145,11 @@ namespace Oqtane.Controllers
try
{
var client = new System.Net.WebClient();
// remove file if it already exists
if (System.IO.File.Exists(folderpath + filename))
{
System.IO.File.Delete(folderpath + filename);
}
client.DownloadFile(url, folderpath + filename);
Files.AddFile(CreateFile(filename, folder.FolderId, folderpath + filename));
}
@ -260,6 +265,11 @@ namespace Oqtane.Controllers
}
else
{
// remove file if it already exists
if (System.IO.File.Exists(Path.Combine(folder, filename)))
{
System.IO.File.Delete(Path.Combine(folder, filename));
}
// rename file now that the entire process is completed
System.IO.File.Move(Path.Combine(folder, filename + ".tmp"), Path.Combine(folder, filename));
logger.Log(LogLevel.Information, this, LogFunction.Create, "File Uploaded {File}", Path.Combine(folder, filename));
@ -326,8 +336,18 @@ namespace Oqtane.Controllers
Models.File file = Files.GetFile(id);
if (file != null && UserPermissions.IsAuthorized(User, "View", file.Folder.Permissions))
{
byte[] filebytes = System.IO.File.ReadAllBytes(GetFolderPath(file.Folder) + file.Name);
return File(filebytes, "application/octet-stream", file.Name);
string filepath = GetFolderPath(file.Folder) + file.Name;
if (System.IO.File.Exists(filepath))
{
byte[] filebytes = System.IO.File.ReadAllBytes(filepath);
return File(filebytes, "application/octet-stream", file.Name);
}
else
{
logger.Log(LogLevel.Error, this, LogFunction.Read, "File Does Not Exist {File}", file);
HttpContext.Response.StatusCode = 404;
return null;
}
}
else
{

View File

@ -183,19 +183,26 @@ namespace Oqtane.Controllers
string connectionString = Config.GetConnectionString("DefaultConnection");
connectionString = connectionString.Replace("|DataDirectory|", datadirectory);
SqlConnection connection = new SqlConnection(connectionString);
try
if (!string.IsNullOrEmpty(connectionString))
{
using (connection)
SqlConnection connection = new SqlConnection(connectionString);
try
{
connection.Open();
using (connection)
{
connection.Open();
}
response.Success = true;
}
catch
{
// database does not exist
response.Message = "Database Does Not Exist";
}
response.Success = true;
}
catch
else
{
// database does not exist
response.Message = "Database Does Not Exist";
response.Message = "Connection String Has Not Been Specified In Oqtane.Server\\appsettings.json";
}
if (response.Success)
@ -243,7 +250,7 @@ namespace Oqtane.Controllers
var result = dbUpgrade.PerformUpgrade();
if (!result.Successful)
{
// TODO: log result.Error.Message;
// TODO: log result.Error.Message - problem is logger is not available here
}
}
// iterate through Oqtane module assemblies and execute any database scripts