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)
|
||||
{
|
||||
string old;
|
||||
string checkFile;
|
||||
string? pathRoot;
|
||||
JsonSerializerOptions jsonSerializerOptions = new() { WriteIndented = true };
|
||||
@ -135,12 +136,9 @@ public class FileRead : Shared.FileRead, IFileRead
|
||||
if (!Directory.Exists(alternateTargetFolder))
|
||||
_ = Directory.CreateDirectory(alternateTargetFolder);
|
||||
checkFile = Path.Combine(alternateTargetFolder, fileConnectorConfiguration.TargetFileName);
|
||||
if (File.Exists(checkFile))
|
||||
{
|
||||
string old = File.ReadAllText(checkFile);
|
||||
if (old == json)
|
||||
continue;
|
||||
}
|
||||
old = !File.Exists(checkFile) ? string.Empty : File.ReadAllText(checkFile);
|
||||
if (old == json)
|
||||
continue;
|
||||
File.WriteAllText(checkFile, json);
|
||||
}
|
||||
}
|
||||
@ -361,7 +359,7 @@ public class FileRead : Shared.FileRead, IFileRead
|
||||
{
|
||||
AppendLines(spaces, lines, workItemAndChildren, workItemType);
|
||||
checkFile = Path.Combine(alternateTargetFolder, $"{workItemType}.md");
|
||||
text = string.Join(Environment.NewLine, lines);
|
||||
text = string.Join(Environment.NewLine, lines);
|
||||
old = !File.Exists(checkFile) ? string.Empty : File.ReadAllText(checkFile);
|
||||
if (text != old)
|
||||
File.WriteAllText(checkFile, text);
|
||||
@ -431,22 +429,17 @@ public class FileRead : Shared.FileRead, IFileRead
|
||||
private void MoveJson(string reportFullPath, DateTime dateTime)
|
||||
#pragma warning restore IDE0060
|
||||
{
|
||||
bool moveFile = true;
|
||||
string json = File.ReadAllText(reportFullPath);
|
||||
Value? value = JsonSerializer.Deserialize<Value>(json);
|
||||
if (value is null)
|
||||
throw new Exception(nameof(value));
|
||||
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);
|
||||
}
|
||||
if (moveFile)
|
||||
File.Delete(checkFile);
|
||||
File.Move(reportFullPath, checkFile);
|
||||
}
|
||||
}
|
||||
|
||||
private Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime dateTime)
|
||||
|
Loading…
x
Reference in New Issue
Block a user