isNewer
I would like to regularly check to see if any theme files have been updated on my client's site. I propose a flag to the download command that just checks if the file on Shopify is newer than the local file, or if the checksums of the two are different. It would return a list of files that are different (perhaps with the two checksums) in a way that could be piped to code that would set up a download of files that were different.
Running theme download --verbose seems to indicate that only files that are different are downloaded, but it isn't clear to me how this decision is made. It would be nice to have more explicit control and also to decide to download or not. This hopefully would give an answer faster than trying to download everything which slows to a crawl once throttling kicks in. For one of my clients (I haven't tested them all), it takes over hour for download to run, even when I run it when I know there have been no changes on Shopify since the last run.
Another solution would be a command that just returned the file name, last_modified, and checksum for each file in the theme. This could then be compared locally with other tools, and again, hopefully not subject to as much throttling.
On further examination and testing the download comparison of remote and local checksums at line 57 in cmd/download.go https://github.com/Shopify/themekit/blob/7a0e38b011d07c1afcdf87dcacd9a7a86579c7ff/cmd/download.go#L57 seems to be failing. I provided a single file (a .png image file) to download and once complete, I repeated the command. The file was downloaded again. I had the same result with a .liquid file... perhaps this is a bug?
$[425]> theme download --verbose snippets/product-details.liquid
[dev] Warning, this is the live theme on dev.
[dev] Successfully wrote snippets/product-details.liquid to disk (Local: 25e1e842c1932f02d1ed04ef15a97e6c)
Downloaded: 1, No Changes: 0, Errored: 0
$[426]> theme download --verbose snippets/product-details.liquid
[dev] Warning, this is the live theme on dev.
[dev] Successfully wrote snippets/product-details.liquid to disk (Local: 25e1e842c1932f02d1ed04ef15a97e6c)
Downloaded: 1, No Changes: 0, Errored: 0
You can see the local checksums are the same both times.
We are still working out some kinks in the checksum comparisons. Mostly there may be differences in how assets are stored in shopify vs how they are stored on the fs. So there are instances right now where we don't manage to filter out all uneeded updates. We are working on making this better in the future.
@davidsturman from the output in your message, it looks like some of the assets don't currently have a remote checksum. This is expected for existing themes from before we added this feature, as we didn't 'backfill' checksums for older assets. If you upload the asset that should trigger a remote checksum to be set, and next time it should not be re-downloaded.
Thank you. This helped. .png and .gif files seem still not to be given checksums (and these are some of the ones I want to track), as well as one small minified .js file (while another minified .js was fine).