From 945669fd816ee57013b814f0165c3aefcaf1fa2e Mon Sep 17 00:00:00 2001 From: Mitra Ardron Date: Fri, 27 Jul 2018 11:38:25 -0700 Subject: [PATCH] Gun - hack till figure out how to delete legacy metadata from pre IPFS rawl-leaves update --- TransportGUN.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/TransportGUN.js b/TransportGUN.js index b8fc9ac..5ccffd1 100644 --- a/TransportGUN.js +++ b/TransportGUN.js @@ -119,7 +119,12 @@ class TransportGUN extends Transport { let g = this.connection(url, verbose); // Goes all the way to the key let val = await this._p_once(g); if (!val) throw new errors.TransportError("GUN unable to retrieve: "+url.href); // WORKAROUND-GUN-ERRORS - gun doesnt throw errors when it cant find something - return typeof val === "string" ? JSON.parse(val) : val; // This looks like it is sync (see same code on p_get and p_rawfetch) + let o = typeof val === "string" ? JSON.parse(val) : val; // This looks like it is sync (see same code on p_get and p_rawfetch) + //TODO-GUN this is a hack because the metadata such as metadata/audio is getting cached in GUN and in this case is wrong. + if (o.metadata && o.metadata.thumbnaillinks && o.metadata.thumbnaillinks.find(t => t.includes('ipfs/zb2'))) { + throw new errors.TransportError("GUN retrieving legacy data at: "+url.href) + } + return o; }