[backend/drive] Fix drive file expiry leaving orphaned file versions in the storage backend
This commit is contained in:
parent
bfd0feaf95
commit
ead9d90029
1 changed files with 10 additions and 7 deletions
|
@ -437,6 +437,8 @@ public class DriveService(
|
||||||
{
|
{
|
||||||
if (file is not { UserHost: not null, Uri: not null, IsLink: false }) return;
|
if (file is not { UserHost: not null, Uri: not null, IsLink: false }) return;
|
||||||
|
|
||||||
|
string?[] paths = [file.AccessKey, file.ThumbnailAccessKey, file.PublicAccessKey];
|
||||||
|
|
||||||
file.IsLink = true;
|
file.IsLink = true;
|
||||||
file.Url = file.Uri;
|
file.Url = file.Uri;
|
||||||
file.ThumbnailUrl = null;
|
file.ThumbnailUrl = null;
|
||||||
|
@ -453,15 +455,16 @@ public class DriveService(
|
||||||
.ExecuteUpdateAsync(p => p.SetProperty(u => u.BannerUrl, file.Uri), token);
|
.ExecuteUpdateAsync(p => p.SetProperty(u => u.BannerUrl, file.Uri), token);
|
||||||
await db.SaveChangesAsync(token);
|
await db.SaveChangesAsync(token);
|
||||||
|
|
||||||
if (file.AccessKey == null) return;
|
if (file.AccessKey != null)
|
||||||
var deduplicated =
|
{
|
||||||
await db.DriveFiles.AnyAsync(p => p.Id != file.Id && p.AccessKey == file.AccessKey && !p.IsLink,
|
var deduplicated = await db.DriveFiles
|
||||||
token);
|
.AnyAsync(p => p.Id != file.Id && p.AccessKey == file.AccessKey && !p.IsLink,
|
||||||
|
token);
|
||||||
|
|
||||||
if (deduplicated)
|
if (deduplicated)
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
string?[] paths = [file.AccessKey, file.ThumbnailAccessKey, file.PublicAccessKey];
|
|
||||||
if (file.StoredInternal)
|
if (file.StoredInternal)
|
||||||
{
|
{
|
||||||
var pathBase = storageConfig.Value.Local?.Path ??
|
var pathBase = storageConfig.Value.Local?.Path ??
|
||||||
|
|
Loading…
Add table
Reference in a new issue