CN117407359A - Version rollback method and device of collaborative document, electronic equipment and medium - Google Patents

Version rollback method and device of collaborative document, electronic equipment and medium Download PDF

Info

Publication number
CN117407359A
CN117407359A CN202311488962.1A CN202311488962A CN117407359A CN 117407359 A CN117407359 A CN 117407359A CN 202311488962 A CN202311488962 A CN 202311488962A CN 117407359 A CN117407359 A CN 117407359A
Authority
CN
China
Prior art keywords
version
collaborative document
rollback
document
operations
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311488962.1A
Other languages
Chinese (zh)
Inventor
陈春寒
何嘉昭
李云
劳学礼
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Digital Guangdong Network Construction Co Ltd
Original Assignee
Digital Guangdong Network Construction Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Digital Guangdong Network Construction Co Ltd filed Critical Digital Guangdong Network Construction Co Ltd
Priority to CN202311488962.1A priority Critical patent/CN117407359A/en
Publication of CN117407359A publication Critical patent/CN117407359A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/11File system administration, e.g. details of archiving or snapshots
    • G06F16/128Details of file system snapshots on the file-level, e.g. snapshot creation, administration, deletion
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1446Point-in-time backing up or restoration of persistent data
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/18File system types
    • G06F16/1873Versioning file systems, temporal file systems, e.g. file system supporting different historic versions of files
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

The application discloses a version rollback method, device, electronic equipment and storage medium of a collaborative document; the method comprises the following steps: if the current user needs to return the collaborative document from the second version to the first version, obtaining the collaborative document of the first version and the second version; updating the first version into the second version, and generating an update record in a rollback stack of a history manager corresponding to the collaborative document of the first version; respectively reversing all the insert operations and the delete operations in the rollback stack to obtain operations required by the second version to be rolled back to the first version; the operation is applied to the local document and synchronized to other users than the current user such that all users roll back the collaborative document from the second version to the first version. The method and the device can combine the snapshot mechanism with the history manager to jointly realize monotonically increasing version rollback, so that all users can be guaranteed to rollback together without conflict, and all data can be guaranteed not to be lost.

Description

