Cscott has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/159190

Change subject: Make sure the collection id is specific to the backend selected.
......................................................................

Make sure the collection id is specific to the backend selected.

If the user first generated an output using (say) the rdf2text backend,
we'd return that output even if the user tried to generate a PDF for
the same article.  I believe this is an artifact of the original
design, where we planned to cache the bundler output separately.
But at the moment we only cache the final output, so the collection
ID needs to be specific to the backend chosen.

Change-Id: Ic6a55b9ac160a389a8a612fde87676752331590e
---
M lib/threads/frontend.js
1 file changed, 10 insertions(+), 2 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Collection/OfflineContentGenerator
 refs/changes/90/159190/1

diff --git a/lib/threads/frontend.js b/lib/threads/frontend.js
index 38cb3e1..61f7395 100644
--- a/lib/threads/frontend.js
+++ b/lib/threads/frontend.js
@@ -385,7 +385,7 @@
                                        400
                                );
                        }
-                       collectionId = createCollectionId( metabookObj );
+                       collectionId = createCollectionId( metabookObj, writer 
);
                }
        }
 
@@ -632,9 +632,10 @@
  * is rendered.
  *
  * @param metabookObj {*} Object created from JSON.parse of the metabook 
parameter
+ * @param writer {string} Target backend
  * @returns string
  */
-function createCollectionId( metabookObj ) {
+function createCollectionId( metabookObj, writer ) {
        var collectionId = crypto.createHash( 'sha1' );
        collectionId.update( metabookObj.title || '' );
        collectionId.update( metabookObj.subtitle || '' );
@@ -655,6 +656,13 @@
        };
        updateChapter( metabookObj.items );
 
+       // XXX in the future we might separately cache the bundle.zip and
+       // the final rendered output.  In that case the collection id would
+       // be specific to the bundle, and we'd generate another id for the
+       // bundle->backend step.  But at the moment we only cache the final
+       // result, so we need to add the backend ("writer") to the hash.
+       collectionId.update( writer );
+
        return collectionId.digest( 'hex' );
 }
 

-- 
To view, visit https://gerrit.wikimedia.org/r/159190
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic6a55b9ac160a389a8a612fde87676752331590e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Collection/OfflineContentGenerator
Gerrit-Branch: master
Gerrit-Owner: Cscott <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to