Problems getting root hash uploading static site using the JS HTTP client

I am trying to create an automated tool for deploying static websites to IPFS and am running into issues getting my root hash.

My testing procedure has been using the same source code each time, so while there are some per-build differences, a number of the files are the same each time. I’m also using the JS HTTP client to add the files, rather than the CLI.

I am using the regular Files API and am calling ipfs.add() with an array of objects which have the file content as a buffer, rather than reading from the file system. Unfortunately, the response doesn’t include all of the files that I call it with, or more importantly, the overall root hash for the directory. I get hashes for all the files & directories if I pass onlyHash: true, but then that hash cannot be found on gateways. I am also passing wrapWithDirectory.

Am I misunderstanding how IPFS would work in this scenario? I was expecting for it to be idempotent – if I try to add a file which has already been added, it just returns the same hash it did last time. If that were the case, though, I would also expect to get a new root hash which refers to this new updated deployment where some of the files are different.

Anyone have tips on why I’m not getting that root hash back from add()? Do I need to provide different options, or put the data in a different shape? Would appreciate any ideas!