Version rollback method and device of collaborative document, electronic equipment and medium
Technical Field
The embodiment of the application relates to the technical field of data storage, in particular to a method, a device, electronic equipment and a medium for version rollback of a collaborative document.
Background
Version rollback of collaborative documents refers to the process that when someone modifies a document during the process of editing the document together by multiple people, the other people can view and cancel the modification and restore to the previous version. Version rollback via snapshot (snapshot) is a common practice that may be used to restore the state of software, systems, or files to a previous point in time. The following is the step of implementing version rollback by snapshot: 1) Creating a snapshot: a snapshot is created before the version that needs rollback so that the current system or file state can be recorded. The snapshot may be created in different manners, such as a disk snapshot, a virtual machine snapshot, and so forth. 2) Rollback version: and selecting a snapshot point to be rolled back, and restoring the system or the file to the state recorded by the snapshot. 3) And (3) verification rollback: ensuring that the returned version is consistent with the desired version. It is checked whether the system, software or file functions properly to ensure that the rollback operation is successful. But there is currently no existing solution for implementing version rollback by snapshot, and in practice it has been found that implementing version rollback by snapshot may cause operation failure.
For example, the text content of the user a at the time point 1 to the time point 5 is: ABC, ABCX, ABCXY, ABCXY, ABCXY; the text contents of the user B at the time point 1 to the time point 5 are respectively: ABC, ABCY, ABCXY, ABC, ABCXY; the text contents of the user C at the time point 1 to the time point 5 are respectively: ABC, ABC, ABC, ABC, ABCXY. Wherein, time point 1: in the initial state, the user A, the user B and the user C complete synchronization with each other, and the text contents of the user A, the user B and the user C at the time point 1 are ABC. Time point 2: the user A and the user B respectively insert X and Y, and the text contents of the user A and the user B at the time point 2 are ABCX and ABCY respectively; at this point, user C suddenly goes offline, and the text content of user C at time point 2 remains ABC. Time point 3: the user A and the user B are synchronized, and the text content of the user A and the user B at the time point 3 is ABCXY; user C remains offline and the text content of user C at point in time 3 remains ABC. Time point 4: the state of the user B restored to the time point 1 through the snapshot is consistent with the state of the user C after temporary power failure. User C rolls back to the version at time point 1 through the snapshot, at which point user C also resumes the connection. Time point 5: user A, user B and user C are synchronized to a consistent state, and the text content of user A, user B and user C at time point 5 is ABCXY, which finally results in rollback failure. In order to rollback the versions of user a, user B, and user C together, a global counter may be maintained for each document by the server, indicating the latest rolled-back version of the current document. When a certain user is off line, before synchronization, whether the data of the local counter is consistent with the data of the server is required to be checked, if version rollback occurs, the data of the local counter is discarded, and the data of the server is directly used. In the networking state: all users need to receive the rollback notification of the server in real time, and the rollback of all users is guaranteed. This solution has the following drawbacks: 1) In real-time editing, the rollback may cause data loss that the user cannot synchronize. For example, the user a inserts a character after the character Y at the time point 5, and corresponds to an insert operation, and if the user returns to the version at the time point 1, the insert operation corresponds to an operation performed by the user after an absent position, and cannot be applied to the document. 2) For offline editing scenes, users expect to keep modifications after offline, and do not expect their own modifications to be discarded.
Disclosure of Invention
The application provides a version rollback method, device, electronic equipment and medium of collaborative documents, which combine a snapshot mechanism and a history manager to jointly realize monotonically increasing version rollback, so that all users can be guaranteed to rollback together without conflict, and all data can be guaranteed not to be lost.
In a first aspect, an embodiment of the present application provides a method for version rollback of a collaborative document, where the method includes:
if the current user needs to roll back the collaborative document from the second version to the first version, acquiring the collaborative document of the first version and the collaborative document of the second version through a snapshot mechanism;
updating the collaborative document of the first version into the collaborative document of the second version, and generating an update record in a rollback stack of a history manager corresponding to the collaborative document of the first version; the update record includes: all insert and delete operations of the collaborative document of the first version to the collaborative document of the second version;
inverting all the insert operations and the delete operations in the rollback stack respectively to obtain operations required by the second version to fall back to the first version;
And applying the operation required by the second version to be returned to the first version to a local document, and synchronizing the operation required by the second version to be returned to the first version to other users except the current user, so that all users return the collaborative document from the second version to the first version.
In a second aspect, an embodiment of the present application further provides a version rollback apparatus for a collaborative document, where the apparatus includes: the device comprises an acquisition module, an updating module, an inversion module and a rollback module; wherein,
the acquisition module is used for acquiring the collaborative document of the first version and the collaborative document of the second version through a snapshot mechanism if the current user needs to return the collaborative document from the second version to the first version;
the updating module is used for updating the collaborative document of the first version into the collaborative document of the second version and generating an updating record in a rollback stack of a history manager corresponding to the collaborative document of the first version; the update record includes: all insert and delete operations of the collaborative document of the first version to the collaborative document of the second version;
The inversion module is used for respectively inverting all the insertion operations and the deletion operations in the rollback stack to obtain operations required by the second version to fall back to the first version;
the rollback module is configured to apply an operation required by the second version to the first version to a local document, and synchronize the operation required by the second version to the first version to users other than the current user, so that all users rollback the collaborative document from the second version to the first version.
In a third aspect, an embodiment of the present application provides an electronic device, including:
one or more processors;
a memory for storing one or more programs,
the one or more programs, when executed by the one or more processors, cause the one or more processors to implement the version rollback method for collaborative documents described in any of the embodiments of the present application.
In a fourth aspect, embodiments of the present application provide a storage medium having stored thereon a computer program that, when executed by a processor, implements a version rollback method for collaborative documents according to any embodiments of the present application.
The embodiment of the application provides a method, a device, electronic equipment and a medium for version rollback of a collaborative document, wherein if a current user needs to rollback the collaborative document from a second version to a first version, the collaborative document of the first version and the collaborative document of the second version are acquired through a snapshot mechanism; then updating the collaborative document of the first version into the collaborative document of the second version, and generating an update record in a rollback stack of a history manager corresponding to the collaborative document of the first version; the update record includes: all insert operations and delete operations of the collaborative document of the first version to the collaborative document of the second version; then, respectively reversing all the insert operation and the delete operation in the rollback stack to obtain the operation required by the second version to be rolled back to the first version; and finally, applying the operation required by the second version to be returned to the first version to the local document, and synchronizing the operation required by the second version to be returned to the first version to other users except the current user, so that all users return the collaborative document from the second version to the first version. That is, in the technical solution of the present application, whether the collaborative document is updated from the first version to the second version or is rolled back from the second version to the first version, the operation thereof is monotonically increasing. In the prior art, the version rollback scheme based on the snapshot may cause data loss during version rollback, and if users are offline, it cannot be guaranteed that all users rollback together. Therefore, compared with the prior art, the version rollback method, the device, the electronic equipment and the medium of the collaborative document provided by the embodiment of the application combine a snapshot mechanism and a history manager to jointly realize monotonically increasing version rollback, so that all users can rollback together without conflict, and all data can be prevented from being lost; in addition, the technical scheme of the embodiment of the application is simple and convenient to realize, convenient to popularize and wider in application range.
Drawings
Fig. 1 is a schematic flow chart of a version rollback method of a collaborative document according to an embodiment of the present application;
FIG. 2 is a schematic diagram of a first flow for implementing version rollback by reverse operation according to an embodiment of the present application;
FIG. 3 is a schematic diagram of a second flow for implementing version rollback through inverse operations according to an embodiment of the present application;
fig. 4 is a second flow diagram of a version rollback method of a collaborative document according to an embodiment of the present application;
FIG. 5 is a schematic diagram of publishing and saving version snapshots provided by an embodiment of the present application;
fig. 6 is a third flow diagram of a version rollback method of a collaborative document according to an embodiment of the present application;
fig. 7 is a schematic diagram of a version rollback method of a collaborative document according to an embodiment of the present application;
fig. 8 is a schematic structural diagram of a version rollback device of a collaborative document according to an embodiment of the present application;
fig. 9 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
The present application is described in further detail below with reference to the drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the application and not limiting thereof. It should be further noted that, for convenience of description, only some, but not all of the structures related to the present application are shown in the drawings.
Example 1
Fig. 1 is a schematic flow chart of a version rollback method of a collaborative document according to an embodiment of the present application, where the method may be performed by a version rollback apparatus or an electronic device, and the apparatus or the electronic device may be implemented by software and/or hardware, and the apparatus or the electronic device may be integrated into any intelligent device having a network communication function. As shown in fig. 1, the version rollback method of the collaborative document may include the steps of:
s101, if the current user needs to roll back the collaborative document from the second version to the first version, acquiring the collaborative document of the first version and the collaborative document of the second version through a snapshot mechanism.
In this step, if the current user needs to rollback the collaborative document from the second version to the first version, the electronic device may obtain the collaborative document of the first version and the collaborative document of the second version through a snapshot mechanism. The snapshot mechanism is a technology of data backup and recovery, and can keep the original state of data while keeping the copy of the data. When the snapshot is made, the system records the state of the current data, creates a data snapshot file or data copy, and stores the data snapshot file or data copy in other positions. Such a snapshot may be used for data recovery when needed, and may be restored to the original state at the time the snapshot was created. The main advantage of the snapshot mechanism is fast recovery. By using snapshots, the time required for recovery can be reduced. Moreover, since the snapshot is performed in the background, the impact on system performance is also small.
S102, updating the collaborative document of the first version into the collaborative document of the second version, and generating an update record in a rollback stack of a history manager corresponding to the collaborative document of the first version; the update record includes: all insert and delete operations of the collaborative document of the first version to the collaborative document of the second version.
In the step, the electronic device can update the collaborative document of the first version to the collaborative document of the second version, and generate an update record in a rollback stack of a history manager corresponding to the collaborative document of the first version; the update record includes: all insert and delete operations of the collaborative document of the first version to the collaborative document of the second version. Specifically, updating the collaborative document of the first version to the collaborative document of the second version may operate as follows: 1) Creating a first version of the collaborative document: in the collaborative document platform or software, a new document is created as a basis for the first version. 2) Copying the second version of the content: all content in the second version of the collaborative document is selected and copied. 3) Paste into first version: switching to the first version of the collaborative document, pasting the copied content at a proper position and deleting the content deleted in the second version of the collaborative document in the first version of the collaborative document. 4) Item-by-item comparison and updating: in the second version of the document, the document contents of the first version are compared item by item, and necessary updates are made. 5) Review and modification: in the second version of the document, review and modification is performed to ensure accuracy, consistency and integrity of the document. 6) Saving and publishing the second version of the collaborative document: once satisfied with the second version of the collaborative document, the document is saved and published so that other collaborators can view and edit. It should be noted that the above operation steps may be completed by y.applyupdate, and the user is not required to actually open the first version of the collaborative document and the second version of the collaborative document.
S103, inverting all the inserting operation and the deleting operation respectively to obtain the operation required by the second version to be returned to the first version.
In this step, the electronic device may invert all the insert operations and the delete operations, respectively, to obtain operations required for the second version to fall back to the first version. Specifically, the operations in the embodiments of the present application include only two types: an insert operation and a delete operation; wherein the inverse of the insert operation is a delete operation; the inverse of the delete operation is an insert operation.
S104, the operation required by the second version to be returned to the first version is applied to the local document, and the operation required by the second version to be returned to the first version is synchronized to other users except the current user, so that all users return the collaborative document from the second version to the first version.
In this step, the electronic device may apply the operations required for the second version to be rolled back to the first version to the local document, and synchronize the operations required for the second version to be rolled back to the first version to other users than the current user, so that all users roll back the collaborative document from the second version to the first version. Specifically, the operations required to rollback the second version to the first version are applied to the local document, and the following method may be adopted: the first version of the collaborative document is passed to the y.encoditeataievapdate, an update data object is generated and then applied to the current document, where the current document refers to the document being edited by the online user, through the y.applyupdate. Further, the operations required for returning the second version to the first version are synchronized to other users than the current user, and the following method may be adopted: 1) Send message or notification: the message of the reverse operation is sent to other users by means of a message or a notification. 2) Data synchronization: if the application or system has a built-in data synchronization function, the data synchronization operation may be triggered immediately after the reverse operation occurs to ensure that other users acquire the latest data on their devices. 3) Updating in real time: if the application is using the real-time data update function, the reverse operation may be synchronized by sending real-time update events to the other user's devices. 4) Using a server: the reverse operation is sent to the server and the server is responsible for synchronizing it to other users. Other users may periodically poll the server to obtain up-to-date operations.
Fig. 2 is a schematic flow chart of implementing version rollback through inverse operation according to an embodiment of the present application. As shown in fig. 2, the initial state of the collaborative document is: ABC, the user C can delete C in the collaborative document in the initial state, and the state of the collaborative document of the user C is ABC-C; wherein the minus sign represents the inverse operation; the user A can add X in the collaborative document in the initial state to obtain the state of the collaborative document of the user A as ABCX; the user B can add Y in the collaborative version of the initial state to obtain the state of the collaborative document of the user B as ABCY; and then combining the state of the collaborative document of the user C, the state of the collaborative document of the user A and the state of the collaborative document of the user B to obtain the combined state of ABC-CXY and the combined content of ABXY. If the current version needs to be rolled back to the version in the initial state, the operation of deleting C, the operation of inserting X and the operation of inserting Y can be respectively inverted to obtain the operation of recovering C, the operation of deleting X and the operation of deleting Y, the operation of recovering C, the operation of deleting X and the operation of deleting Y are combined into the combined state, and the target state ABC-CCXY-Y-X is obtained, wherein the content after single call-back is ABC.
Fig. 3 is a schematic diagram of a second flow for implementing version rollback through inverse operation according to an embodiment of the present application. As shown in FIG. 3, the state of the collaborative document of user A is the latest state ABC-CCXY-Y-X, the state of the collaborative document of user B is ABC-CXY, the state of the collaborative document of user C is ABC, the state of the collaborative document of user A is the latest state, the state of the collaborative document of user B and the state of the collaborative document of user C are combined to obtain the combined state of ABC-CCXY-Y-X, and the combined content is ABC.
According to the version rollback method of the collaborative document, if a current user needs to rollback the collaborative document from the second version to the first version, the collaborative document of the first version and the collaborative document of the second version are acquired through a snapshot mechanism; then updating the collaborative document of the first version into the collaborative document of the second version, and generating an update record in a rollback stack of a history manager corresponding to the collaborative document of the first version; the update record includes: all insert operations and delete operations of the collaborative document of the first version to the collaborative document of the second version; then, respectively reversing all the insert operation and the delete operation in the rollback stack to obtain the operation required by the second version to be rolled back to the first version; and finally, applying the operation required by the second version to be returned to the first version to the local document, and synchronizing the operation required by the second version to be returned to the first version to other users except the current user, so that all users return the collaborative document from the second version to the first version. That is, in the technical solution of the present application, whether the collaborative document is updated from the first version to the second version or is rolled back from the second version to the first version, the operation thereof is monotonically increasing. In the prior art, the version rollback scheme based on the snapshot may cause data loss during version rollback, and if users are offline, it cannot be guaranteed that all users rollback together. Therefore, compared with the prior art, the version rollback method of the collaborative document provided by the embodiment of the application combines a snapshot mechanism and a history manager to jointly realize monotonically increasing version rollback, so that all users can be guaranteed to rollback together without conflict, and all data can be guaranteed not to be lost; in addition, the technical scheme of the embodiment of the application is simple and convenient to realize, convenient to popularize and wider in application range.
Example two
Fig. 4 is a second flowchart of a version rollback method of a collaborative document according to an embodiment of the present application. Further optimization and expansion based on the above technical solution can be combined with the above various alternative embodiments. As shown in fig. 4, the version rollback method of the collaborative document may include the steps of:
s401, if the current user needs to return the collaborative document from the second version to the first version, obtaining a snapshot of the collaborative document of the first version and a snapshot of the collaborative document of the second version through a snapshot mechanism.
S402, generating the collaborative document of the first version and the collaborative document of the second version according to the snapshot of the collaborative document of the first version and the snapshot of the collaborative document of the second version.
In this step, the electronic device may generate the first version of the collaborative document and the second version of the collaborative document according to the snapshot of the first version of the collaborative document and the snapshot of the second version of the collaborative document. For example, generating a first version of a collaborative document from a snapshot of the first version of the collaborative document may operate as follows: 1) A snapshot of the collaborative document of the first version is obtained. This may be a photograph of the document, a scanned piece, or a backup file that is saved in another form. 2) The snapshot file is opened using appropriate software or tools. 3) The content in the snapshot file is transferred to the editing tool. This may be done by direct copy and paste or by importing the snapshot file into an editing tool. 4) The necessary formatting of the content in the editing tool is performed. The layout may need to be rearranged, font style or size changed, titles, numbers or other elements added, etc., as desired. 5) Checking whether the document is accurate or not, and performing necessary editing and modification. Ensuring that the content, format and style of the document is consistent with the original snapshot file. 6) The generated first version of the collaborative document is saved and exported.
Fig. 5 is a schematic diagram of publishing and saving version snapshots according to an embodiment of the present application. As shown in fig. 5, the snapshot corresponding to the version a is a version snapshot a, and a user may edit in the version a, for example, the user may perform an inserting operation and a deleting operation in the version a, and then release the version to obtain a version B, and simultaneously save the snapshot to obtain a version snapshot B; the user may also edit in version B, for example, the user may perform an insert operation and a delete operation in version B, and then release the version to obtain version C, and save the snapshot to obtain version snapshot C.
S403, calling the Y.applyupdate through an application program interface API provided by the real-time collaboration library YJS.
In this step, the electronic device may call y.applyupdate through an application program interface API provided by YJS. The y.applyupdate is a function in the YJS library for applying external updates to the YJS document. In collaborative editing, multiple users may edit a document at the same time, and each user's operation will be transmitted to other users in an updated form. When one user receives updates for other users, the updates may be applied to the local document using the y.applyupdate function.
S404, updating the collaborative document of the first version into the collaborative document of the second version through the Y.application update, and generating an update record in a rollback stack of a history manager corresponding to the collaborative document of the first version; the update record includes: all insert and delete operations of the collaborative document of the first version to the collaborative document of the second version.
In the step, the electronic device can update the collaborative document of the first version into the collaborative document of the second version through the Y.application update, and an update record is generated in a history manager corresponding to the collaborative document of the first version; the update record includes: all insert and delete operations of the collaborative document of the first version to the collaborative document of the second version. Specifically, the electronic device updates the collaborative document of the first version to the collaborative document of the second version through the y.applyupdate, and the following method may be adopted: firstly, transmitting the collaboration document of the second version to Y.encodstateateAsupdate to generate an update data object; the first version of the collaborative document and the update data object are then passed to the y.applyupdate such that the y.applyupdate updates the first version of the collaborative document to the second version of the collaborative document based on the first version of the collaborative document and the update data object.
S405, inverting all the insert operations and the delete operations in the rollback stack respectively to obtain operations required by the second version to be rolled back to the first version.
In this step, the electronic device may first call, in the history manager corresponding to the collaborative document of the first version, a rollback operation of the history manager corresponding to the collaborative document of the first version; and then obtaining the operation required by the second version to fall back to the first version based on the fall-back operation of the history manager corresponding to the collaborative document of the first version.
S406, the operation required by the second version to be returned to the first version is applied to the local document, and the operation required by the second version to be returned to the first version is synchronized to other users except the current user, so that all users return the collaborative document from the second version to the first version.
According to the version rollback method of the collaborative document, if a current user needs to rollback the collaborative document from the second version to the first version, the collaborative document of the first version and the collaborative document of the second version are acquired through a snapshot mechanism; then updating the collaborative document of the first version into the collaborative document of the second version, and generating an update record in a rollback stack of a history manager corresponding to the collaborative document of the first version; the update record includes: all insert operations and delete operations of the collaborative document of the first version to the collaborative document of the second version; then, respectively reversing all the insert operation and the delete operation in the rollback stack to obtain the operation required by the second version to be rolled back to the first version; and finally, applying the operation required by the second version to be returned to the first version to the local document, and synchronizing the operation required by the second version to be returned to the first version to other users except the current user, so that all users return the collaborative document from the second version to the first version. That is, in the technical solution of the present application, whether the collaborative document is updated from the first version to the second version or is rolled back from the second version to the first version, the operation thereof is monotonically increasing. In the prior art, the version rollback scheme based on the snapshot may cause data loss during version rollback, and if users are offline, it cannot be guaranteed that all users rollback together. Therefore, compared with the prior art, the version rollback method of the collaborative document provided by the embodiment of the application combines a snapshot mechanism and a history manager to jointly realize monotonically increasing version rollback, so that all users can be guaranteed to rollback together without conflict, and all data can be guaranteed not to be lost; in addition, the technical scheme of the embodiment of the application is simple and convenient to realize, convenient to popularize and wider in application range.
Example III
Fig. 6 is a third flowchart combination of a version rollback method of a collaborative document according to an embodiment of the present application. As shown in fig. 6, the version rollback method of the collaborative document may include the steps of:
s601, if the current user needs to roll back the collaborative document from the second version to the first version, obtaining a snapshot of the collaborative document of the first version and a snapshot of the collaborative document of the second version through a snapshot mechanism.
S602, generating the collaborative document of the first version and the collaborative document of the second version according to the snapshot of the collaborative document of the first version and the snapshot of the collaborative document of the second version.
S603, calling Y.applyupdate through an application program interface API provided by the YJS, and updating the collaborative document of the first version into the collaborative document of the second version through the Y.applyupdate.
In this step, the electronic device may call y.applyupdate through the application program interface API provided by the real-time collaboration repository YJS, and update the collaborative document of the first version to the collaborative document of the second version through y.applyupdate.
S604, generating an update record in a rollback stack of a history manager corresponding to the collaborative document of the first version; the update record includes: all insert and delete operations of the collaborative document of the first version to the collaborative document of the second version.
In this step, the electronic device may generate an update record in a rollback stack of a history manager corresponding to the collaborative document of the first version. The history manager is a computer software or function for recording and storing a user's activity history in a computer system or web browser. The history manager typically records the user's activities in a time-sequential manner so that the user can review and search for their previous operations or accessed content. A rollback stack is a data structure that can be understood as a stack that stores operation histories, primarily for transactional rollback operations. When inserting or deleting data, these operations are recorded in the rollback stack in order. If an error occurs in the execution process of the transaction or the transaction is rolled back, the system can recover to the state before the transaction starts by traversing the rollback stack to cancel the operation which has been executed. Implementations of rollback typically use a last-in-first-out approach, i.e., the last operation performed will be revoked first. Before each transaction begins, the system creates a new rollback stack for storing the operations during execution of the transaction. If the transaction execution is successful, the operations in the rollback stack will be flushed and no rollback is required. When an error occurs or rollback is needed, the system can sequentially cancel the operations in the rollback stack, so that the data is returned to the state before the transaction begins. The roll-back stack is used to ensure consistency and integrity of the database. It provides a reliable way to handle cases of transaction failure or rollback, ensuring that database operations can be properly revoked, avoiding the propagation of erroneous effects into the database.
The embodiment of the application can use one rollback stack to save the insert operation and the delete operation; two rollback stacks may also be used to hold insert and delete operations, respectively. When performing the insert operation, the inserted element is stacked into the insert operation stack. When a delete operation is performed, the deleted element is stacked into the delete operation stack. When the rollback is needed, the latest operation is taken out from the operation stack, and corresponding operation is carried out according to the operation type. If the operation is the insert operation, the operation of deleting the element needs to be performed, and if the operation is the delete operation, the operation of inserting the element needs to be performed. Thus, the functions of saving the insert operation and the delete operation in the rollback stack can be realized.
S605, calling the rollback operation of the history manager corresponding to the collaborative document of the first version in the history manager corresponding to the collaborative document of the first version.
In this step, the electronic device may call, in the history manager corresponding to the collaborative document of the first version, a rollback operation of the history manager corresponding to the collaborative document of the first version. Specifically, the rollback operation of the history manager corresponding to the collaborative document of the first version is called, which may be performed according to the following steps: 1) And opening the collaborative document of the first version to ensure that the user has permission to modify and access the history. 2) And searching and opening a history manager corresponding to the collaborative document. This manager may be a specific function in the document editing tool or a separate history page. 3) In the history manager, all modified versions are found. These versions may be identified by date, time stamp, or the like. 4) Find a particular version that wants to roll back and then select the corresponding option to perform the roll back operation. In general, the option may be to rollback to the selected version or to set the selected version to the current version. 5) After the rollback operation is completed, modifications brought by rollback can be seen in the collaborative document.
S606, obtaining the operation required by the second version to fall back to the first version based on the fall-back operation of the history manager corresponding to the collaborative document of the first version.
In this step, the electronic device may obtain an operation required for the second version to fall back to the first version based on a rollback operation of the history manager corresponding to the collaborative document of the first version. Specifically, the electronic device may obtain, for all the insert operations, delete operations corresponding to all the insert operations in the rollback stack based on the first rollback operation of the history manager corresponding to the collaborative document of the first version; the first rollback operation is to invert all the insert operations in the rollback stack; aiming at all the deleting operations, obtaining inserting operations corresponding to all the deleting operations in the rollback stack based on the second rollback operation of the history manager corresponding to the collaborative document of the first version; the second rollback operation is to invert all deletion operations in the rollback stack; and taking the deletion operation corresponding to all the insertion operations in the rollback stack and the insertion operation corresponding to all the deletion operations as operations required by the second version to fall back to the first version.
S607, the operation required by the second version to be returned to the first version is applied to the local document, and the operation required by the second version to be returned to the first version is synchronized to other users except the current user, so that all users return the collaborative document from the second version to the first version.
Fig. 7 is a schematic diagram of a version rollback method of a collaborative document according to an embodiment of the present application. As shown in fig. 7, the collaborative document may be rolled back from version D to version B, from version B to version a, and from version a to version C. The initial state has A, B, C, D four versions, and if the version D needs to be rolled back to the version B, the reverse operations of the version C and the version D are respectively applied to the version D; if the version B needs to be rolled back to the version A, the reverse operation of the version B is applied to the version B; if it is desired to rollback version A to version C, then the operations of version B and version C are applied on version A, respectively.
According to the version rollback method of the collaborative document, if a current user needs to rollback the collaborative document from the second version to the first version, the collaborative document of the first version and the collaborative document of the second version are acquired through a snapshot mechanism; then updating the collaborative document of the first version into the collaborative document of the second version, and generating an update record in a rollback stack of a history manager corresponding to the collaborative document of the first version; the update record includes: all insert operations and delete operations of the collaborative document of the first version to the collaborative document of the second version; then, respectively reversing all the insert operation and the delete operation in the rollback stack to obtain the operation required by the second version to be rolled back to the first version; and finally, applying the operation required by the second version to be returned to the first version to the local document, and synchronizing the operation required by the second version to be returned to the first version to other users except the current user, so that all users return the collaborative document from the second version to the first version. That is, in the technical solution of the present application, whether the collaborative document is updated from the first version to the second version or is rolled back from the second version to the first version, the operation thereof is monotonically increasing. In the prior art, the version rollback scheme based on the snapshot may cause data loss during version rollback, and if users are offline, it cannot be guaranteed that all users rollback together. Therefore, compared with the prior art, the version rollback method of the collaborative document provided by the embodiment of the application combines a snapshot mechanism and a history manager to jointly realize monotonically increasing version rollback, so that all users can be guaranteed to rollback together without conflict, and all data can be guaranteed not to be lost; in addition, the technical scheme of the embodiment of the application is simple and convenient to realize, convenient to popularize and wider in application range.
Example IV
Fig. 8 is a schematic structural diagram of a version rollback device for collaborative documents according to an embodiment of the present application. As shown in fig. 8, the version rollback apparatus 800 of the collaborative document includes: an acquisition module 801, an update module 802, an inversion module 803, and a rollback module 804; wherein,
the obtaining module 801 is configured to obtain, if the current user needs to rollback the collaborative document from the second version to the first version, the collaborative document of the first version and the collaborative document of the second version through a snapshot mechanism;
the updating module 802 is configured to update the collaborative document of the first version to the collaborative document of the second version, and generate an update record in a rollback stack of a history manager corresponding to the collaborative document of the first version; the update record includes: all insert and delete operations of the collaborative document of the first version to the collaborative document of the second version;
the inversion module 803 is configured to invert all the insert operations and delete operations in the rollback stack respectively, so as to obtain operations required by the second version to fall back to the first version;
the rollback module 804 is configured to apply an operation required for the second version to be rolled back to the first version to a local document, and synchronize the operation required for the second version to be rolled back to the first version to a user other than the current user, so that all users rollback the collaborative document from the second version to the first version.
The version rollback device can execute the method provided by any embodiment of the application, and has the corresponding functional modules and beneficial effects of the execution method. Technical details not described in detail in this embodiment may refer to the version rollback method of the collaborative document provided in any embodiment of the present application.
Example five
Fig. 9 is a schematic structural diagram of an electronic device according to an embodiment of the present application. Fig. 9 illustrates a block diagram of an exemplary electronic device suitable for use in implementing embodiments of the present application. The electronic device 12 shown in fig. 9 is merely an example and should not be construed as limiting the functionality and scope of use of the embodiments herein.
As shown in fig. 9, the electronic device 12 is in the form of a general purpose computing device. Components of the electronic device 12 may include, but are not limited to: one or more processors or processing units 16, a system memory 28, a bus 18 that connects the various system components, including the system memory 28 and the processing units 16.
Bus 18 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor, and a local bus using any of a variety of bus architectures. By way of example, and not limitation, such architectures include Industry Standard Architecture (ISA) bus, micro channel architecture (MAC) bus, enhanced ISA bus, video Electronics Standards Association (VESA) local bus, and Peripheral Component Interconnect (PCI) bus.
Electronic device 12 typically includes a variety of computer system readable media. Such media can be any available media that is accessible by electronic device 12 and includes both volatile and nonvolatile media, removable and non-removable media.
The system memory 28 may include computer system readable media in the form of volatile memory, such as Random Access Memory (RAM) 30 and/or cache memory 32. The electronic device 12 may further include other removable/non-removable, volatile/nonvolatile computer system storage media. By way of example only, storage system 34 may be used to read from or write to non-removable, nonvolatile magnetic media (not shown in FIG. 9, commonly referred to as a "hard disk drive"). Although not shown in fig. 9, a magnetic disk drive for reading from and writing to a removable non-volatile magnetic disk (e.g., a "floppy disk"), and an optical disk drive for reading from or writing to a removable non-volatile optical disk (e.g., a CD-ROM, DVD-ROM, or other optical media) may be provided. In such cases, each drive may be coupled to bus 18 through one or more data medium interfaces. Memory 28 may include at least one program product having a set (e.g., at least one) of program modules configured to carry out the functions of the embodiments of the present application.
A program/utility 40 having a set (at least one) of program modules 42 may be stored in, for example, memory 28, such program modules 42 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each or some combination of which may include an implementation of a network environment. Program modules 42 generally perform the functions and/or methods in the embodiments described herein.
The electronic device 12 may also communicate with one or more external devices 14 (e.g., keyboard, pointing device, display 24, etc.), one or more devices that enable a user to interact with the electronic device 12, and/or any devices (e.g., network card, modem, etc.) that enable the electronic device 12 to communicate with one or more other computing devices. Such communication may occur through an input/output (I/O) interface 22. Also, the electronic device 12 may communicate with one or more networks such as a Local Area Network (LAN), a Wide Area Network (WAN) and/or a public network, such as the Internet, through a network adapter 20. As shown, the network adapter 20 communicates with other modules of the electronic device 12 over the bus 18. It should be appreciated that although not shown in fig. 9, other hardware and/or software modules may be used in connection with electronic device 12, including, but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, data backup storage systems, and the like.
The processing unit 16 executes various functional applications and data processing by running programs stored in the system memory 28, for example, implementing a version rollback method of a collaborative document provided by an embodiment of the present application.
Example six
Embodiments of the present application provide a computer storage medium.
Any combination of one or more computer readable media may be employed in the computer readable storage media of the embodiments herein. The computer readable medium may be a computer readable signal medium or a computer readable storage medium. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples (a non-exhaustive list) of the computer-readable storage medium would include the following: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
The computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, either in baseband or as part of a carrier wave. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
Computer program code for carrying out operations of the present application may be written in one or more programming languages, including an object oriented programming language such as Java, smalltalk, C ++ and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computer (for example, through the Internet using an Internet service provider).
Note that the above is only a preferred embodiment of the present application and the technical principle applied. Those skilled in the art will appreciate that the present application is not limited to the particular embodiments described herein, but is capable of numerous obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the present application. Therefore, while the present application has been described in connection with the above embodiments, the present application is not limited to the above embodiments, but may include many other equivalent embodiments without departing from the spirit of the present application, the scope of which is defined by the scope of the appended claims.

