A file editing method and device
By receiving user editing instructions and merging the latest version of the files in the server, the data coverage problem during multiple edits by multiple people in the B-side interactive film and television background is solved, reducing development complexity and resource utilization.
Patent Information
- Application Number
- CN201910906389.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-09-24
- Publication Date
- 2024-12-20
- Estimated Expiration
- 2039-12-05
AI Technical Summary
When multiple people edit videos at the same time, the data update interface is scattered, the workload is huge, and the update logic is complex, resulting in data coverage problems.
By receiving user editing instructions, a second file is generated, and before publishing to the server, determine whether there is the latest version of the first file in the server. If so, merge to generate the edited file to publish it to avoid direct forwarding and resource occupation.
It reduces the development workload of the data layer, realizes centralized version management, and avoids file overwriting when multiple people edit.
Smart Images

Figure CN112632016B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of network technology, and in particular to a file editing method and device. Background Art
[0002] With the development of network technology, people can also edit movies and TV online through the Internet, which is interactive movies and TV. Interactive movies and TV are divided into C-end, C-end backend and B-end. B-end is the management backend provided by interactive movies and TV to creators for online editing of interactive videos. The final edited and produced data may fall into the database; C-end is the interactive video client contacted by ordinary users; C-end backend provides server services to C-end, and its data source is the database that B-end finally lands on.
[0003] At present, the B-side needs to provide a variety of operations to improve the creator's experience, such as (1) each video clip can be dragged, and their positions need to be saved; (2) video clips can be added / deleted, and need to be saved immediately; (3) jumps between video clips can also be added / deleted, and need to be saved immediately; (4) the UI and sound effects of jumps between video clips can also be edited by users, and need to be saved immediately; (5) support for multiple people to edit the same interactive drama at the same time. The above operations make the B-side functions very complicated, and traditional development ideas will have many problems in solving this problem, such as scattered data update interfaces, huge workload, and complex update data forwarding logic. Summary of the invention
[0004] One purpose of the present application is to propose a file editing method and device, which at least to a certain extent reduces the development workload of the data layer, implements a centralized version management mechanism for the data layer, and ensures that edited files submitted by multiple people will not overwrite each other.
[0005] According to one aspect of an embodiment of the present application, a file editing method is applied, the method comprising:
[0006] Receiving an editing instruction for a first file input by a user, and generating a second file according to the first file and the editing instruction;
[0007] Before publishing the second file to the server, determining whether a third file can be obtained from the server, the third file being the latest version of the first file stored in the server;
[0008] If the third file can be obtained from the server, generating an edited file according to the second file and the third file;
[0009] The edited file is published to the server.
[0010] According to one aspect of an embodiment of the present application, a file editing device is applied for, comprising:
[0011] A receiving module, configured to receive an editing instruction for a first file input by a user, and generate a second file according to the first file and the editing instruction;
[0012] A determination module, used for determining whether a third file can be obtained from the server before publishing the second file to the server, wherein the third file is the latest version of the first file stored in the server;
[0013] a generating module, configured to generate an edited file according to the second file and the third file if the third file can be obtained from the server;
[0014] A publishing module is used to publish the edited file to the server.
[0015] In one embodiment, the determining module includes:
[0016] a first acquisition unit, configured to determine, according to the identification number of the first file, whether a file having an identification number greater than the identification number of the first file can be acquired from the server;
[0017] A processing unit is configured to determine that the third file can be obtained from the server if a file with an identification number greater than the identification number of the first file can be obtained from the server.
[0018] In one embodiment, the receiving module includes:
[0019] a copying unit, configured to copy the first file to obtain a copy of the first file, and generate a second file according to the first file and the editing instruction;
[0020] The device is also used for:
[0021] storing an identification number of the copy of the first file to determine the identification number of the first file based on the stored identification number of the copy of the first file;
[0022] It is determined whether a third file exists according to the identification number of the copy of the first file, the identification number of the third file being greater than the identification number of the copy of the first file.
[0023] In one embodiment, the generating module comprises:
[0024] A second acquisition unit, used to respectively acquire the fields included in the second file and the fields included in the third file;
[0025] The merging unit is used to merge the fields included in the second file and the fields included in the third file to generate an edited file.
[0026] In one embodiment, the field includes a field identifier and a field value, and the merging unit is used to:
[0027] Calculating a union of the field identifiers included in the second file and the field identifiers included in the third file to obtain a field identifier set;
[0028] According to the field values included in the second file and the field values included in the third file, obtaining the field value corresponding to each field identifier in the field identifier set;
[0029] The edited file is obtained according to the field identification set and the field value corresponding to each field identification in the field identification set.
[0030] In one embodiment, acquiring the field value corresponding to each field identifier in the field identifier set according to the field value included in the second file and the field value included in the third file includes:
[0031] For a first type of field identifier included in the field identifier set and having a corresponding field value in the second file but not in the third file, setting the field value of the first type of field identifier to the corresponding field value in the second file;
[0032] For the second type of field identifiers included in the field identifier set and having corresponding field values in the third file but not in the second file, setting the field values of the second type of field identifiers to the corresponding field values in the third file;
[0033] For the third type of field identifiers included in the field identifier set and having corresponding field values in both the second file and the third file, and the corresponding field values are different, the field value of the third type of field identifier is set to the corresponding field value in the second file.
[0034] In one embodiment, the apparatus further comprises:
[0035] The updating module is used to obtain an updated first file according to the fourth file and the first file if a fourth file is received from the server before receiving the editing instruction of the first file input by the user, wherein the fourth file is an updated version of the first file.
[0036] In one embodiment, the receiving module is further configured to:
[0037] An editing instruction for the updated first file input by a user is received, and a second file is generated according to the updated first file and the editing instruction.
[0038] In one embodiment, the update module is used to:
[0039] Respectively obtaining the fields included in the first file and the fields included in the fourth file;
[0040] Calculating a union of the field identifiers included in the first file and the field identifiers included in the fourth file to obtain a field identifier set;
[0041] According to the field values included in the first file and the field values included in the fourth file, obtaining the field value corresponding to each field identifier in the field identifier set;
[0042] An updated first file is obtained according to the field identifier set and the field value corresponding to each field identifier in the field identifier set.
[0043] According to one aspect of the embodiments of the present application, an electronic device is applied for, including:
[0044] one or more processors;
[0045] A storage device, used to store one or more programs, when the one or more programs are executed by the one or more processors, enables the one or more processors to implement the file editing method mentioned in the above-mentioned first aspect or any possible implementation of the above-mentioned first aspect.
[0046] According to one aspect of an embodiment of the present application, a computer program medium is applied for, on which computer-readable instructions are stored. When the computer-readable instructions are executed by a processor of a computer, the computer executes the method as described above.
[0047] The technical solution provided by the embodiment of the present application may include the following beneficial effects: the technical solution provided by the present application generates a second file by receiving the user's edits to the first file, and before publishing the second file to the server, determines whether a third file stored in the server can be obtained from the server, the third file being the latest version of the first file stored in the server, and if the third file can be obtained, an edited file is generated based on the second file and the third file, and the edited file is published to the server. This makes it unnecessary to forward all edited files to the server for processing when multiple people are editing, thus avoiding complex forwarding logic and occupying server resources, and directly obtaining the latest version of the file from the server, generating the edited file based on the latest version of the file and the second file, and ensuring that the edited files submitted separately when multiple people are editing the file will not overwrite each other.
[0048] Other features and advantages of the present application will become apparent from the following detailed description, or may be learned in part by the practice of the present application.
[0049] It should be understood that the foregoing general description and the following detailed description are exemplary only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] The accompanying drawings herein are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the present invention, and together with the specification are used to explain the principles of the present invention. Obviously, the accompanying drawings described below are only some embodiments of the present invention, and for those of ordinary skill in the art, other accompanying drawings can be obtained based on these accompanying drawings without creative work.
[0051] In the attached picture:
[0052] Figure 1 A system architecture diagram of a file editing method application according to an embodiment of the present application is shown.
[0053] Figure 2 A flowchart of a file editing method according to an embodiment of the present application is shown.
[0054] Figure 3 A flowchart of determining whether a third file can be obtained from a server according to an embodiment of the present application is shown.
[0055] Figure 4 A flowchart of a file editing method according to another embodiment of the present application is shown.
[0056] Figure 5 A detailed flowchart of step S230 according to an embodiment of the present application is shown.
[0057] Figure 6 A detailed flowchart of step S2302 according to an embodiment of the present application is shown.
[0058] Figure 7 A flowchart of obtaining an updated first file based on a fourth file and a first file according to an embodiment of the present application is shown.
[0059] Figure 8 An interactive flow chart of an application scenario of an interactive video in which a file editing method according to an embodiment of the present application is applied is shown.
[0060] Fig. 9 A block diagram of a file editing device according to an embodiment of the present application is shown.
[0061] Fig.10A schematic diagram of the structure of a computer system of an electronic device according to an embodiment of the present application is shown. DETAILED DESCRIPTION
[0062] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in a variety of forms and should not be construed as limited to the examples set forth herein; rather, these example embodiments are provided so that the description of the present application will be more comprehensive and complete and the concepts of the example embodiments will be fully conveyed to those skilled in the art. The accompanying drawings are only schematic illustrations of the present application and are not necessarily drawn to scale. The same reference numerals in the figures represent the same or similar parts, and thus their repeated description will be omitted.
[0063] In addition, the described features, structures or characteristics may be combined in one or more example embodiments in any suitable manner. In the following description, many specific details are provided to provide a full understanding of the example embodiments of the present application. However, those skilled in the art will appreciate that the technical solution of the present application may be practiced while omitting one or more of the specific details, or other methods, components, steps, etc. may be adopted. In other cases, known structures, methods, implementations or operations are not shown or described in detail to avoid obscuring the present application and making the various aspects of the present application obscure.
[0064] Some of the blocks shown in the accompanying drawings are functional entities that do not necessarily correspond to physically or logically independent entities. These functional entities can be implemented in software form, or in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.
[0065] Please refer to the following Figure 1 Describe the system architecture used by the file editing method of the embodiment of the present application.
[0066] like Figure 1 As shown, the architecture 100 may include one or more of terminal devices 101, 102, 103, a network 104, and a server 105. The network 104 is used to provide a medium for communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc. The terminal devices 101, 102, 103 may be various electronic devices with display screens, including but not limited to desktop computers, portable computers, smart phones, tablet computers, etc. It should be understood that Figure 1The number of terminal devices, networks and servers in the embodiment is only for illustration. According to the implementation requirements, there may be any number of terminal devices, networks and servers. For example, the server 105 may be a server cluster composed of multiple servers.
[0067] The file editing method provided in the embodiment of the present disclosure is generally executed by the terminal devices 101, 102, and 103, and accordingly, the file editing device is generally disposed in the terminal devices 101, 102, and 103. However, it is easy for those skilled in the art to understand that the file editing method provided in the embodiment of the present disclosure can also be executed by the server 105, and accordingly, the file editing device can also be disposed in the server 105, which is not particularly limited in the present exemplary embodiment.
[0068] In an embodiment of the present invention, users logged in on terminal devices 101, 102, and 103 may be accessing a file in server 105 at the same time. Terminal devices 101, 102, and 103 may respectively send editing information of a file by the users logged in on the terminal devices to server 105. Server 105 may process the editing information and store or send the processed editing information to the terminals of other users accessing the file.
[0069] For example, the file is a video file, and multiple users can access the video file. The video file can be stored on the server 105. The terminal devices 101, 102, and 103 where the multiple users are located can access the video file in the server 105 through a network connection, and the multiple users can edit the video file at the same time. The multiple terminal devices 101, 102, and 103 can send editing information to the server 105, and the server 105 can process the editing information sent by one terminal and send it to other terminals. For example, after the terminal device 101 edits the video file, it can send the editing information to the server 105, and the server 105 can process the editing information sent by the terminal device 101 and send it to other terminal devices 102 and 103, thereby realizing data synchronization in the video file.
[0070] It should be noted that the multiple terminal devices 101, 102, 103 can access the server 105 through the installed client, and can also access the server 105 through a portal website, which is not limited in the embodiment of the present invention.
[0071] The file editing method is applied to a terminal, which can be one of the multiple terminal devices 101, 102, and 103. The following description is based on the example of a user currently logged in on a terminal device. In the embodiment of the present invention, multiple users can edit the same file at the same time, wherein, for a certain terminal, the user logged in on the terminal is accessing a file, and the users logged in on other terminals are also accessing the file and editing the file area.
[0072] When any user accesses a file, the terminal can establish a connection with the server. Specifically, the terminal can call the socket.io library to establish a socket channel with the server. The socket channel is used for full-duplex communication with the server. The name of the socket.io library is briefly explained below. The Chinese name of the socket in the name is "socket", and the full English name of io is "Input Output", which means input and output.
[0073] In one possible implementation, for a file, the server can store the corresponding relationship between the socket communication handles of all users accessing the file and the file. For example, the server can store the socket communication handles of all users accessing the file in a hash map (HashMap) object. The HashMap object usually stores data in the form of key-value pairs. Specifically, the identification information of the file can be used as a key in the HashMap object, and the identification information is used to uniquely identify the file. For example, the identity identification number (Identification, ID) of the file can be used as a key. Whenever a user sends editing information to the server, the server can obtain the socket communication handles of all users who are accessing the file based on the identification information of the file, and then process the editing information, and send the processed editing information to all users through the socket communication handles of all users obtained. The above-mentioned server can be called a broadcast for receiving and sending the editing information. If multiple users collaborate to edit the same file, the editing information can also be called collaborative information.
[0074] In a specific embodiment, a user in a terminal device obtains a first file from a server, inputs an editing instruction for the first file, and obtains a second file based on the first file and the editing instruction. Before publishing the second file to the server, the terminal device needs to determine whether a third file can be obtained from the server, where the third file is the latest version of the first file stored in the server. If the third file can be obtained from the server, an edited file is generated based on the second file and the third file; and the edited file is published to the server.
[0075] In a specific embodiment, after receiving the first file, the terminal device can copy the first file to obtain a copy of the first file, receive editing instructions input by the user for the first file, obtain the second file, and store the identification number of the copy of the first file, and determine whether a file with an identification number greater than the identification number of the first file can be obtained from the server based on the identification number of the copy of the first file. If a file with an identification number greater than the identification number of the first file can be obtained, it is determined that the third file can be obtained from the server.
[0076] Below through Figure 2 The embodiment shown illustrates the specific process of the file editing method, see Figure 2 , the file editing method may include the following steps:
[0077] Step S210: receiving an editing instruction for a first file input by a user, and generating a second file according to the first file and the editing instruction;
[0078] Step S220: Before publishing the second file to the server, determine whether a third file can be obtained from the server, where the third file is the latest version of the first file stored in the server;
[0079] Step S230: if the third file can be obtained from the server, generating an edited file according to the second file and the third file;
[0080] Step S240: publishing the edited file to the server.
[0081] These steps are described in detail below.
[0082] Step S210: receiving an editing instruction for a first file input by a user, and generating a second file according to the first file and the editing instruction.
[0083] In an embodiment of the present invention, the first file is a target file for editing by a user logged in on a terminal device. The first file may be an online shared file or may be stored locally on the user's terminal. However, based on shared software, other users' terminals may also edit the first file. Of course, the first file may also be stored locally on other users' terminals. However, based on shared software, the user's terminal may also edit the first file.
[0084] The editing instruction may be generated by the user by triggering an input module of the terminal device, and the input module may be a touch screen, a mouse, a keyboard, etc., which is not specifically limited here.
[0085] Understandably, the user can input editing instructions through the mouse, keyboard, etc. according to the needs, the processor can receive the input editing instructions, and then perform corresponding operations according to the editing instructions. Among them, the editing instructions include but are not limited to the first instruction for table nesting, the second instruction for element grouping, the third instruction for loading waiting animation, the fourth instruction for container quantity change, the fifth instruction for element fixation, the sixth instruction for element movement, the seventh instruction for element information change, the eighth instruction for element layout switching, etc. For example, if the user needs to perform a table nesting operation on the web page, the first instruction can be input through the mouse, keyboard, etc.
[0086] The second file is a file obtained by performing an editing operation on the first file. When an editing instruction is received, the first file is edited to obtain the second file.
[0087] Step S220: Before publishing the second file to the server, determine whether a third file can be obtained from the server, where the third file is the latest version of the first file stored in the server.
[0088] The third file is the latest version of the first file stored in the server. It can be a file edited by users of other terminal devices and sent to the server. After the server receives the file sent by other terminal devices, it can store the received file or broadcast the received file to the terminals of other users who are accessing the file.
[0089] In step S210, after the user edits the first file to obtain the second file, the terminal where the user is located will send the second file to the server. However, before sending the second file, the terminal will first send a request to obtain the latest version of the file to the server to determine whether the latest version of the first file can be obtained from the server.
[0090] Step S230: If the third file can be obtained from the server, generate an edited file according to the second file and the third file.
[0091] In step S230, if the terminal device can obtain the third file from the server, it means that the first file edited by the user is not the latest file. Therefore, the terminal device will not directly publish the second file edited in step S210 to the server, but will generate the edited file based on the latest third file and the second file obtained.
[0092] Step S240: publishing the edited file to the server.
[0093] In this embodiment, the second file is generated by receiving the user's edits to the first file. Before publishing the second file to the server, it is determined whether the third file stored in the server can be obtained from the server. The third file is the latest version of the first file stored in the server. If the third file can be obtained, the edited file is generated based on the second file and the third file, and the edited file is published to the server. In this way, when multiple people edit, it is not necessary to forward all edited files to the server for processing, avoiding complex forwarding logic and occupying server resources. In addition, the latest version of the file is directly obtained from the server, and the edited file is generated based on the latest version of the file and the second file, ensuring that the edited files submitted separately will not overwrite each other when multiple people edit the file.
[0094] In one embodiment, the determination of whether the third file can be obtained from the server in step S220 may be determined by calculating and comparing hash values of the first file and the third file.
[0095] In another embodiment, whether the third file can be obtained from the server in step S220 can also be determined directly by comparing the identification numbers of the first file and the third file, such as Figure 3 As shown, determining whether the third file can be obtained from the server includes the following steps:
[0096] Step S310: determining, according to the identification number of the first file, whether a file having an identification number greater than the identification number of the first file can be obtained from the server;
[0097] Step S320: If a file with an identification number greater than the identification number of the first file can be obtained from the server, it is determined that the third file can be obtained from the server.
[0098] In step S310, the identification number refers to a number that can be used to identify the file version, and can be composed of characters such as letters, symbols, and numbers. The method of determining whether a file with an identification number greater than the identification number of the first file can be obtained from the server can be that the terminal device sends a request to the server, and the request carries the identification number of the first file, or after the terminal device obtains the file, the file identification number is compared locally on the terminal device.
[0099] In step S320, after receiving the request, the server obtains a file with an identification number greater than the identification number of the first file according to the identification number of the received first file, and then sends it to the terminal device. If the identification number of the obtained file is greater than the identification number of the first file, it is determined that the third file can be obtained from the server, and the third file is the latest version of the first file. If there is only a file with an identification number equal to the identification number of the first file in the server, it means that the first file is already the latest version, and it is determined that the third file cannot be obtained from the server.
[0100] In the above embodiment, the identification number of the first file can be obtained by copying the first file to obtain a copy of the first file, storing the identification number of the copy of the first file, and using the identification number of the copy of the first file as the identification number of the first file. In this embodiment, Figure 4 As shown, the file editing method includes:
[0101] Step S410: copy the first file to obtain a copy of the first file, and generate a second file according to the first file and the editing instruction;
[0102] Step S420: storing the identification number of the copy of the first file, so as to determine the identification number of the first file according to the stored identification number of the copy of the first file;
[0103] Step S430: determining whether a third file exists according to the identification number of the copy of the first file, wherein the identification number of the third file is greater than the identification number of the copy of the first file;
[0104] Step S440: If a file with an identification number greater than the identification number of the first file can be obtained from the server, it is determined that the third file can be obtained from the server;
[0105] Step S450: generating an edited file according to the second file and the third file;
[0106] Step S460: publish the edited file to the server.
[0107] In step S410, before receiving the user's input of the editing instruction for the first file, a copy of the first file is saved in the local memory, and one copy is defined as the copy of the first file. The copy of the first file is used to indicate that all previous edits made to the file by the user are based on this version; and one copy is defined as the first file, which is used for editing by the user, and the user's operations in the editor are all based on the operations on the first file.
[0108] In step S420, after receiving the user's editing instruction, the first file becomes the second file, and the copy of the first file has not been edited or modified by the user, so the identification number of the copy of the first file can be used as the identification number of the first file.
[0109] In step S430, the method of determining whether the third file exists in the server is to send the identification number of the copy of the first file to the server, and the server determines whether there is a file with a greater identification number than the copy of the first file based on the identification number of the copy of the first file.
[0110] In step S440, after receiving the request sent by the terminal device to determine whether the third file exists, the server obtains a file whose identification number is greater than the identification number of the copy of the first file according to the identification number of the received copy of the first file, and then sends it to the terminal device. If the identification number of the obtained file is greater than the identification number of the copy of the first file, it is determined that the third file can be obtained from the server, and the third file is the latest version of the first file. If there is only a file whose identification number is equal to the identification number of the copy of the first file in the server, it means that the first file is already the latest version, and it is determined that the third file cannot be obtained from the server.
[0111] Steps S450-460 and Figure 2 Steps S230-240 are the same and will not be described again here.
[0112] There are multiple implementations for generating the edited file according to the second file and the third file in step S230.
[0113] In one embodiment, Figure 5 As shown, step S230 specifically includes:
[0114] Step S2301, respectively obtaining fields included in the second file and fields included in the third file;
[0115] Step S2302: Merge the fields included in the second file and the fields included in the third file to generate an edited file.
[0116] In step S2301, the second file and the third file are data sets with the same attribute characteristics stored in the file system, and the file system refers to a system that stores data in the form of files in a mass storage device, which may include various existing database systems and other file systems. The second file and the third file both include multiple fields, and a field refers to a data set that represents a specific attribute of a file.
[0117] In step S2302, merging refers to the operation of converting at least two independent information into one independent information through reversible combination and / or transformation. Therefore, by merging the fields included in the second file and the fields included in the third file, an edited file can be obtained.
[0118] In one embodiment, see Figure 6 , step S2302 specifically includes:
[0119] Step S23021: Calculate the union of the field identifiers included in the second file and the field identifiers included in the third file to obtain a field identifier set;
[0120] Step S23022: acquiring, according to the field values contained in the second file and the field values contained in the third file, the field value corresponding to each field identifier in the field identifier set;
[0121] Step S23023: Obtain an edited file according to the field identifier set and the field value corresponding to each field identifier in the field identifier set.
[0122] In step S23021, in the embodiment of the present invention, each field includes a field identifier and a field value, the field identifier is used to identify the attribute represented by the field, and the field value is used to store specific information of the attribute represented by the field. The field identifiers contained in the second file and the field identifiers contained in the third file are combined to obtain a field identifier set.
[0123] Step S23022: Obtain the field value corresponding to each field identifier in the field identifier set according to the field value contained in the second file and the field value contained in the third file.
[0124] For each field identifier in the field identifier set, the field value corresponding to the field identifier is obtained according to the field value included in the second file and the field value included in the third file.
[0125] In a specific embodiment, step S23022 specifically includes:
[0126] For a first type of field identifier included in the field identifier set and having a corresponding field value in the second file but not in the third file, setting the field value of the first type of field identifier to the corresponding field value in the second file;
[0127] For the second type of field identifiers included in the field identifier set and having corresponding field values in the third file but not in the second file, setting the field values of the second type of field identifiers to the corresponding field values in the third file;
[0128] For the third type of field identifiers included in the field identifier set and having corresponding field values in both the second file and the third file, and the corresponding field values are different, the field value of the third type of field identifier is set to the corresponding field value in the second file.
[0129] In this embodiment, if there is a first type of field identifier in the field identifier set, and the first type of field identifier has a corresponding field value in the second file, but does not have a corresponding field value in the third file, the field value of the first type of field identifier is set to the corresponding field value in the second file.
[0130] If there is a second type of field identifier in the field identifier set, and the second type of field identifier has a corresponding field value in the third file, but does not have a corresponding field value in the second file, then the field value of the first type of field identifier is set to the corresponding field value in the third file.
[0131] If there is a third type of field identifier in the field identifier set, and the third type of field identifier has corresponding field values in both the second file and the third file, but the corresponding field values are different, the field value of the third type of field identifier is set to the corresponding field value in the second file.
[0132] As mentioned above, multiple terminal devices can send editing information to the server, and the server can process the editing information sent by one terminal and send it to other terminals. After the user obtains the first file from the server, before entering the editing instruction, if the user receives a file forwarded by other terminals through the server, the first file needs to be updated.
[0133] In this embodiment, the file editing method further includes:
[0134] Before receiving the editing instruction input by the user for the first file, if a fourth file sent by the server is received, an updated first file is obtained according to the fourth file and the first file, and the fourth file is an updated version of the first file.
[0135] In this step, the fourth file is a file forwarded to the terminal device through the server after other users edit the first file on other terminal devices, and the fourth file is an updated version of the first file. In one embodiment, the method for determining whether the fourth file is an updated version of the first file can adopt an identification number comparison method. If the identification number of the received file is greater than the identification number of the first file, the file is determined to be the fourth file, and the updated first file is obtained based on the fourth file and the first file; if the identification number of the received file is equal to the identification number of the first file, it is determined that the file is not the fourth file, and the first file is directly used as the latest version of the file.
[0136] In one embodiment, Figure 7 As shown, obtaining an updated first file according to the fourth file and the first file includes:
[0137] Step S710: respectively obtain the fields included in the first file and the fields included in the fourth file;
[0138] Step S720: obtaining a union of the field identifiers included in the first file and the field identifiers included in the fourth file to obtain a field identifier set;
[0139] Step S730: acquiring, according to the field values included in the first file and the field values included in the fourth file, the field value corresponding to each field identifier in the field identifier set;
[0140] Step S740: Obtain an updated first file according to the field identifier set and the field value corresponding to each field identifier in the field identifier set.
[0141] The above step S710 and Figure 5 The above step S720 is similar to step S2301, so it will not be repeated here. Figure 6 Step S23021 is similar, so it will not be repeated here.
[0142] In step S730, the field value corresponding to each field identifier in the field identifier set is obtained according to the field value included in the first file and the field value included in the fourth file.
[0143] In a specific embodiment, step S730 includes:
[0144] For a first type of field identifier included in the field identifier set and having a corresponding field value in the first file but not in the fourth file, setting the field value of the first type of field identifier to the corresponding field value in the first file;
[0145] For a second type of field identifier included in the field identifier set and having a corresponding field value in the fourth file but not in the first file, setting the field value of the second type of field identifier to the corresponding field value in the fourth file;
[0146] For third-category field identifiers included in the field identifier set and having corresponding field values in both the first file and the fourth file, and the corresponding field values are different, the field value of the third-category field identifier is set to the corresponding field value in the fourth file.
[0147] In this embodiment, if the field identifier set includes a third type of field identifier whose corresponding field values exist in both the first file and the fourth file and the corresponding field values are different, it means that other user terminals have edited the first file, and therefore the first file is not the latest file. It is necessary to set the field value of the third type of field identifier to the field value corresponding to the fourth file to obtain an updated first file.
[0148] In one embodiment, if a fourth file is received before receiving an editing instruction input by a user for a first file, and an updated first file is obtained according to the fourth file and the first file, then receiving an editing instruction input by a user for the first file and generating a second file according to the first file and the editing instruction includes:
[0149] An editing instruction for the updated first file input by a user is received, and a second file is generated according to the updated first file and the editing instruction.
[0150] Figure 8 An interactive flow chart of an application scenario of an interactive video in which a file editing method according to an embodiment of the present application is applied is shown.
[0151] In the application scenario of interactive video, the video terminal 101 initiates a connection to the video processing server 105. After the video terminal 101 successfully connects to the video processing server 105, in step S810, the video terminal 101 obtains the first video file. In step S820, the video terminal 101 receives the editing instruction input by the user for the first video file, and obtains the second video file according to the editing instruction and the first video file. Before the video terminal 101 sends the second video file to the video processing server 105, the video terminal 101 sends a request to the server. In step S830, the video terminal 101 determines whether a third file can be obtained from the video processing server 105, and the third file is the latest version of the first file stored in the video processing server 105. In step S840, if the video terminal 101 determines that the third video file exists in the video processing server 105, the third video file is obtained from the video processing server 105, and the second video file and the third video file are merged to obtain the edited file. Finally, the video terminal 101 publishes the edited video file to the video processing server.
[0152] like Fig. 9 As shown, according to an embodiment of the present application, a file editing device is provided, characterized in that the device includes:
[0153] A receiving module 910 is configured to receive an editing instruction for a first file input by a user, and generate a second file according to the first file and the editing instruction;
[0154] A determination module 920 is used to determine whether a third file can be obtained from the server before publishing the second file to the server, wherein the third file is the latest version of the first file stored in the server;
[0155] A generating module 930, configured to generate an edited file according to the second file and the third file if the third file can be obtained from the server;
[0156] The publishing module 940 is used to publish the edited file to the server.
[0157] In one embodiment, the determining module 920 includes:
[0158] a first acquisition unit, configured to determine, according to the identification number of the first file, whether a file having an identification number greater than the identification number of the first file can be acquired from the server;
[0159] A processing unit is configured to determine that the third file can be obtained from the server if a file with an identification number greater than the identification number of the first file can be obtained from the server.
[0160] In one embodiment, the receiving module 910 includes:
[0161] a copying unit, configured to copy the first file to obtain a copy of the first file, and generate a second file according to the first file and the editing instruction;
[0162] The device is also used for:
[0163] storing an identification number of the copy of the first file to determine the identification number of the first file based on the stored identification number of the copy of the first file;
[0164] It is determined whether a third file exists according to the identification number of the copy of the first file, the identification number of the third file being greater than the identification number of the copy of the first file.
[0165] In one embodiment, the generating module 930 includes:
[0166] A second acquisition unit, used to respectively acquire the fields included in the second file and the fields included in the third file;
[0167] The merging unit is used to merge the fields included in the second file and the fields included in the third file to generate an edited file.
[0168] In one embodiment, the field includes a field identifier and a field value, and the merging unit is used to:
[0169] Calculating a union of the field identifiers included in the second file and the field identifiers included in the third file to obtain a field identifier set;
[0170] According to the field values included in the second file and the field values included in the third file, obtaining the field value corresponding to each field identifier in the field identifier set;
[0171] The edited file is obtained according to the field identification set and the field value corresponding to each field identification in the field identification set.
[0172] In one embodiment, acquiring the field value corresponding to each field identifier in the field identifier set according to the field value included in the second file and the field value included in the third file includes:
[0173] For a first type of field identifier included in the field identifier set and having a corresponding field value in the second file but not in the third file, setting the field value of the first type of field identifier to the corresponding field value in the second file;
[0174] For the second type of field identifiers included in the field identifier set and having corresponding field values in the third file but not in the second file, setting the field values of the second type of field identifiers to the corresponding field values in the third file;
[0175] For the third type of field identifiers included in the field identifier set and having corresponding field values in both the second file and the third file, and the corresponding field values are different, the field value of the third type of field identifier is set to the corresponding field value in the second file.
[0176] In one embodiment, the apparatus further comprises:
[0177] The updating module is used to obtain an updated first file according to the fourth file and the first file if a fourth file is received from the server before receiving the editing instruction of the first file input by the user, wherein the fourth file is an updated version of the first file.
[0178] In one embodiment, the receiving module is further configured to:
[0179] An editing instruction for the updated first file input by a user is received, and a second file is generated according to the updated first file and the editing instruction.
[0180] In one embodiment, the update module is used to:
[0181] Respectively obtaining the fields included in the first file and the fields included in the fourth file;
[0182] Calculating a union of the field identifiers included in the first file and the field identifiers included in the fourth file to obtain a field identifier set;
[0183] According to the field values included in the first file and the field values included in the fourth file, obtaining the field value corresponding to each field identifier in the field identifier set;
[0184] An updated first file is obtained according to the field identifier set and the field value corresponding to each field identifier in the field identifier set.
[0185] Fig.10 A schematic diagram of the structure of a computer system suitable for implementing an electronic device of an embodiment of the present disclosure is shown.
[0186] It should be noted that Fig.10 The computer system 800 of the electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0187] like Fig.10 As shown, the computer system 800 includes a central processing unit (CPU) 801, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 808 or the program loaded from the storage part 808 to the random access memory (RAM) 803. In the RAM 803, various programs and data required for system operation are also stored. The CPU 801, the ROM 808, and the RAM 803 are connected to each other through a bus 804. An input / output (I / O) interface 805 is also connected to the bus 804.
[0188] The following components are connected to the I / O interface 805: an input section 806 including a keyboard, a mouse, etc.; an output section 807 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 808 including a hard disk, etc.; and a communication section 809 including a network interface card such as a LAN card, a modem, etc. The communication section 809 performs communication processing via a network such as the Internet. A drive 810 is also connected to the I / O interface 805 as needed. A removable medium 811, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 810 as needed, so that a computer program read therefrom is installed into the storage section 808 as needed.
[0189] In particular, according to an embodiment of the present disclosure, the process described below with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program contains a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 809, and / or installed from the removable medium 811. When the computer program is executed by the central processing unit (CPU) 801, the various functions defined in the method and apparatus of the present application are executed. In some embodiments, the computer system 800 may also include an AI (Artificial Intelligence) processor, which is used to process computing operations related to machine learning.
[0190] It should be noted that the computer-readable medium shown in the present disclosure may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, 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 disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0191] The flow charts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0192] The units involved in the embodiments described in the present disclosure may be implemented by software or hardware, and the units described may also be arranged in a processor. The names of these units do not, in some cases, constitute limitations on the units themselves.
[0193] As another aspect, the present application also provides a computer-readable medium, which may be included in the electronic device described in the above embodiment; or may exist independently without being installed in the electronic device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by an electronic device, the electronic device implements the method described in the following embodiment. For example, the electronic device may implement the following method. Figure 2 to Figure 7 The various steps shown, etc.
Claims
1. A file editing method, It is characterized in that Applied to terminal equipment, including: By calling the socket.io library, a socket channel is established with the server to connect and access a first file in the server, where the first file is an online shared file, and the server is used to store the communication handles of all users accessing the file in a hash map object, where the hash map object stores data in the form of key-value pairs, and uses the identification information of the file as a key; Copying the first file to obtain a copy of the first file, storing an identification number of the copy of the first file, wherein the copy of the first file is used to indicate that all previous edits of the file by the user are modifications made based on this version; the first file is used for editing by the user; Receiving an editing instruction for a first file input by a user logged in on a terminal, and generating a second file according to the first file and the editing instruction; Before publishing the second file to the server, determining whether a third file exists according to the identification number of the copy of the first file, the third file is the latest version of the first file stored in the server, and the identification number of the third file is greater than the identification number of the copy of the first file; If the third file can be obtained from the server, the fields contained in the second file and the fields contained in the third file are respectively obtained, wherein the fields include field identifiers and field values; the field identifiers are used to identify the attributes represented by the fields, and the field values are used to store specific information of the attributes represented by the fields; Calculating a union of the field identifiers included in the second file and the field identifiers included in the third file to obtain a field identifier set; For a first type of field identifier included in the field identifier set and having a corresponding field value in the second file but not in the third file, setting the field value of the first type of field identifier to the corresponding field value in the second file; For the second type of field identifiers included in the field identifier set and having corresponding field values in the third file but not in the second file, setting the field values of the second type of field identifiers to the corresponding field values in the third file; For a third type of field identifier included in the field identifier set and having corresponding field values in both the second file and the third file, and the corresponding field values are different, the field value of the third type of field identifier is set to the corresponding field value in the second file; Obtaining an edited file according to the field identifier set and the field value corresponding to each field identifier in the field identifier set; Publishing the edited file to the server, so that the server obtains the communication handles of all terminal devices that are accessing the file according to the identification information of the file and the hash map object, and sends the file to the corresponding terminal device through the obtained communication handle; Also includes: Before the user logged in on the receiving terminal inputs an editing instruction for the first file, if the identification number of the file received from the server is greater than the identification number of the first file, it is determined that the file is a fourth file, and an updated first file is obtained based on the fourth file and the first file. The fourth file is an updated version of the first file, and the fourth file is a file forwarded to the current terminal device through the server after other users edit the first file on other terminal devices.
2. The method according to claim 1, It is characterized in that The receiving terminal inputs an editing instruction for a first file from a user logged in, and generates a second file according to the first file and the editing instruction, comprising: An editing instruction for the updated first file input by a user is received, and a second file is generated according to the updated first file and the editing instruction.
3. The method according to claim 1, It is characterized in that Obtaining an updated first file according to the fourth file and the first file, including: Respectively obtaining the fields included in the first file and the fields included in the fourth file; Calculating a union of the field identifiers included in the first file and the field identifiers included in the fourth file to obtain a field identifier set; According to the field values included in the first file and the field values included in the fourth file, obtaining the field value corresponding to each field identifier in the field identifier set; An updated first file is obtained according to the field identifier set and the field value corresponding to each field identifier in the field identifier set.
4. A file editing device, It is characterized in that Set in a terminal device, the device is used to: establish a socket channel with a server by calling a socket.io library to connect and access a first file in the server, the first file is an online shared file, and the server is used to store the communication handles of all users accessing the file in a hash map object, the hash map object stores data in the form of key-value pairs, and uses the identification information of the file as a key; including: a receiving module, configured to copy the first file to obtain a copy of the first file, receive an editing instruction for the first file input by a user logged in on a terminal, and generate a second file according to the first file and the editing instruction, wherein the copy of the first file is used to indicate that all previous edits to the file by the user are based on this version; and the first file is used for editing by the user; The device is also used to store an identification number of a copy of the first file; a determination module, configured to determine, before publishing the second file to the server, whether a third file exists according to the identification number of the copy of the first file, the third file being the latest version of the first file stored in the server, and the identification number of the third file being greater than the identification number of the copy of the first file; a generating module, configured to generate an edited file according to the second file and the third file if the third file can be obtained from the server; A publishing module, used for publishing the edited file to the server, so that the server obtains the communication handles of all terminal devices that are accessing the file according to the identification information of the file, and sends the file to the corresponding terminal device through the obtained communication handle; The generation module comprises: A second acquisition unit is used to respectively acquire fields included in the second file and fields included in the third file, wherein the fields include field identifiers and field values; the field identifiers are used to identify attributes represented by the fields, and the field values are used to store specific information of the attributes represented by the fields; a merging unit, configured to obtain a union of field identifiers contained in the second file and field identifiers contained in the third file to obtain a field identifier set; for first-category field identifiers contained in the field identifier set and having corresponding field values in the second file but not in the third file, setting the field values of the first-category field identifiers to the corresponding field values in the second file; for second-category field identifiers contained in the field identifier set and having corresponding field values in the third file but not in the second file, setting the field values of the second-category field identifiers to the corresponding field values in the third file; for third-category field identifiers contained in the field identifier set and having corresponding field values in both the second file and the third file but having different corresponding field values, setting the field values of the third-category field identifiers to the corresponding field values in the second file; and obtaining an edited file according to the field identifier set and the field values corresponding to the respective field identifiers in the field identifier set; The device also includes: The update module is used to obtain an updated first file based on the fourth file and the first file if a fourth file is received from the server before receiving an editing instruction for the first file input by the user, wherein the fourth file is an updated version of the first file and is a file forwarded to the current terminal device through the server after other users edit the first file on other terminal devices.
5. The device according to claim 4, It is characterized in that The receiving module is also used for: An editing instruction for the updated first file input by a user is received, and a second file is generated according to the updated first file and the editing instruction.
6. The device according to claim 4, It is characterized in that Update modules are used to: Respectively obtaining the fields included in the first file and the fields included in the fourth file; Calculating a union of the field identifiers included in the first file and the field identifiers included in the fourth file to obtain a field identifier set; According to the field values included in the first file and the field values included in the fourth file, obtaining the field value corresponding to each field identifier in the field identifier set; An updated first file is obtained according to the field identifier set and the field value corresponding to each field identifier in the field identifier set.
7. An electronic device, It is characterized in that include: one or more processors; A storage device for storing one or more programs, which, when executed by the one or more processors, enables the one or more processors to implement the method according to any one of claims 1 to 3.
8. A computer-readable storage medium, It is characterized in that Computer readable instructions are stored thereon, and when the computer readable instructions are executed by a processor, the processor is caused to execute the method according to any one of claims 1 to 3.
9. A computer program product, It is characterized in that It comprises a computer program carried on a computer-readable storage medium, the computer program comprising a program code for executing the method as claimed in any one of claims 1 to 3.
Citation Information
Patent Citations
Data caching method and device and server
CN104298695A
Intelligent conflict detection and semantic expression of document edits
CN106663089A
File editing method, device and system, client, server and storage medium
CN110110301A
