Move file missing logging to a better location, and log actual filenames to logs

This commit is contained in:
Dean Herbert 2023-05-05 16:50:05 +09:00
parent 4ec98b0578
commit 9cafb20fcb
1 changed files with 11 additions and 11 deletions

View File

@ -54,20 +54,14 @@ private void exportZipArchive(TModel model, Stream outputStream, ProgressNotific
using (var stream = UserFileStorage.GetStream(file.File.GetStoragePath()))
{
// Sometimes we cannot find the file(probably deleted by the user), so we handle this and post a error.
if (stream == null)
{
// Only pop up once to prevent spam.
if (!fileMissing)
{
Logger.Log("Some of model files are missing, they will not be included in the archive", LoggingTarget.Database, LogLevel.Error);
fileMissing = true;
}
}
else
{
writer.Write(file.Filename, stream);
Logger.Log($"File {file.Filename} is missing in local storage and will not be included in the export", LoggingTarget.Database);
fileMissing = true;
continue;
}
writer.Write(file.Filename, stream);
}
if (notification != null)
@ -77,6 +71,12 @@ private void exportZipArchive(TModel model, Stream outputStream, ProgressNotific
i++;
}
// Only pop up once to prevent spam.
if (fileMissing)
{
Logger.Log("Some of model files are missing, they will not be included in the archive", LoggingTarget.Database, LogLevel.Error);
}
}
catch (ObjectDisposedException)
{