Claims (9)

1. A method for version rollback of a collaborative document, the method comprising:
if the current user needs to roll back the collaborative document from the second version to the first version, acquiring the collaborative document of the first version and the collaborative document of the second version through a snapshot mechanism;
updating the collaborative document of the first version into the collaborative document of the second version, and generating an update record in a rollback stack of a history manager corresponding to the collaborative document of the first version; the update record includes: all insert and delete operations of the collaborative document of the first version to the collaborative document of the second version;
Inverting all the insert operations and the delete operations in the rollback stack respectively to obtain operations required by the second version to fall back to the first version;
and applying the operation required by the second version to be returned to the first version to a local document, and synchronizing the operation required by the second version to be returned to the first version to other users except the current user, so that all users return the collaborative document from the second version to the first version.
2. The method of claim 1, wherein obtaining the first version of the collaborative document and the second version of the collaborative document via a snapshot mechanism comprises:
obtaining a snapshot of the collaborative document of the first version and a snapshot of the collaborative document of the second version through a snapshot mechanism;
and generating the collaborative document of the first version and the collaborative document of the second version according to the snapshot of the collaborative document of the first version and the snapshot of the collaborative document of the second version.
3. The method of claim 1, wherein updating the first version of the collaborative document to the second version of the collaborative document comprises:
The method comprises the steps of calling Y.applyupdate through an application program interface API provided by a real-time collaboration library YJS;
and updating the collaborative document of the first version into the collaborative document of the second version through the Y.application update.
4. A method according to claim 3, wherein updating the collaborative document of the first version to the collaborative document of the second version by y.applyupdate comprises:
transmitting the collaboration document of the second version to Y.encodstateateAsupdate to generate an update data object;
and transmitting the first version of collaborative document and the update data object to Y.applyupdate, so that the Y.applyupdate updates the first version of collaborative document to the second version of collaborative document based on the first version of collaborative document and the update data object.
5. The method of claim 1, wherein inverting all insert operations and delete operations in the rollback stack, respectively, results in operations required for the second version to rollback to the first version, comprising:
calling the rollback operation of the history manager corresponding to the collaborative document of the first version in the history manager corresponding to the collaborative document of the first version;
And obtaining the operation required by the second version to fall back to the first version based on the fall-back operation of the history manager corresponding to the collaborative document of the first version.
6. The method of claim 5, wherein deriving the operation required for the second version to rollback to the first version based on a rollback operation of a history manager corresponding to the collaborative document of the first version comprises:
aiming at all the insertion operations, obtaining deletion operations corresponding to all the insertion operations in the rollback stack based on the first rollback operation of the history manager corresponding to the collaborative document of the first version; wherein the first rollback operation is to invert all insert operations in the rollback stack;
aiming at all the deleting operations, obtaining inserting operations corresponding to all the deleting operations in the rollback stack based on the second rollback operation of the history manager corresponding to the collaborative document of the first version; wherein the second rollback operation is to invert all delete operations in the rollback stack;
and taking the deletion operation corresponding to all the insertion operations in the rollback stack and the insertion operation corresponding to all the deletion operations as operations required by the second version to fall back to the first version.
7. A version rollback apparatus for collaborative documents, the apparatus comprising: the device comprises an acquisition module, an updating module, an inversion module and a rollback module; wherein,
the acquisition module is used for acquiring the collaborative document of the first version and the collaborative document of the second version through a snapshot mechanism if the current user needs to return the collaborative document from the second version to the first version;
the updating module is used for updating the collaborative document of the first version into the collaborative document of the second version and generating an updating record in a rollback stack of a history manager corresponding to the collaborative document of the first version; the update record includes: all insert and delete operations of the collaborative document of the first version to the collaborative document of the second version;
the inversion module is used for respectively inverting all the insertion operations and the deletion operations in the rollback stack to obtain operations required by the second version to fall back to the first version;
the rollback module is configured to apply an operation required by the second version to the first version to a local document, and synchronize the operation required by the second version to the first version to users other than the current user, so that all users rollback the collaborative document from the second version to the first version.
8. An electronic device, comprising:
one or more processors;
a memory for storing one or more programs,
the one or more programs, when executed by the one or more processors, cause the one or more processors to implement the version rollback method of a collaborative document of any of claims 1-6.
9. A storage medium having stored thereon a computer program, which when executed by a processor implements a version rollback method of a collaborative document according to any of claims 1 to 6.
CN202311488962.1A 2023-11-09 2023-11-09 Version rollback method and device of collaborative document, electronic equipment and medium Pending CN117407359A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311488962.1A CN117407359A (en) 2023-11-09 2023-11-09 Version rollback method and device of collaborative document, electronic equipment and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311488962.1A CN117407359A (en) 2023-11-09 2023-11-09 Version rollback method and device of collaborative document, electronic equipment and medium

