Skip to content

Commit

Permalink
Md5 hash diffing to skip generating unchanged files (#316)
Browse files Browse the repository at this point in the history
* add simple md5 hashing to compare file contents and speed up parsing

fix the import paths

* generate run.n

* output the hashes into cfg.outputDir + "/hashes/" instead of in the input directory

* generate run.n
  • Loading branch information
ninjamuffin99 authored Sep 1, 2024
1 parent 3eac1d9 commit ef8eaf0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
Binary file modified run.n
Binary file not shown.
18 changes: 18 additions & 0 deletions src/dox/Dox.hx
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,25 @@ class Dox {
function parseFile(path) {
var name = new Path(path).file;
Sys.println('Parsing $path');

var hashPaths = cfg.outputPath + "/hashes/";

if (!FileSystem.exists(hashPaths))
FileSystem.createDirectory(hashPaths);

var data = sys.io.File.getContent(path);
var md5Hash = haxe.crypto.Md5.encode(data);

if (sys.FileSystem.exists(hashPaths + name + ".md5")) {
var previousHash = sys.io.File.getContent(hashPaths + name + ".md5");
if (md5Hash == previousHash) {
Sys.println('Skipping $path, no file changes detected');
return;
}
}

sys.io.File.saveContent(hashPaths + name + ".md5", md5Hash);

var xml = try Xml.parse(data).firstElement() catch (err:Dynamic) {
trace('Error while parsing $path');
throw err;
Expand Down

0 comments on commit ef8eaf0

Please sign in to comment.