Skip to content

Commit fb55c33

Browse files
committed
clean opnames in cache
1 parent 4ca19f4 commit fb55c33

2 files changed

Lines changed: 22 additions & 15 deletions

File tree

shared/api/utils/shared_doc_util.js

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -505,29 +505,37 @@ export default class SharedDocUtil extends SharedUtil
505505
if (op && op.name && op.id)
506506
{
507507
let error = false;
508-
if (cachedLookup.ids[op.id] && cachedLookup.ids[op.id] !== op.name)
509-
{
510-
this._log.warn("DUPLICATE OP ID", op.id, op.name, cachedLookup.ids[op.id]);
511-
error = true;
512-
}
513508
if (cachedLookup.names[op.name] && cachedLookup.names[op.name] !== op.id)
514509
{
515510
this._log.warn("DUPLICATE OP NAME", op.name, op.id, cachedLookup.names[op.names]);
516511
error = true;
517512
}
513+
518514
if (error && haltOnError) throw new Error("OP LOOKUP CONSISTENCY ERROR!" + op.id + " " + op.name + " " + cachedLookup.ids[op.id]);
519-
if (cachedLookup.ids[op.id] !== op.name)
515+
if (!error)
520516
{
521-
changed = true;
522-
cachedLookup.ids[op.id] = op.name;
523-
}
524-
if (cachedLookup.names[op.name] !== op.id)
525-
{
526-
changed = true;
527-
cachedLookup.names[op.name] = op.id;
517+
if (cachedLookup.ids[op.id] !== op.name)
518+
{
519+
changed = true;
520+
cachedLookup.ids[op.id] = op.name;
521+
}
522+
if (cachedLookup.names[op.name] !== op.id)
523+
{
524+
changed = true;
525+
cachedLookup.names[op.name] = op.id;
526+
}
528527
}
529528
}
530529
});
530+
for (const oldName in cachedLookup.names)
531+
{
532+
const oldId = cachedLookup.names[oldName];
533+
if (cachedLookup.ids[oldId] !== oldName)
534+
{
535+
delete cachedLookup.names[oldName];
536+
changed = true;
537+
}
538+
}
531539
this.setCachedLookup(cachedLookup);
532540
if (changed)
533541
{

shared/api/utils/shared_ops_util.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3857,9 +3857,8 @@ export default class SharedOpsUtil extends SharedUtil
38573857

38583858
if (removeOld)
38593859
{
3860-
fs.emptyDirSync(oldOpDir);
3860+
fs.rmSync(oldOpDir, { "recursive": true, "force": true });
38613861
this._docsUtil.replaceOpNameInLookup(oldName, newName);
3862-
fs.rmSync(oldOpDir, { "recursive": true });
38633862
}
38643863

38653864
if (!removeOld || newId)

0 commit comments

Comments
 (0)