Publications (1)

Publication Number Publication Date
CN117407359A true CN117407359A (en) 2024-01-16

Family

ID=89496088

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311488962.1A Pending CN117407359A (en) 2023-11-09 2023-11-09 Version rollback method and device of collaborative document, electronic equipment and medium

Country Status (1)

Country Link
CN (1) CN117407359A (en)

Similar Documents

Publication Publication Date Title
KR101137101B1 (en) Cross-pollination of multiple sync sources
CA2933790C (en) Apparatus and method for creating a real time database replica
US8250033B1 (en) Replication of a data set using differential snapshots
CN110309218B (en) Data exchange system and data writing method
US8595381B2 (en) Hierarchical file synchronization method, software and devices
CN113396407A (en) System and method for augmenting database applications using blockchain techniques
CN105574187B (en) A kind of Heterogeneous Database Replication transaction consistency support method and system
CN106462631B (en) Consistent view of partitioned data in a final consistent system
EP1706822B1 (en) Maintaining consistency for remote copy using virtualization
US20040163029A1 (en) Data recovery techniques in storage systems
US20130179405A1 (en) Systems and methods for creating copies of data, such as archive copies
CN109542682B (en) Data backup method, device, equipment and storage medium
KR20070058281A (en) System and method for a consistency check of a database backup
US20200104404A1 (en) Seamless migration of distributed systems
CN102272751A (en) Data integrity in a database environment through background synchronization
US7194486B2 (en) Method and system for data processing with data replication for the same
CN104463014B (en) A kind of oracle database guard method based on snapshot
CN113377763B (en) Database table switching method and device, electronic equipment and computer storage medium
JP3042600B2 (en) Distributed file synchronization method
JP4512386B2 (en) Backup system and method
CN117407359A (en) Version rollback method and device of collaborative document, electronic equipment and medium
CN112181248B (en) Operation method and device of history list
JP2002318717A (en) Database system
US20080059538A1 (en) Method and system for synchronizing offline records
JP2002222107A (en) Data synchronizing device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination