From 3f1132b1db92177023cd2bbf1959c450ebbd2ef3 Mon Sep 17 00:00:00 2001 From: GZTime Date: Fri, 6 Oct 2023 23:33:36 +0800 Subject: [PATCH] feat: always store file to fs --- src/GZCTF/Repositories/FileRepository.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/GZCTF/Repositories/FileRepository.cs b/src/GZCTF/Repositories/FileRepository.cs index 662488594..86f40b78a 100644 --- a/src/GZCTF/Repositories/FileRepository.cs +++ b/src/GZCTF/Repositories/FileRepository.cs @@ -134,19 +134,19 @@ async Task StoreLocalFile(string fileName, Stream contentStream, Canc { localFile = new() { Hash = fileHash, Name = fileName, FileSize = contentStream.Length }; await context.AddAsync(localFile, token); + } - var path = Path.Combine(FilePath.Uploads, localFile.Location); + var path = Path.Combine(FilePath.Uploads, localFile.Location); - if (!Directory.Exists(path)) - Directory.CreateDirectory(path); + if (!Directory.Exists(path)) + Directory.CreateDirectory(path); - using FileStream fileStream = File.Create(Path.Combine(path, localFile.Hash)); + using FileStream fileStream = File.Create(Path.Combine(path, localFile.Hash)); - contentStream.Position = 0; - await contentStream.CopyToAsync(fileStream, token); - } + contentStream.Position = 0; + await contentStream.CopyToAsync(fileStream, token); await SaveAsync(token); return localFile; } -} \ No newline at end of file +}