Merge pull request #5057 from sbwalker/dev
fix #5044 - improve file part removal logic
This commit is contained in:
commit
6f588200d7
|
@ -536,17 +536,23 @@ namespace Oqtane.Controllers
|
|||
// clean up file parts
|
||||
foreach (var file in Directory.GetFiles(folder, "*" + token + "*"))
|
||||
{
|
||||
// file name matches part or is more than 2 hours old (ie. a prior file upload failed)
|
||||
if (fileparts.Contains(file) || System.IO.File.GetCreationTime(file).ToUniversalTime() < DateTime.UtcNow.AddHours(-2))
|
||||
if (fileparts.Contains(file))
|
||||
{
|
||||
try
|
||||
{
|
||||
System.IO.File.Delete(file);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// unable to delete part - ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// rename temp file
|
||||
if (success)
|
||||
{
|
||||
// remove file if it already exists (as well as any thumbnails)
|
||||
// remove file if it already exists (as well as any thumbnails which may exist)
|
||||
foreach (var file in Directory.GetFiles(folder, Path.GetFileNameWithoutExtension(filename) + ".*"))
|
||||
{
|
||||
if (Path.GetExtension(file) != ".tmp")
|
||||
|
|
Loading…
Reference in New Issue
Block a user