Skip to content

Commit cbe2e29

Browse files
committed
only check hash when file exists
1 parent d588c33 commit cbe2e29

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

Tocsoft.GraphQLCodeGen.MsBuild/GenerateGraphQLClient.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,21 +103,22 @@ public override bool Execute()
103103
string fileName = Path.GetFileName(f);
104104
string newFileContent = File.ReadAllText(f);
105105
string hashFile = Path.Combine(fullIntermediateOutputDirectory, fileName + ".hash");
106+
string targetPath = Path.Combine(fullIntermediateOutputDirectory, fileName);
107+
106108
bool filedirty = true;
107109
string actualHash = GetSha256Hash(sha, newFileContent); // TODO skip section while hashing (generated date etc)
108-
if (File.Exists(hashFile))
110+
if (File.Exists(hashFile) && File.Exists(targetPath)) // ensure we only try and skip if files exist on disk
109111
{
110112
string hash = File.ReadAllText(hashFile);
111113
filedirty = hash != actualHash;
112114
}
113-
File.WriteAllText(hashFile, actualHash);
114115

115-
string targetPAth = Path.Combine(fullIntermediateOutputDirectory, fileName);
116116
if (filedirty)
117117
{
118-
File.WriteAllText(targetPAth, newFileContent);
118+
File.WriteAllText(hashFile, actualHash);
119+
File.WriteAllText(targetPath, newFileContent);
119120
}
120-
generateFiles.Add(new TaskItem(targetPAth));
121+
generateFiles.Add(new TaskItem(targetPath));
121122
}
122123
// find matching files in this folder if they have identical hashes then skip them
123124

0 commit comments

Comments
 (0)