mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 14:13:43 +01:00
Merge pull request #19547 from overleaf/jpa-move-v2-doc-versions
[overleaf-editor-core] keep v2DocVersions in-sync with fileMap GitOrigin-RevId: 23491dfe51b71561837c96b8c550f75b0835a176
This commit is contained in:
@@ -133,6 +133,7 @@ class Snapshot {
|
||||
*/
|
||||
moveFile(pathname, newPathname) {
|
||||
this.fileMap.moveFile(pathname, newPathname)
|
||||
if (this.v2DocVersions) this.v2DocVersions.moveFile(pathname, newPathname)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -50,6 +50,23 @@ class V2DocVersions {
|
||||
_.assign(snapshot.v2DocVersions.data, this.data)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Move or remove a doc.
|
||||
* Must be called after FileMap#moveFile, which validates the paths.
|
||||
*/
|
||||
moveFile(pathname, newPathname) {
|
||||
for (const [id, v] of Object.entries(this.data)) {
|
||||
if (v.pathname !== pathname) continue
|
||||
|
||||
if (newPathname === '') {
|
||||
delete this.data[id]
|
||||
} else {
|
||||
v.pathname = newPathname
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = V2DocVersions
|
||||
|
||||
Reference in New Issue
Block a user