Files
overleaf-cep/libraries/overleaf-editor-core/index.js
T
Jakob AckermannandClaude Opus 5 6caa5fc3a3 [monorepo] read empty content from its hash, in a shared blob store base (#36831)
The hash of empty content is a property of the content rather than of anything
stored: every project's empty file has it, whether or not a blob was ever written
under it, and a file may reference it before anything has. Eight blob stores were
each paying a lookup -- a database query, an HTTP request, a read of a cache that
offline mode may be the only thing standing in for -- to be told what the hash
already says, and clsi had already reinvented the answer on its own.

overleaf-editor-core gains BlobStoreBase, which answers getString for that hash
and delegates the rest to the fetchString its subclasses provide. getObject comes
with it: four stores spelled out the same JSON.parse of getString, and a fifth
wrapped it in a log line.

Adopted by history-v1's BlobStore, BackupBlobStore, HashCheckBlobStore and
recover_zip's RecoveryBlobStore, by project-history's BlobStore, by clsi's
BlobStore, and by web's HistoryBlobStore, SimpleBlobStore and FrontendBlobStore.
history-v1 keeps its own answers in getStream, getBlob and getBlobs, which no
other store implements. Writing and copying a blob are untouched, so a project
that wrote empty content still has a blob for it and a read answers the same
either way.

Two paths could not handle a project holding a tracked change or a comment at
all. Loading such a file needs the ranges blob its rangesHash points at, and
hashing one again needs to write it back, so a store missing getObject or
putObject fails outright:

- recover_zip died on `blobStore.getObject is not a function`, making every such
  project unrecoverable. The test covering it asserts a tracked delete is absent
  from the zip, which the script already asked for and never reached.
- GET /projects/:project_id/latest/hashed_content returned 500 from the same
  cause, then would have hit a missing putObject in snapshot.store.
  HashCheckBlobStore becomes a class over the base and gains putObject.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
GitOrigin-RevId: c84f62465beff6cf77ffac26aa772984e1b554cb
2026-09-17 12:06:30 +00:00

122 lines
5.1 KiB
JavaScript

const AddCommentOperation = require('./lib/operation/add_comment_operation')
const Author = require('./lib/author')
const AuthorList = require('./lib/author_list')
const Blob = require('./lib/blob')
const BlobStoreBase = require('./lib/blob_store_base')
const Change = require('./lib/change')
const ChangeRequest = require('./lib/change_request')
const ChangeNote = require('./lib/change_note')
const Chunk = require('./lib/chunk')
const ChunkResponse = require('./lib/chunk_response')
const Comment = require('./lib/comment')
const DeleteCommentOperation = require('./lib/operation/delete_comment_operation')
const File = require('./lib/file')
const FileMap = require('./lib/file_map')
const History = require('./lib/history')
const Label = require('./lib/label')
const AddFileOperation = require('./lib/operation/add_file_operation')
const MoveFileOperation = require('./lib/operation/move_file_operation')
const SetCommentStateOperation = require('./lib/operation/set_comment_state_operation')
const EditFileOperation = require('./lib/operation/edit_file_operation')
const EditNoOperation = require('./lib/operation/edit_no_operation')
const EditOperationTransformer = require('./lib/operation/edit_operation_transformer')
const SetFileMetadataOperation = require('./lib/operation/set_file_metadata_operation')
const NoOperation = require('./lib/operation/no_operation')
const Operation = require('./lib/operation')
const RestoreOrigin = require('./lib/origin/restore_origin')
const RestoreFileOrigin = require('./lib/origin/restore_file_origin')
const Origin = require('./lib/origin')
const { EDITOR_ORIGIN_KIND } = require('./lib/origin')
const EditorOrigin = require('./lib/origin/editor_origin')
const OtClient = require('./lib/ot_client')
const rebaseChanges = require('./lib/rebase')
const {
editorChangeIdentity,
editorChangeIdentityOf,
isSameEditorChange,
} = require('./lib/change_identity')
const TextOperation = require('./lib/operation/text_operation')
const EditOperation = require('./lib/operation/edit_operation')
const safePathname = require('./lib/safe_pathname')
const Snapshot = require('./lib/snapshot')
const {
DEFAULT_TEXT_EXTENSIONS,
DEFAULT_EDITABLE_FILENAMES,
} = require('./lib/text_file_defaults')
const util = require('./lib/util')
const V2DocVersions = require('./lib/v2_doc_versions')
const {
InsertOp,
RemoveOp,
RetainOp,
ScanOp,
} = require('./lib/operation/scan_op')
const TrackedChange = require('./lib/file_data/tracked_change')
const TrackedChangeList = require('./lib/file_data/tracked_change_list')
const TrackingProps = require('./lib/file_data/tracking_props')
const Range = require('./lib/range')
const CommentList = require('./lib/file_data/comment_list')
const LazyStringFileData = require('./lib/file_data/lazy_string_file_data')
const StringFileData = require('./lib/file_data/string_file_data')
const EditOperationBuilder = require('./lib/operation/edit_operation_builder')
const {
getDocUpdaterCompatibleRanges,
} = require('./lib/doc_updater_compatible_ranges')
exports.AddCommentOperation = AddCommentOperation
exports.Author = Author
exports.AuthorList = AuthorList
exports.Blob = Blob
exports.BlobStoreBase = BlobStoreBase
exports.Change = Change
exports.ChangeRequest = ChangeRequest
exports.ChangeNote = ChangeNote
exports.Chunk = Chunk
exports.ChunkResponse = ChunkResponse
exports.Comment = Comment
exports.DEFAULT_TEXT_EXTENSIONS = DEFAULT_TEXT_EXTENSIONS
exports.DEFAULT_EDITABLE_FILENAMES = DEFAULT_EDITABLE_FILENAMES
exports.DeleteCommentOperation = DeleteCommentOperation
exports.File = File
exports.FileMap = FileMap
exports.LazyStringFileData = LazyStringFileData
exports.StringFileData = StringFileData
exports.History = History
exports.Label = Label
exports.AddFileOperation = AddFileOperation
exports.MoveFileOperation = MoveFileOperation
exports.SetCommentStateOperation = SetCommentStateOperation
exports.EditFileOperation = EditFileOperation
exports.EditNoOperation = EditNoOperation
exports.EditOperationBuilder = EditOperationBuilder
exports.EditOperationTransformer = EditOperationTransformer
exports.SetFileMetadataOperation = SetFileMetadataOperation
exports.NoOperation = NoOperation
exports.Operation = Operation
exports.RestoreOrigin = RestoreOrigin
exports.RestoreFileOrigin = RestoreFileOrigin
exports.Origin = Origin
exports.EditorOrigin = EditorOrigin
exports.EDITOR_ORIGIN_KIND = EDITOR_ORIGIN_KIND
exports.OtClient = OtClient
exports.rebaseChanges = rebaseChanges
exports.editorChangeIdentity = editorChangeIdentity
exports.editorChangeIdentityOf = editorChangeIdentityOf
exports.isSameEditorChange = isSameEditorChange
exports.TextOperation = TextOperation
exports.EditOperation = EditOperation
exports.safePathname = safePathname
exports.Snapshot = Snapshot
exports.util = util
exports.V2DocVersions = V2DocVersions
exports.ScanOp = ScanOp
exports.InsertOp = InsertOp
exports.RetainOp = RetainOp
exports.RemoveOp = RemoveOp
exports.TrackedChangeList = TrackedChangeList
exports.TrackedChange = TrackedChange
exports.Range = Range
exports.CommentList = CommentList
exports.TrackingProps = TrackingProps
exports.getDocUpdaterCompatibleRanges = getDocUpdaterCompatibleRanges