This commit is contained in:
2020-06-27 14:01:23 +00:00
parent 9c0f00fbb0
commit 50901186d3
27 changed files with 244 additions and 196 deletions

View File

@@ -416,6 +416,19 @@ namespace AyaNova.Util
}
//////////////////////////////////////////////////////////
//
// Delete all attachments for object
//
internal static async Task DeleteAttachmentsForObjectAsync(AyaType ayaType, long ayaId, AyContext ct)
{
var deleteList = await ct.FileAttachment.Where(z => z.AttachToObjectId == ayaId && z.AttachToObjectType == ayaType).ToListAsync();
foreach (var d in deleteList)
{
await DeleteFileAttachmentAsync(d, ct);
}
}
/// <summary>
/// Delete a file attachment
/// checks ref count and if would be zero deletes file physically
@@ -540,12 +553,12 @@ namespace AyaNova.Util
//got to be at least 32 chars
if (FileName.Length < 32) return false;
//probably all 64 chars but let's not count on that and go with folder is correct
//what *should* the path be for a file of this name?
var ExpectedFullPath=GetPermanentAttachmentFilePath(FileName);
var ExpectedFullPath = GetPermanentAttachmentFilePath(FileName);
//if expected equals real then it's very likely an orphaned file
return fullPathName==ExpectedFullPath;
return fullPathName == ExpectedFullPath;
}