Skip to content

Commit

Permalink
fix: hash more data in dateLastModified auto-updater
Browse files Browse the repository at this point in the history
  • Loading branch information
TheGiddyLimit committed May 18, 2022
1 parent 69f1322 commit 644c6a0
Show file tree
Hide file tree
Showing 714 changed files with 716 additions and 719 deletions.
9 changes: 3 additions & 6 deletions _node/add-timestamps.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,10 @@ async function pUpdateDir (dir) {

let updateType = _UPDATE_TYPES.NONE;

// We hash the file *without* `_meta`, as `_meta` includes:
// - "dateAdded" and "dateLastModified", which we want to ignore for hashing for timestamp updates
// - the "_dateLastModifiedHash", which we want to ignore for hashing
// Unfortunately this means that updating the `_meta` does not trigger a hash change, but this is an
// acceptable sacrifice for the rest of the system being simpler.
// We hash the file without `dateAdded`, `dateLastModified`, and `_dateLastModifiedHash` to ensure the hash
// is stable when changing date values.
const toHashObj = {...fileData.json};
delete toHashObj._meta;
toHashObj._meta = {...toHashObj._meta, dateAdded: undefined, dateLastModified: undefined, _dateLastModifiedHash: undefined};
const expectedHash = (await hasha.async(JSON.stringify(toHashObj))).slice(0, 10);

if (!fileData.json._meta._dateLastModifiedHash) {
Expand Down
2 changes: 1 addition & 1 deletion action/Sample - Giddy; Extinguish.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
],
"dateAdded": 0,
"dateLastModified": 0,
"_dateLastModifiedHash": "caca90c5e3"
"_dateLastModifiedHash": "24bbcb6f02"
},
"action": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
],
"dateAdded": 1558867830,
"dateLastModified": 1558867830,
"_dateLastModifiedHash": "b4ba9c3d27"
"_dateLastModifiedHash": "631d29e8a4"
},
"adventure": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
],
"dateAdded": 1558867830,
"dateLastModified": 1558867830,
"_dateLastModifiedHash": "f7d4203072"
"_dateLastModifiedHash": "2e9c50ca64"
},
"adventure": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
],
"dateAdded": 1558867830,
"dateLastModified": 1558867830,
"_dateLastModifiedHash": "bc0e383fd8"
"_dateLastModifiedHash": "e7be74b30d"
},
"adventure": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
],
"dateAdded": 1600276023,
"dateLastModified": 1600276023,
"_dateLastModifiedHash": "7175f66f70"
"_dateLastModifiedHash": "329174137c"
},
"adventure": [
{
Expand Down
2 changes: 1 addition & 1 deletion adventure/Adventurers League; DDIA-MORD Rrakkma.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
],
"dateAdded": 1552599066,
"dateLastModified": 1552599066,
"_dateLastModifiedHash": "5c8eb89a86"
"_dateLastModifiedHash": "4dd36ef1b8"
},
"adventure": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
],
"dateAdded": 1621775534,
"dateLastModified": 1621775534,
"_dateLastModifiedHash": "11efb350fd"
"_dateLastModifiedHash": "b0551c9d64"
},
"adventure": [
{
Expand Down
2 changes: 1 addition & 1 deletion adventure/Adventures Await; The Curse of Dusk Hollow.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
],
"dateAdded": 1614898919,
"dateLastModified": 1614898919,
"_dateLastModifiedHash": "ad01921c48"
"_dateLastModifiedHash": "39433c82cc"
},
"adventure": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
],
"dateAdded": 1615141398,
"dateLastModified": 1615141398,
"_dateLastModifiedHash": "4af8aa856a"
"_dateLastModifiedHash": "da81451269"
},
"adventure": [
{
Expand Down
2 changes: 1 addition & 1 deletion adventure/Adventures Await; The Fangs of Zengar.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
],
"dateAdded": 1615141398,
"dateLastModified": 1615141398,
"_dateLastModifiedHash": "3d7e831a73"
"_dateLastModifiedHash": "ee5e030bdf"
},
"monster": [
{
Expand Down
2 changes: 1 addition & 1 deletion adventure/Adventures Await; Wrath of the Demon Lord.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
],
"dateAdded": 1621775534,
"dateLastModified": 1621775534,
"_dateLastModifiedHash": "677c1b598c"
"_dateLastModifiedHash": "f2fcc1a419"
},
"monster": [
{
Expand Down
2 changes: 1 addition & 1 deletion adventure/Anthony Joyce; The Blood Hunter Adventure.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
},
"dateAdded": 1600868694,
"dateLastModified": 1637785076,
"_dateLastModifiedHash": "c9fbae6d64"
"_dateLastModifiedHash": "5a282700ea"
},
"adventure": [
{
Expand Down
2 changes: 1 addition & 1 deletion adventure/D&D Duet; First Blush.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
],
"dateAdded": 1604518196,
"dateLastModified": 1605873511,
"_dateLastModifiedHash": "312785ff9c"
"_dateLastModifiedHash": "d735f3549d"
},
"adventure": [
{
Expand Down
2 changes: 1 addition & 1 deletion adventure/D&D Duet; Second Glance.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
],
"dateAdded": 1605873511,
"dateLastModified": 1605873511,
"_dateLastModifiedHash": "de5c25d48e"
"_dateLastModifiedHash": "be56abbd64"
},
"adventure": [
{
Expand Down
2 changes: 1 addition & 1 deletion adventure/D&D Duet; Third Times the Charm.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
],
"dateAdded": 0,
"dateLastModified": 0,
"_dateLastModifiedHash": "b2bf26dc21"
"_dateLastModifiedHash": "23e4419a0e"
},
"adventure": [
{
Expand Down
2 changes: 1 addition & 1 deletion adventure/DMDave; Assault on Quabus.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
],
"dateAdded": 1603117106,
"dateLastModified": 1603117106,
"_dateLastModifiedHash": "dcd382a14d"
"_dateLastModifiedHash": "f259b47a09"
},
"adventure": [
{
Expand Down
2 changes: 1 addition & 1 deletion adventure/JVC Parry; Call from the Deep.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
],
"dateAdded": 1579711362,
"dateLastModified": 1643743088,
"_dateLastModifiedHash": "284dcd29f0"
"_dateLastModifiedHash": "09fb1fc784"
},
"adventure": [
{
Expand Down
2 changes: 1 addition & 1 deletion adventure/Kelsey Dionne; Temple of the Basilisk Cult.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
],
"dateAdded": 1600868694,
"dateLastModified": 1600868694,
"_dateLastModifiedHash": "d6c1868ead"
"_dateLastModifiedHash": "1b96680177"
},
"adventure": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
],
"dateAdded": 1603210180,
"dateLastModified": 1603210180,
"_dateLastModifiedHash": "456ac9db38"
"_dateLastModifiedHash": "efcd521766"
},
"adventure": [
{
Expand Down
2 changes: 1 addition & 1 deletion adventure/Kobold Press; Book of Lairs.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
],
"dateAdded": 1557517754,
"dateLastModified": 1557517754,
"_dateLastModifiedHash": "cf2d9d69a2"
"_dateLastModifiedHash": "72b6b2ea97"
},
"adventure": [
{
Expand Down
2 changes: 1 addition & 1 deletion adventure/Kobold Press; Tome of Beasts 2 Lairs.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
],
"dateAdded": 1616030766,
"dateLastModified": 1616030766,
"_dateLastModifiedHash": "932883542e"
"_dateLastModifiedHash": "9f6bec3e5b"
},
"item": [
{
Expand Down
2 changes: 1 addition & 1 deletion adventure/Kurtis J Wiebe; The Hangover.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
],
"dateAdded": 1592179890,
"dateLastModified": 1592179890,
"_dateLastModifiedHash": "c4e7768e85"
"_dateLastModifiedHash": "aecac8cc26"
},
"adventure": [
{
Expand Down
2 changes: 1 addition & 1 deletion adventure/Limitless Adventures; Limitless Adventures.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
],
"dateAdded": 0,
"dateLastModified": 0,
"_dateLastModifiedHash": "f0ea627762"
"_dateLastModifiedHash": "dfc3dffccc"
},
"adventure": [
{
Expand Down
2 changes: 1 addition & 1 deletion adventure/Nerd Herd; Adventure Book - 1.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
],
"dateAdded": 1540038097,
"dateLastModified": 1540038097,
"_dateLastModifiedHash": "8d1bb740f0"
"_dateLastModifiedHash": "48ea8bd3a9"
},
"adventure": [
{
Expand Down
2 changes: 1 addition & 1 deletion adventure/Sample - Giddy; Caverns of Catastrophe.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
],
"dateAdded": 0,
"dateLastModified": 0,
"_dateLastModifiedHash": "c25737f7b5"
"_dateLastModifiedHash": "cd7c288d98"
},
"adventure": [
{
Expand Down
2 changes: 1 addition & 1 deletion adventure/TragicMissile; Sacrifice of Innocence.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
],
"dateAdded": 1619398800,
"dateLastModified": 1619658000,
"_dateLastModifiedHash": "782daf2737"
"_dateLastModifiedHash": "5c31dca770"
},
"adventure": [
{
Expand Down
2 changes: 1 addition & 1 deletion adventure/Winghorn Press; Wild Sheep Chase.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
],
"dateAdded": 1616356061,
"dateLastModified": 1616356061,
"_dateLastModifiedHash": "1e6a6216f7"
"_dateLastModifiedHash": "b0294a05cd"
},
"adventure": [
{
Expand Down
2 changes: 1 addition & 1 deletion adventure/Wizards of the Coast; Barber of Silverymoon.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
],
"dateAdded": 1586225424,
"dateLastModified": 1586225424,
"_dateLastModifiedHash": "2494bee735"
"_dateLastModifiedHash": "2a89ae07e4"
},
"adventure": [
{
Expand Down
2 changes: 1 addition & 1 deletion adventure/Wizards of the Coast; Crypts of Kelemvor.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
],
"dateAdded": 1600868694,
"dateLastModified": 1600868694,
"_dateLastModifiedHash": "432ab3130c"
"_dateLastModifiedHash": "f6b3fecba1"
},
"adventure": [
{
Expand Down
2 changes: 1 addition & 1 deletion adventure/arcanist; The Delian Tomb.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"MM"
]
},
"_dateLastModifiedHash": "a0ce174004"
"_dateLastModifiedHash": "2a49f85f6c"
},
"item": [
{
Expand Down
2 changes: 1 addition & 1 deletion background/Brewskii; Silver Thorn Background.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
],
"dateAdded": 1540936360,
"dateLastModified": 1540936360,
"_dateLastModifiedHash": "864254f489"
"_dateLastModifiedHash": "de034d1b03"
},
"background": [
{
Expand Down
2 changes: 1 addition & 1 deletion background/D&D Wiki; Featured Quality Backgrounds.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
],
"dateAdded": 1633834544,
"dateLastModified": 1649158861,
"_dateLastModifiedHash": "143aaca8c2"
"_dateLastModifiedHash": "21c9baf517"
},
"background": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
],
"dateAdded": 1587424627,
"dateLastModified": 1587424627,
"_dateLastModifiedHash": "0e9d76f2bb"
"_dateLastModifiedHash": "cdb3ad7e3f"
},
"background": [
{
Expand Down
2 changes: 1 addition & 1 deletion background/Nerd Herd; Noble Backgrounds.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
],
"dateAdded": 1540162759,
"dateLastModified": 1540162759,
"_dateLastModifiedHash": "02f0faeec4"
"_dateLastModifiedHash": "eab06e5ece"
},
"background": [
{
Expand Down
2 changes: 1 addition & 1 deletion background/Sample - Giddy; Farmer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
],
"dateAdded": 0,
"dateLastModified": 0,
"_dateLastModifiedHash": "4bd24f86c6"
"_dateLastModifiedHash": "272984671c"
},
"background": [
{
Expand Down
2 changes: 1 addition & 1 deletion background/zeek0; Backgrounds Omnibus.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
],
"dateAdded": 1549715846,
"dateLastModified": 1549715846,
"_dateLastModifiedHash": "e9d0a8b5cc"
"_dateLastModifiedHash": "594081d0ee"
},
"background": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
],
"dateAdded": 1549715846,
"dateLastModified": 1549715846,
"_dateLastModifiedHash": "d5f07319b5"
"_dateLastModifiedHash": "67a5f7cb8c"
},
"book": [
{
Expand Down
2 changes: 1 addition & 1 deletion book/Curio Solus; Festival Activies.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
],
"dateAdded": 1549715846,
"dateLastModified": 1549715846,
"_dateLastModifiedHash": "4760ddbb7c"
"_dateLastModifiedHash": "8e190c915e"
},
"book": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"DMG"
]
},
"_dateLastModifiedHash": "7832b02d23"
"_dateLastModifiedHash": "764919fa54"
},
"book": [
{
Expand Down
2 changes: 1 addition & 1 deletion book/Dave Eisinger; Discerning Merchant's Price Guide.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
],
"dateAdded": 1629491629,
"dateLastModified": 1629491629,
"_dateLastModifiedHash": "95ba4c75de"
"_dateLastModifiedHash": "f73022cd3c"
},
"book": [
{
Expand Down
2 changes: 1 addition & 1 deletion book/Ghostfire Gaming; Grim Hollow Campaign Guide.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
},
"dateAdded": 1618022160,
"dateLastModified": 1638906218,
"_dateLastModifiedHash": "3b0ea6eb1d"
"_dateLastModifiedHash": "ec0e229877"
},
"spell": [
{
Expand Down
2 changes: 1 addition & 1 deletion book/Ghostfire Gaming; Grim Hollow Player's Guide.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"BGT:P": "Background Talent; Pauper & Pit Fighter",
"BGT:S": "Background Talent; Seafarer"
},
"_dateLastModifiedHash": "4a89322a56"
"_dateLastModifiedHash": "f27da053eb"
},
"book": [
{
Expand Down
Loading

0 comments on commit 644c6a0

Please sign in to comment.