Better old check
This commit is contained in:
parent
c6c2ff6960
commit
a84e2637bb
@ -114,6 +114,7 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
|
|
||||||
private static void ParseWorkItemsAsync(FileConnectorConfiguration fileConnectorConfiguration, string[] alternateTargetFolders, ReadOnlyCollection<WorkItem> workItems)
|
private static void ParseWorkItemsAsync(FileConnectorConfiguration fileConnectorConfiguration, string[] alternateTargetFolders, ReadOnlyCollection<WorkItem> workItems)
|
||||||
{
|
{
|
||||||
|
string old;
|
||||||
string checkFile;
|
string checkFile;
|
||||||
string? pathRoot;
|
string? pathRoot;
|
||||||
JsonSerializerOptions jsonSerializerOptions = new() { WriteIndented = true };
|
JsonSerializerOptions jsonSerializerOptions = new() { WriteIndented = true };
|
||||||
@ -135,12 +136,9 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
if (!Directory.Exists(alternateTargetFolder))
|
if (!Directory.Exists(alternateTargetFolder))
|
||||||
_ = Directory.CreateDirectory(alternateTargetFolder);
|
_ = Directory.CreateDirectory(alternateTargetFolder);
|
||||||
checkFile = Path.Combine(alternateTargetFolder, fileConnectorConfiguration.TargetFileName);
|
checkFile = Path.Combine(alternateTargetFolder, fileConnectorConfiguration.TargetFileName);
|
||||||
if (File.Exists(checkFile))
|
old = !File.Exists(checkFile) ? string.Empty : File.ReadAllText(checkFile);
|
||||||
{
|
|
||||||
string old = File.ReadAllText(checkFile);
|
|
||||||
if (old == json)
|
if (old == json)
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
File.WriteAllText(checkFile, json);
|
File.WriteAllText(checkFile, json);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -431,23 +429,18 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
private void MoveJson(string reportFullPath, DateTime dateTime)
|
private void MoveJson(string reportFullPath, DateTime dateTime)
|
||||||
#pragma warning restore IDE0060
|
#pragma warning restore IDE0060
|
||||||
{
|
{
|
||||||
bool moveFile = true;
|
|
||||||
string json = File.ReadAllText(reportFullPath);
|
string json = File.ReadAllText(reportFullPath);
|
||||||
Value? value = JsonSerializer.Deserialize<Value>(json);
|
Value? value = JsonSerializer.Deserialize<Value>(json);
|
||||||
if (value is null)
|
if (value is null)
|
||||||
throw new Exception(nameof(value));
|
throw new Exception(nameof(value));
|
||||||
string checkFile = Path.Combine(_FileConnectorConfiguration.TargetFileLocation, $"{value.Id}.json");
|
string checkFile = Path.Combine(_FileConnectorConfiguration.TargetFileLocation, $"{value.Id}.json");
|
||||||
if (File.Exists(checkFile))
|
string old = !File.Exists(checkFile) ? string.Empty : File.ReadAllText(checkFile);
|
||||||
|
if (json != old)
|
||||||
{
|
{
|
||||||
string old = File.ReadAllText(checkFile);
|
|
||||||
if (json == old)
|
|
||||||
moveFile = false;
|
|
||||||
else
|
|
||||||
File.Delete(checkFile);
|
File.Delete(checkFile);
|
||||||
}
|
|
||||||
if (moveFile)
|
|
||||||
File.Move(reportFullPath, checkFile);
|
File.Move(reportFullPath, checkFile);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime dateTime)
|
private Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime dateTime)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user