renaming of the 3Blog3 setting => UserFilesRoot
All checks were successful
Dotnet build and test / build (pull_request) Successful in 33m37s
All checks were successful
Dotnet build and test / build (pull_request) Successful in 33m37s
This commit is contained in:
parent
f9d95fd98f
commit
446b595077
18 changed files with 30 additions and 39 deletions
|
|
@ -8,7 +8,7 @@
|
|||
"CorsAllowedOrigins": [
|
||||
"https://preprod-api.$DOMAIN"
|
||||
],
|
||||
"Blog": "blog"
|
||||
"UserFilesRoot": "files"
|
||||
},
|
||||
"ConnectionStrings": {
|
||||
"YavscConnection": "Server=localhost;Port=5432;Database=lame-db-name;Username=lame-user-name;Password=lame-password;"
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@
|
|||
"EMail": "paul@pschneider.fr"
|
||||
},
|
||||
"Quota": 200000000,
|
||||
"Blog": "blog",
|
||||
"UserFilesRoot": "files",
|
||||
"Avatars": "avatars",
|
||||
"Bills": "bills",
|
||||
"TempDir": "temp",
|
||||
|
|
|
|||
|
|
@ -1,8 +0,0 @@
|
|||
namespace Yavsc.Blogs;
|
||||
|
||||
public static class BlogConstants
|
||||
{
|
||||
public const string AdminRole = "Admin";
|
||||
public const string ModeratorRole = "Moderator";
|
||||
public const string UserRole = "User";
|
||||
}
|
||||
|
|
@ -200,7 +200,7 @@ namespace Yavsc.Blogs.Controllers
|
|||
if (string.IsNullOrEmpty(ownerUserName))
|
||||
return NotFound(new { error = "owner not found" });
|
||||
|
||||
var physicalPath = Path.Combine(siteSettings.Blog, ownerUserName, file.Path ?? "");
|
||||
var physicalPath = Path.Combine(siteSettings.UserFilesRoot, ownerUserName, file.Path ?? "");
|
||||
var fi = new FileInfo(physicalPath);
|
||||
if (!fi.Exists) return NotFound(new { error = "file not on disk" });
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ using Yavsc.Models;
|
|||
using Yavsc.Services;
|
||||
using Yavsc.Server.Helpers;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.Extensions.Options;
|
||||
namespace Yavsc.Blogs;
|
||||
|
||||
internal class Program
|
||||
|
|
@ -85,9 +84,9 @@ internal class Program
|
|||
})
|
||||
.Configure<SiteSettings>(settings =>
|
||||
{
|
||||
if (settings.Blog == null)
|
||||
if (settings.UserFilesRoot == null)
|
||||
{
|
||||
settings.Blog = "blog";
|
||||
settings.UserFilesRoot = "blog";
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
"https://localhost:5005",
|
||||
"https://api.pschneider.fr"
|
||||
],
|
||||
"Blog": "blog"
|
||||
"UserFilesRoot": "files"
|
||||
},
|
||||
"ConnectionStrings": {
|
||||
"YavscConnection": "Server=localhost;Port=5432;Database=lame-db-name;Username=lame-user-name;Password=lame-password;"
|
||||
|
|
|
|||
|
|
@ -421,9 +421,9 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
// Renames the blog files
|
||||
var userdirinfo = new DirectoryInfo(
|
||||
Path.Combine(_siteSettings.Blog,
|
||||
Path.Combine(_siteSettings.UserFilesRoot,
|
||||
oldUserName));
|
||||
var newdir = Path.Combine(_siteSettings.Blog,
|
||||
var newdir = Path.Combine(_siteSettings.UserFilesRoot,
|
||||
model.UserName);
|
||||
if (userdirinfo.Exists)
|
||||
userdirinfo.MoveTo(newdir);
|
||||
|
|
|
|||
|
|
@ -1267,7 +1267,7 @@ ADD COLUMN IF NOT EXISTS ""Moderated"" boolean NOT NULL DEFAULT FALSE;");
|
|||
{
|
||||
throw new InvalidOperationException("GitRepository path is not configured in SiteSettings.");
|
||||
}
|
||||
if (settings.Blog == null)
|
||||
if (settings.UserFilesRoot == null)
|
||||
{
|
||||
throw new InvalidOperationException("Blog path is not configured in SiteSettings.");
|
||||
}
|
||||
|
|
@ -1284,7 +1284,7 @@ ADD COLUMN IF NOT EXISTS ""Moderated"" boolean NOT NULL DEFAULT FALSE;");
|
|||
throw new InvalidOperationException("TempDir path is not configured in SiteSettings.");
|
||||
}
|
||||
|
||||
var userFilesDirInfo = new DirectoryInfo(settings.Blog);
|
||||
var userFilesDirInfo = new DirectoryInfo(settings.UserFilesRoot);
|
||||
|
||||
if (!userFilesDirInfo.Exists) userFilesDirInfo.Create();
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ public class Startup
|
|||
ResourcesHelpers.GlobalLocalizer = localizer;
|
||||
Config.SmtpSetup = smtpSettings.Value;
|
||||
Config.Authority = siteSettings.Value.Authority;
|
||||
string blogsDir = siteSettings.Value.Blog ?? throw new Exception("blogsDir is not set.");
|
||||
string blogsDir = siteSettings.Value.UserFilesRoot ?? throw new Exception("blogsDir is not set.");
|
||||
string billsDir = siteSettings.Value.Bills ?? throw new Exception("billsDir is not set.");
|
||||
string tempDir = siteSettings.Value.TempDir ?? throw new Exception("tempDir is not set.");
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ namespace Yavsc.ViewComponents
|
|||
{
|
||||
string uid = ViewContext.HttpContext.User.GetUserId();
|
||||
return View(new UserDirectoryInfo(
|
||||
siteSettings.Blog,
|
||||
siteSettings.UserFilesRoot,
|
||||
uid, dirname));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@
|
|||
"Avatars": "avatars",
|
||||
"Quota": 200000000,
|
||||
"Bills": "bills",
|
||||
"Blog": "blog",
|
||||
"UserFilesRoot": "files",
|
||||
"TempDir": "temp",
|
||||
"DataDir": "data",
|
||||
"GitRepository": "git"
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ namespace Yavsc.Server.Helpers
|
|||
this ClaimsPrincipal user,
|
||||
string subpath, SiteSettings siteSettings)
|
||||
{
|
||||
var root = Path.Combine(siteSettings.Blog, user.GetUserName());
|
||||
var root = Path.Combine(siteSettings.UserFilesRoot, user.GetUserName());
|
||||
if (!string.IsNullOrWhiteSpace(subpath))
|
||||
{
|
||||
if (!subpath.IsValidYavscPath())
|
||||
|
|
@ -67,7 +67,7 @@ namespace Yavsc.Server.Helpers
|
|||
|
||||
public static void DeleteUserFile(this ApplicationUser user, string fileName, SiteSettings siteSettings)
|
||||
{
|
||||
var root = Path.Combine(siteSettings.Blog, user.UserName);
|
||||
var root = Path.Combine(siteSettings.UserFilesRoot, user.UserName);
|
||||
var fi = new FileInfo(Path.Combine(root, fileName));
|
||||
if (!fi.Exists) return;
|
||||
// Capture the length BEFORE deleting: FileInfo.Length throws
|
||||
|
|
@ -80,7 +80,7 @@ namespace Yavsc.Server.Helpers
|
|||
|
||||
public static FsOperationInfo DeleteUserDirOrFile(this ApplicationUser user, string dirName, SiteSettings siteSettings)
|
||||
{
|
||||
var root = Path.Combine(siteSettings.Blog, user.UserName);
|
||||
var root = Path.Combine(siteSettings.UserFilesRoot, user.UserName);
|
||||
if (string.IsNullOrEmpty(dirName))
|
||||
return new FsOperationInfo { Done = false, ErrorCode = ErrorCode.InvalidRequest, ErrorMessage = "specify a directory or file name" };
|
||||
|
||||
|
|
@ -110,7 +110,7 @@ namespace Yavsc.Server.Helpers
|
|||
|
||||
public static FsOperationInfo MoveUserDir(this ApplicationUser user, string fromDirName, string toDirName, SiteSettings siteSettings)
|
||||
{
|
||||
var root = Path.Combine(siteSettings.Blog, user.UserName);
|
||||
var root = Path.Combine(siteSettings.UserFilesRoot, user.UserName);
|
||||
if (string.IsNullOrEmpty(fromDirName))
|
||||
return new FsOperationInfo { Done = false, ErrorCode = ErrorCode.InvalidRequest, ErrorMessage = "specify a dir name " };
|
||||
|
||||
|
|
@ -136,7 +136,7 @@ namespace Yavsc.Server.Helpers
|
|||
}
|
||||
public static FsOperationInfo MoveUserFileToDir(this ApplicationUser user, string fileNameFrom, string fileNameDest, SiteSettings siteSettings)
|
||||
{
|
||||
var root = Path.Combine(siteSettings.Blog, user.UserName);
|
||||
var root = Path.Combine(siteSettings.UserFilesRoot, user.UserName);
|
||||
var fi = new FileInfo(Path.Combine(root, fileNameFrom));
|
||||
if (!fi.Exists) return new FsOperationInfo { Done = false, ErrorCode = ErrorCode.NotFound, ErrorMessage = "no file to move" };
|
||||
string dest;
|
||||
|
|
@ -151,7 +151,7 @@ namespace Yavsc.Server.Helpers
|
|||
}
|
||||
public static FsOperationInfo MoveUserFile(this ApplicationUser user, string fileNameFrom, string fileNameDest, SiteSettings siteSettings)
|
||||
{
|
||||
var root = Path.Combine(siteSettings.Blog, user.UserName);
|
||||
var root = Path.Combine(siteSettings.UserFilesRoot, user.UserName);
|
||||
var fi = new FileInfo(Path.Combine(root, fileNameFrom));
|
||||
if (!fi.Exists) return new FsOperationInfo { Done = false, ErrorCode = ErrorCode.NotFound, ErrorMessage = "no file to move" };
|
||||
var fo = new FileInfo(Path.Combine(root, fileNameDest));
|
||||
|
|
@ -318,7 +318,7 @@ namespace Yavsc.Server.Helpers
|
|||
|
||||
public static UserDirectoryInfo GetUserFiles(SiteSettings settings, string userId, string subdir)
|
||||
{
|
||||
UserDirectoryInfo di = new UserDirectoryInfo(settings.Blog, userId, subdir);
|
||||
UserDirectoryInfo di = new UserDirectoryInfo(settings.UserFilesRoot, userId, subdir);
|
||||
return di;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ public class BlogSpotService
|
|||
_context = context;
|
||||
this.fileSystemAuthManager = fileSystemAuthManager;
|
||||
this.siteSettings = siteSettings.Value;
|
||||
if (siteSettings.Value.Blog == null)
|
||||
if (siteSettings.Value.UserFilesRoot == null)
|
||||
{
|
||||
throw new InvalidOperationException("SiteSettings.Blog is not configured.");
|
||||
}
|
||||
|
|
@ -56,7 +56,7 @@ public class BlogSpotService
|
|||
{
|
||||
string blogFilesSubdir = $"blogs/{postId}";
|
||||
string destDir = Path.Combine(
|
||||
siteSettings.Blog,
|
||||
siteSettings.UserFilesRoot,
|
||||
user.UserName,
|
||||
blogFilesSubdir);
|
||||
var di = new DirectoryInfo(destDir);
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ namespace Yavsc
|
|||
public string DataDir { get; set; }
|
||||
public string Avatars { get; set; }
|
||||
public long Quota { get; set; }
|
||||
public string Blog { get; set; }
|
||||
public string UserFilesRoot { get; set; }
|
||||
public string Bills { get; set; }
|
||||
public string GitRepository { get; set; }
|
||||
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ public sealed class BlogsWebServerFixture : WebHostFixture
|
|||
// on real files.
|
||||
builder.Services.Configure<SiteSettings>(s =>
|
||||
{
|
||||
s.Blog = BlogFilesRoot;
|
||||
s.UserFilesRoot = BlogFilesRoot;
|
||||
});
|
||||
|
||||
// Real BlogSpotService — same instance the production host
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ public sealed class MappedClaimsBlogsWebServerFixture : IDisposable, IBackendFix
|
|||
// BlogsWebServerFixture.
|
||||
builder.Services.Configure<SiteSettings>(s =>
|
||||
{
|
||||
s.Blog = Path.Combine(Path.GetTempPath(), "postit-blogs-mappedclaims-" + Guid.NewGuid().ToString("N"));
|
||||
s.UserFilesRoot = Path.Combine(Path.GetTempPath(), "postit-blogs-mappedclaims-" + Guid.NewGuid().ToString("N"));
|
||||
});
|
||||
builder.Services.AddScoped<BlogSpotService>();
|
||||
builder.Services.AddScoped<IAuthorizationHandler, PermissionHandler>();
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
"FavIcon": "/favicon.ico",
|
||||
"Icon": "/images/yavsc.png",
|
||||
"GitRepository": "testingrepo",
|
||||
"Blog": "blog",
|
||||
"UserFilesRoot": "files",
|
||||
"Bills": "bills",
|
||||
"TempDir": "temp",
|
||||
"Avatars": "avatars",
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ public sealed class ServerServicesFixture : IDisposable
|
|||
// Details itself doesn't read it, but the service constructor
|
||||
// throws if SiteSettings.Blog is null, so configure a temp
|
||||
// value to keep construction alive.
|
||||
services.Configure<SiteSettings>(s => s.Blog = "server-tests-files-root");
|
||||
services.Configure<SiteSettings>(s => s.UserFilesRoot = "server-tests-files-root");
|
||||
|
||||
// Trivial file-system auth: Details never calls into it, but
|
||||
// the DI container needs an instance to construct the service.
|
||||
|
|
|
|||
Loading…
Reference in a new issue