🐛 Try to fix the soft delete filter didn't work in drive
This commit is contained in:
@@ -306,7 +306,7 @@ public class FileController(
|
||||
|
||||
[Authorize]
|
||||
[HttpDelete("{id}")]
|
||||
public async Task<ActionResult> DeleteFile(string id)
|
||||
public async Task<ActionResult<SnCloudFile>> DeleteFile(string id)
|
||||
{
|
||||
if (HttpContext.Items["CurrentUser"] is not Account currentUser) return Unauthorized();
|
||||
var userId = Guid.Parse(currentUser.Id);
|
||||
@@ -318,9 +318,9 @@ public class FileController(
|
||||
if (file is null) return NotFound();
|
||||
|
||||
await fs.DeleteFileDataAsync(file, force: true);
|
||||
await fs.DeleteFileAsync(file);
|
||||
await fs.DeleteFileAsync(file, skipData: true);
|
||||
|
||||
return NoContent();
|
||||
return Ok(file);
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
|
||||
@@ -103,7 +103,8 @@ public class FileService(
|
||||
var bundle = await ValidateAndGetBundleAsync(fileBundleId, accountId);
|
||||
var finalExpiredAt = CalculateFinalExpiration(expiredAt, pool, bundle);
|
||||
|
||||
var (managedTempPath, fileSize, finalContentType) = await PrepareFileAsync(fileId, filePath, fileName, contentType);
|
||||
var (managedTempPath, fileSize, finalContentType) =
|
||||
await PrepareFileAsync(fileId, filePath, fileName, contentType);
|
||||
|
||||
var file = CreateFileObject(fileId, fileName, finalContentType, fileSize, finalExpiredAt, bundle, accountId);
|
||||
|
||||
@@ -112,7 +113,8 @@ public class FileService(
|
||||
await ExtractMetadataAsync(file, managedTempPath);
|
||||
}
|
||||
|
||||
var (processingPath, isTempFile) = await ProcessEncryptionAsync(fileId, managedTempPath, encryptPassword, pool, file);
|
||||
var (processingPath, isTempFile) =
|
||||
await ProcessEncryptionAsync(fileId, managedTempPath, encryptPassword, pool, file);
|
||||
|
||||
file.Hash = await HashFileAsync(processingPath);
|
||||
|
||||
@@ -231,7 +233,8 @@ public class FileService(
|
||||
file.StorageId ??= file.Id;
|
||||
}
|
||||
|
||||
private async Task PublishFileUploadedEventAsync(SnCloudFile file, FilePool pool, string processingPath, bool isTempFile)
|
||||
private async Task PublishFileUploadedEventAsync(SnCloudFile file, FilePool pool, string processingPath,
|
||||
bool isTempFile)
|
||||
{
|
||||
var js = nats.CreateJetStreamContext();
|
||||
await js.PublishAsync(
|
||||
@@ -471,13 +474,14 @@ public class FileService(
|
||||
return await db.Files.AsNoTracking().FirstAsync(f => f.Id == file.Id);
|
||||
}
|
||||
|
||||
public async Task DeleteFileAsync(SnCloudFile file)
|
||||
public async Task DeleteFileAsync(SnCloudFile file, bool skipData = false)
|
||||
{
|
||||
db.Remove(file);
|
||||
await db.SaveChangesAsync();
|
||||
await _PurgeCacheAsync(file.Id);
|
||||
|
||||
await DeleteFileDataAsync(file);
|
||||
if (!skipData)
|
||||
await DeleteFileDataAsync(file);
|
||||
}
|
||||
|
||||
public async Task DeleteFileDataAsync(SnCloudFile file, bool force = false)
|
||||
@@ -660,9 +664,12 @@ public class FileService(
|
||||
}
|
||||
}
|
||||
|
||||
return [.. references
|
||||
.Select(r => cachedFiles.GetValueOrDefault(r.Id))
|
||||
.Where(f => f != null)];
|
||||
return
|
||||
[
|
||||
.. references
|
||||
.Select(r => cachedFiles.GetValueOrDefault(r.Id))
|
||||
.Where(f => f != null)
|
||||
];
|
||||
}
|
||||
|
||||
public async Task<int> GetReferenceCountAsync(string fileId)
|
||||
@@ -781,4 +788,4 @@ file class UpdatableCloudFile(SnCloudFile file)
|
||||
.SetProperty(f => f.UserMeta, userMeta)
|
||||
.SetProperty(f => f.IsMarkedRecycle, IsMarkedRecycle);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user