mirror of
https://github.com/overleaf/overleaf.git
synced 2025-01-23 22:31:12 +00:00
Merge pull request #1853 from overleaf/bg-check-doc-hashes-staged-rollout
enable sharejs hash checking GitOrigin-RevId: 2c71d239b2f5ee2bee6baf03dd54aaa8afc6fae7
This commit is contained in:
parent
9ca3b68efc
commit
c242a8d4c1
2 changed files with 14 additions and 3 deletions
|
@ -175,6 +175,9 @@ block requirejs
|
|||
window.aceWorkerPath = "#{aceWorkerPath}";
|
||||
window.pdfCMapsPath = "#{pdfCMapsPath}"
|
||||
window.uiConfig = JSON.parse('!{JSON.stringify(uiConfig).replace(/\//g, "\\/")}');
|
||||
//- enable doc hash checking for projects created after 2019-06-09
|
||||
//- this is for a staged rollout, eventually we will turn this on for all projects
|
||||
window.useShareJsHash = (window.project_id > "5cfd8f700000000000000000")
|
||||
|
||||
- if (settings.overleaf != null)
|
||||
script(type='text/javascript').
|
||||
|
|
|
@ -1303,9 +1303,17 @@ define(['ace/ace','libs/sha1'], function () {
|
|||
|
||||
this.emit('flipped_pending_to_inflight');
|
||||
|
||||
if (window.sl_debugging) {
|
||||
// send git hash of current snapshot when debugging
|
||||
var sha1 = CryptoJS.SHA1("blob " + this.snapshot.length + "\x00" + this.snapshot).toString()
|
||||
if (window.useShareJsHash || window.sl_debugging) {
|
||||
var now = Date.now()
|
||||
var age = this.__lastSubmitTimestamp && (now - this.__lastSubmitTimestamp)
|
||||
var RECOMPUTE_HASH_INTERVAL = 5000
|
||||
// check the document hash regularly (but not if we have checked in the last 5 seconds)
|
||||
var needToRecomputeHash = !this.__lastSubmitTimestamp || (age > RECOMPUTE_HASH_INTERVAL) || (age < 0)
|
||||
if (needToRecomputeHash || window.sl_debugging) {
|
||||
// send git hash of current snapshot
|
||||
var sha1 = CryptoJS.SHA1("blob " + this.snapshot.length + "\x00" + this.snapshot).toString()
|
||||
this.__lastSubmitTimestamp = now;
|
||||
}
|
||||
}
|
||||
|
||||
// console.log "SENDING OP TO SERVER", @inflightOp, @version
|
||||
|
|
Loading…
Reference in a new issue