This commit is contained in:
2020-06-27 00:04:51 +00:00
parent 433c97b36e
commit 4c33a05e6d
2 changed files with 89 additions and 11 deletions

View File

@@ -522,6 +522,34 @@ namespace AyaNova.Util
return File.Exists(GetPermanentAttachmentFilePath(fileName));
}
internal static bool AppearsToBeAnOrphanedAttachment(string fullPathName)
{
// is it in the correct folder which is named based on it's hash?
// Is it X characters long (they all are or not?) Not sure though actually, maybe they are all 64 characters, maybe not
// Does it have an extension? None of ours have an extension
if (Path.HasExtension(fullPathName)) return false;
var FileName = Path.GetFileName(fullPathName);
//2339371F6C0C88656888163072635B282BB7FFF7B33771AB2295C868A0FECD34
//3D67D4D258DCC7BB3CB560013C737E9865DFFB324C2012AA7E9E75CCCBE4133C
//BA7816BF8F01CFEA414140DE5DAE2223B00361A396177A9CB410FF61F20015AD
//40CE02D157C845E42AA4EF7DCC93A74B0179649C8D0A806B2F985D34AA7385CE
//9F2BA2DF87889B1E71346CC575A6F57334B441DB5AE4D40814F95E232C9539B5
//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);
//if expected equals real then it's very likely an orphaned file
return fullPathName==ExpectedFullPath;
}
#endregion attachment stuff
#region General utilities