Switched to database scheme seperation from MoonCores SingleDb. Updated mooncore versions. Updating to correct Async naming
This commit is contained in:
@@ -23,7 +23,7 @@ public class CombineController : Controller
|
||||
}
|
||||
|
||||
[HttpPost("combine")]
|
||||
public async Task<IResult> Combine([FromBody] CombineRequest request)
|
||||
public async Task<IResult> CombineAsync([FromBody] CombineRequest request)
|
||||
{
|
||||
// Validate file lenght
|
||||
if (request.Files.Length < 2)
|
||||
|
||||
@@ -19,7 +19,7 @@ public class CompressController : Controller
|
||||
private const string BaseDirectory = "storage";
|
||||
|
||||
[HttpPost("compress")]
|
||||
public async Task<IResult> Compress([FromBody] CompressRequest request)
|
||||
public async Task<IResult> CompressAsync([FromBody] CompressRequest request)
|
||||
{
|
||||
// Validate item length
|
||||
if (request.Items.Length == 0)
|
||||
@@ -48,11 +48,11 @@ public class CompressController : Controller
|
||||
switch (request.Format)
|
||||
{
|
||||
case "tar.gz":
|
||||
await CompressTarGz(destinationPath, itemsPaths, rootPath);
|
||||
await CompressTarGzAsync(destinationPath, itemsPaths, rootPath);
|
||||
break;
|
||||
|
||||
case "zip":
|
||||
await CompressZip(destinationPath, itemsPaths, rootPath);
|
||||
await CompressZipAsync(destinationPath, itemsPaths, rootPath);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -66,14 +66,14 @@ public class CompressController : Controller
|
||||
|
||||
#region Tar Gz
|
||||
|
||||
private async Task CompressTarGz(string destination, IEnumerable<string> items, string root)
|
||||
private async Task CompressTarGzAsync(string destination, IEnumerable<string> items, string root)
|
||||
{
|
||||
await using var outStream = System.IO.File.Create(destination);
|
||||
await using var gzoStream = new GZipOutputStream(outStream);
|
||||
await using var tarStream = new TarOutputStream(gzoStream, Encoding.UTF8);
|
||||
|
||||
foreach (var item in items)
|
||||
await CompressItemToTarGz(tarStream, item, root);
|
||||
await CompressItemToTarGzAsync(tarStream, item, root);
|
||||
|
||||
await tarStream.FlushAsync();
|
||||
await gzoStream.FlushAsync();
|
||||
@@ -84,7 +84,7 @@ public class CompressController : Controller
|
||||
outStream.Close();
|
||||
}
|
||||
|
||||
private async Task CompressItemToTarGz(TarOutputStream tarOutputStream, string item, string root)
|
||||
private async Task CompressItemToTarGzAsync(TarOutputStream tarOutputStream, string item, string root)
|
||||
{
|
||||
if (System.IO.File.Exists(item))
|
||||
{
|
||||
@@ -117,7 +117,7 @@ public class CompressController : Controller
|
||||
if (Directory.Exists(item))
|
||||
{
|
||||
foreach (var fsEntry in Directory.EnumerateFileSystemEntries(item))
|
||||
await CompressItemToTarGz(tarOutputStream, fsEntry, root);
|
||||
await CompressItemToTarGzAsync(tarOutputStream, fsEntry, root);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,13 +125,13 @@ public class CompressController : Controller
|
||||
|
||||
#region ZIP
|
||||
|
||||
private async Task CompressZip(string destination, IEnumerable<string> items, string root)
|
||||
private async Task CompressZipAsync(string destination, IEnumerable<string> items, string root)
|
||||
{
|
||||
await using var outStream = System.IO.File.Create(destination);
|
||||
await using var zipOutputStream = new ZipOutputStream(outStream);
|
||||
|
||||
foreach (var item in items)
|
||||
await AddItemToZip(zipOutputStream, item, root);
|
||||
await AddItemToZipAsync(zipOutputStream, item, root);
|
||||
|
||||
await zipOutputStream.FlushAsync();
|
||||
await outStream.FlushAsync();
|
||||
@@ -140,7 +140,7 @@ public class CompressController : Controller
|
||||
outStream.Close();
|
||||
}
|
||||
|
||||
private async Task AddItemToZip(ZipOutputStream outputStream, string item, string root)
|
||||
private async Task AddItemToZipAsync(ZipOutputStream outputStream, string item, string root)
|
||||
{
|
||||
if (System.IO.File.Exists(item))
|
||||
{
|
||||
@@ -175,7 +175,7 @@ public class CompressController : Controller
|
||||
if (Directory.Exists(item))
|
||||
{
|
||||
foreach (var subItem in Directory.EnumerateFileSystemEntries(item))
|
||||
await AddItemToZip(outputStream, subItem, root);
|
||||
await AddItemToZipAsync(outputStream, subItem, root);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ public class DecompressController : Controller
|
||||
private const string BaseDirectory = "storage";
|
||||
|
||||
[HttpPost("decompress")]
|
||||
public async Task Decompress([FromBody] DecompressRequest request)
|
||||
public async Task DecompressAsync([FromBody] DecompressRequest request)
|
||||
{
|
||||
var path = Path.Combine(BaseDirectory, FilePathHelper.SanitizePath(request.Path));
|
||||
var destination = Path.Combine(BaseDirectory, FilePathHelper.SanitizePath(request.Destination));
|
||||
@@ -25,18 +25,18 @@ public class DecompressController : Controller
|
||||
switch (request.Format)
|
||||
{
|
||||
case "tar.gz":
|
||||
await DecompressTarGz(path, destination);
|
||||
await DecompressTarGzAsync(path, destination);
|
||||
break;
|
||||
|
||||
case "zip":
|
||||
await DecompressZip(path, destination);
|
||||
await DecompressZipAsync(path, destination);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#region Tar Gz
|
||||
|
||||
private async Task DecompressTarGz(string path, string destination)
|
||||
private async Task DecompressTarGzAsync(string path, string destination)
|
||||
{
|
||||
await using var fs = System.IO.File.Open(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
||||
await using var gzipInputStream = new GZipInputStream(fs);
|
||||
@@ -74,7 +74,7 @@ public class DecompressController : Controller
|
||||
|
||||
#region Zip
|
||||
|
||||
private async Task DecompressZip(string path, string destination)
|
||||
private async Task DecompressZipAsync(string path, string destination)
|
||||
{
|
||||
await using var fs = System.IO.File.Open(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
||||
await using var zipInputStream = new ZipInputStream(fs);
|
||||
|
||||
@@ -25,7 +25,7 @@ public class DownloadUrlController : Controller
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public async Task Get([FromQuery] string path)
|
||||
public async Task GetAsync([FromQuery] string path)
|
||||
{
|
||||
var physicalPath = Path.Combine(BaseDirectory, FilePathHelper.SanitizePath(path));
|
||||
var name = Path.GetFileName(physicalPath);
|
||||
@@ -55,7 +55,7 @@ public class DownloadUrlController : Controller
|
||||
await using var zipStream = new ZipOutputStream(Response.Body);
|
||||
zipStream.IsStreamOwner = false;
|
||||
|
||||
await StreamFolderAsZip(zipStream, physicalPath, baseDirectory, HttpContext.RequestAborted);
|
||||
await StreamFolderAsZipAsync(zipStream, physicalPath, baseDirectory, HttpContext.RequestAborted);
|
||||
}
|
||||
catch (ZipException)
|
||||
{
|
||||
@@ -68,7 +68,7 @@ public class DownloadUrlController : Controller
|
||||
}
|
||||
}
|
||||
|
||||
private async Task StreamFolderAsZip(
|
||||
private async Task StreamFolderAsZipAsync(
|
||||
ZipOutputStream zipStream,
|
||||
string path, string rootPath,
|
||||
CancellationToken cancellationToken
|
||||
@@ -102,7 +102,7 @@ public class DownloadUrlController : Controller
|
||||
if (HttpContext.RequestAborted.IsCancellationRequested)
|
||||
return;
|
||||
|
||||
await StreamFolderAsZip(zipStream, directory, rootPath, cancellationToken);
|
||||
await StreamFolderAsZipAsync(zipStream, directory, rootPath, cancellationToken);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ public class DownloadUrlController : Controller
|
||||
// Yes I know we can just create that url on the client as the exist validation is done on both endpoints,
|
||||
// but we leave it here for future modifications. E.g. using a distributed file provider or smth like that
|
||||
[HttpPost]
|
||||
public Task<DownloadUrlResponse> Post([FromQuery] string path)
|
||||
public Task<DownloadUrlResponse> PostAsync([FromQuery] string path)
|
||||
{
|
||||
var safePath = FilePathHelper.SanitizePath(path);
|
||||
var physicalPath = Path.Combine(BaseDirectory, safePath);
|
||||
|
||||
@@ -15,7 +15,7 @@ public class FilesController : Controller
|
||||
private const string BaseDirectory = "storage";
|
||||
|
||||
[HttpPost("touch")]
|
||||
public async Task CreateFile([FromQuery] string path)
|
||||
public async Task CreateFileAsync([FromQuery] string path)
|
||||
{
|
||||
var safePath = FilePathHelper.SanitizePath(path);
|
||||
var physicalPath = Path.Combine(BaseDirectory, safePath);
|
||||
@@ -31,7 +31,7 @@ public class FilesController : Controller
|
||||
}
|
||||
|
||||
[HttpPost("mkdir")]
|
||||
public Task CreateFolder([FromQuery] string path)
|
||||
public Task CreateFolderAsync([FromQuery] string path)
|
||||
{
|
||||
var safePath = FilePathHelper.SanitizePath(path);
|
||||
var physicalPath = Path.Combine(BaseDirectory, safePath);
|
||||
@@ -47,7 +47,7 @@ public class FilesController : Controller
|
||||
}
|
||||
|
||||
[HttpGet("list")]
|
||||
public Task<FileSystemEntryResponse[]> List([FromQuery] string path)
|
||||
public Task<FileSystemEntryResponse[]> ListAsync([FromQuery] string path)
|
||||
{
|
||||
var safePath = FilePathHelper.SanitizePath(path);
|
||||
var physicalPath = Path.Combine(BaseDirectory, safePath);
|
||||
@@ -92,7 +92,7 @@ public class FilesController : Controller
|
||||
}
|
||||
|
||||
[HttpPost("move")]
|
||||
public Task Move([FromQuery] string oldPath, [FromQuery] string newPath)
|
||||
public Task MoveAsync([FromQuery] string oldPath, [FromQuery] string newPath)
|
||||
{
|
||||
var oldSafePath = FilePathHelper.SanitizePath(oldPath);
|
||||
var newSafePath = FilePathHelper.SanitizePath(newPath);
|
||||
@@ -123,7 +123,7 @@ public class FilesController : Controller
|
||||
}
|
||||
|
||||
[HttpDelete("delete")]
|
||||
public Task Delete([FromQuery] string path)
|
||||
public Task DeleteAsync([FromQuery] string path)
|
||||
{
|
||||
var safePath = FilePathHelper.SanitizePath(path);
|
||||
var physicalDirPath = Path.Combine(BaseDirectory, safePath);
|
||||
@@ -141,7 +141,7 @@ public class FilesController : Controller
|
||||
}
|
||||
|
||||
[HttpPost("upload")]
|
||||
public async Task<IResult> Upload([FromQuery] string path)
|
||||
public async Task<IResult> UploadAsync([FromQuery] string path)
|
||||
{
|
||||
if (Request.Form.Files.Count != 1)
|
||||
return Results.Problem("Only one file is allowed in the request", statusCode: 400);
|
||||
@@ -179,7 +179,7 @@ public class FilesController : Controller
|
||||
}
|
||||
|
||||
[HttpGet("download")]
|
||||
public async Task Download([FromQuery] string path)
|
||||
public async Task DownloadAsync([FromQuery] string path)
|
||||
{
|
||||
var safePath = FilePathHelper.SanitizePath(path);
|
||||
var physicalPath = Path.Combine(BaseDirectory, safePath);
|
||||
|
||||
Reference in New Issue
Block a user