File synchronization method and apparatus, storage medium, and electronic device
By searching for the target triplet and plugin array in the file synchronization method and performing operations based on the current file state, the problem of poor synchronization performance caused by hard-coded methods is solved, and file state consistency and flexible configuration are achieved.
Patent Information
- Application Number
- CN202211596113.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-13
- Publication Date
- 2026-01-06
- Estimated Expiration
- 2042-12-13
AI Technical Summary
In existing technologies, the file synchronization method between local terminals and servers uses hard coding, resulting in poor synchronization performance and difficulty in flexible adjustment.
By extracting the synchronization operation identifier from the synchronization request, finding the target triplet and plugin array, and performing these operations, the file state is migrated based on the current file state, thus achieving consistency between the file state on the local terminal and the server.
It improves the configurability and scalability of file synchronization operations, ensuring the consistency of file status between the local terminal and the server.
Smart Images

Figure CN115934664B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and more specifically, to a file synchronization method, apparatus, storage medium, and electronic device. Background Technology
[0002] Currently, file operations such as modifying, adding, and deleting files on local terminals or servers in management information systems can lead to inconsistencies in the existence of the same file between the local terminal and the server (e.g., the file exists on the local terminal but not on the server; or the file does not exist on the local terminal but exists on the server terminal; or modifications made on the local terminal result in inconsistencies between the file content stored on the local terminal and the file content on the server). File synchronization is necessary to ensure that the file existence status is consistent between the local terminal and the server.
[0003] In related technologies, such as cloud storage, the timing and method of file synchronization are hard-coded and cannot be configured, resulting in poor synchronization effects between the server and the local terminal. Furthermore, it is difficult to design and modify flexibly. For example, even if published files cannot be changed, cloud storage may still upload accidentally modified files from the local machine to the server.
[0004] There is currently no effective solution to the above problems. Summary of the Invention
[0005] This invention provides a file synchronization method, apparatus, storage medium, and electronic device to at least solve the technical problem in related technologies where the file synchronization method between a local terminal and a server is implemented using hard-coding, resulting in poor synchronization performance when synchronizing files between the server and the local terminal.
[0006] According to one aspect of the present invention, a file synchronization method is provided, comprising: responding to a synchronization request for a target file and extracting a synchronization operation identifier of a synchronization operation in the synchronization request; based on the synchronization operation identifier and the current state of the target file in a management information system, searching for a target triplet and a target plugin array related to the synchronization operation, wherein the target triplet is used to represent the file state migration path of the target file in the management information system, and the target triplet consists of the current state of the target file, the synchronization operation identifier, and a first target state; executing a plugin in the target plugin array, and if the plugin in the target plugin array is executed successfully, updating the current state of the target file in the management information system to the first target state, so that the existence state of the target file on the local terminal and the server in the management information system is consistent.
[0007] Further, based on the synchronization operation identifier and the current state of the target file in the management information system, the process of searching for the target triplet and the target plugin array related to the synchronization operation includes: searching for the target triplet in the triplet list of the file state transition graph based on the synchronization operation identifier and the current state, wherein each triplet in the triplet list represents a file state transition path in the file state transition graph; and, if the target triplet is found, searching for the target plugin array in the operation configuration file of the file state transition graph based on the synchronization operation identifier, wherein the operation configuration file records the plugins that perform the path association operation for each file state transition in the file state transition graph.
[0008] Furthermore, the target plugin array includes multiple plugins, and executing the plugins in the target plugin array includes: executing the multiple plugins in the target plugin array according to the order in which the multiple plugins are arranged in the target plugin array; receiving the execution results of the multiple plugins; and determining that the plugins in the target plugin array have been executed successfully if the execution results indicate that all the multiple plugins have been executed successfully.
[0009] Further, before searching for the target triplet in the triplet list of the file state transition graph based on the synchronization operation identifier and the current state, the file synchronization method further includes: obtaining N triplets, combining the N triplets to obtain the triplet list, wherein each triplet in the N triplets includes: a starting state, an operation identifier, and a second target state, and N is a positive integer greater than or equal to 1; obtaining operation identifiers for multiple operations and a plugin array corresponding to each operation identifier, and determining the operation configuration file based on the operation identifiers for multiple operations and the plugin array corresponding to each operation identifier, wherein the multiple operations are synchronization operations performed on files on a server or local terminal in the management information system, and the plugin array is used to store multiple plugins that execute the operation corresponding to each operation identifier; and determining the file state transition graph based on the triplet list and the operation configuration file.
[0010] Further, determining the file state transition graph based on the triplet list and the operation configuration file includes: determining an initial state transition graph based on the triplet list and the operation configuration file; performing a first verification on the initial state transition graph based on the state types of the file states in the initial state transition graph to obtain a first verification result, wherein the state types include at least a first state type and a second state type, and the stability of the state corresponding to the first state type is higher than that of the state corresponding to the second state type in the management information system; performing a second verification on the initial state transition graph based on the triplets in the triplet list in the initial state transition graph to obtain a second verification result; and determining the initial state transition graph as the file state transition graph if both the first verification result and the second verification result indicate that the verification has passed.
[0011] Further, based on the triples in the triple list of the initial state transition graph, a second verification is performed on the initial state transition graph to obtain a second verification result, including: verifying whether the number of second target states corresponding to the same initial state and operation identifier in the triple list is one, to obtain a third verification result; verifying whether the operation identifier in each triple exists in the operation configuration file, to obtain a fourth verification result; and determining the second verification result based on the third verification result and the fourth verification result.
[0012] Furthermore, the file synchronization method further includes: obtaining configuration information of a target operation and a triple corresponding to the target operation, wherein the configuration information of the target operation includes at least: a target operation identifier and a plugin corresponding to the target operation identifier; adding the configuration information of the target operation to the operation configuration file corresponding to the file state transition graph, and adding the triple corresponding to the target operation to the triple list corresponding to the file state transition graph.
[0013] According to another aspect of the present invention, a file synchronization apparatus is also provided, comprising: an extraction unit, configured to extract a synchronization operation identifier of a synchronization operation in a synchronization request in response to a synchronization request for a target file; a search unit, configured to search for a target triplet and a target plugin array related to the synchronization operation based on the synchronization operation identifier and the current state of the target file in a management information system, wherein the target triplet represents the file state migration path of the target file in the management information system, and the target triplet consists of the current state of the target file, the synchronization operation identifier, and a first target state; and a processing unit, configured to execute plugins in the target plugin array, and, if the plugins in the target plugin array are executed successfully, update the current state of the target file in the management information system to the first target state, so that the existence state of the target file on the local terminal and the server in the management information system is consistent.
[0014] Further, the search unit includes: a first search subunit, configured to search for the target triplet in the triplet list of the file state transition graph based on the synchronization operation identifier and the current state, wherein each triplet in the triplet list represents a file state transition path in the file state transition graph; and a second search subunit, configured to, if the target triplet is found, search for the target plugin array in the operation configuration file of the file state transition graph based on the synchronization operation identifier, wherein the operation configuration file records the plugins that perform the path association operation for each file state transition in the file state transition graph.
[0015] Furthermore, the target plugin array includes multiple plugins, and the processing unit includes: an execution subunit, used to execute multiple plugins in the target plugin array according to the order in which the multiple plugins are arranged in the target plugin array; a receiving subunit, used to receive the execution results of the multiple plugins; and a first determining subunit, used to determine that the plugins in the target plugin array have been executed successfully if the execution results indicate that all the multiple plugins have been executed successfully.
[0016] Furthermore, the search unit further includes: an acquisition subunit, configured to acquire N triples and combine the N triples to obtain the triple list before searching for the target triple in the triple list of the file state transition graph based on the synchronization operation identifier and the current state, wherein each triple in the N triples includes: a starting state, an operation identifier, and a second target state, and N is a positive integer greater than or equal to 1; a second determination subunit, configured to acquire operation identifiers of multiple operations and a plugin array corresponding to each operation identifier, and determine the operation configuration file based on the operation identifiers of the multiple operations and the plugin array corresponding to each operation identifier, wherein the multiple operations are synchronization operations performed on files of a server or local terminal in the management information system, and the plugin array is used to store multiple plugins that execute the operation corresponding to each operation identifier; and a third determination subunit, configured to determine the file state transition graph based on the triple list and the operation configuration file.
[0017] Further, the third determining subunit includes: a determining module, configured to determine an initial state transition diagram based on the triplet list and the operation configuration file; a first verification module, configured to perform a first verification on the initial state transition diagram based on the state type of the file state in the initial state transition diagram, and obtain a first verification result, wherein the state type includes at least: a first state type and a second state type, and the stability of the state corresponding to the first state type is higher than that of the state corresponding to the second state type in the management information system; a second verification module, configured to perform a second verification on the initial state transition diagram based on the triplets in the triplet list in the initial state transition diagram, and obtain a second verification result; and a determining module, configured to determine the initial state transition diagram as the file state transition diagram when both the first verification result and the second verification result indicate that the verification has passed.
[0018] Furthermore, the second verification module includes: a first verification submodule, used to verify whether the number of second target states corresponding to the same initial state and operation identifier in the triplet list is one, to obtain a third verification result; a second verification submodule, used to verify whether the operation identifier in each triplet exists in the operation configuration file, to obtain a fourth verification result; and a determination submodule, used to determine the second verification result based on the third verification result and the fourth verification result.
[0019] Furthermore, the file synchronization device also includes: an acquisition unit, used to acquire configuration information of a target operation and a triplet corresponding to the target operation, wherein the configuration information of the target operation includes at least: a target operation identifier and a plugin corresponding to the target operation identifier; and an addition unit, used to add the configuration information of the target operation to the operation configuration file corresponding to the file state transition graph, and add the triplet corresponding to the target operation to the triplet list corresponding to the file state transition graph.
[0020] According to another aspect of the present invention, an electronic device is also provided, including: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to perform the file synchronization method of any of the above-mentioned methods by executing the executable instructions.
[0021] According to another aspect of the present invention, a computer-readable storage medium is also provided, which stores a computer program, wherein the computer program controls the device where the computer-readable storage medium is located to execute the file synchronization method described above when it is running.
[0022] In this invention, in response to a synchronization request for a target file, the synchronization operation identifier of the synchronization operation in the synchronization request is extracted. Based on the synchronization operation identifier and the current state of the target file in the management information system, a target triplet and a target plugin array related to the synchronization operation are searched. The target triplet represents the file state migration path of the target file in the management information system and consists of the current state of the target file, the synchronization operation identifier, and a first target state. Plugins in the target plugin array are executed, and if the plugins in the target plugin array execute successfully, the current state of the target file in the management information system is updated to the first target state, so that the existence state of the target file on the local terminal and the server in the management information system is consistent. This solves the technical problem in related technologies where the file synchronization method between the local terminal and the server is implemented using hard-coding, resulting in poor synchronization effects. In this invention, the target file is synchronized using a triplet list and plugins in the operation configuration file, avoiding the situation where hard-coding the synchronization of server and local terminal files makes it difficult to flexibly adjust the file synchronization operation method, thereby achieving the technical effect of improving the configurability and scalability of file synchronization operations. Attached Figure Description
[0023] The accompanying drawings, which are included to provide a further understanding of the invention and form part of this application, illustrate exemplary embodiments of the invention and, together with their description, serve to explain the invention and do not constitute an undue limitation thereof. In the drawings:
[0024] Figure 1This is a flowchart of an optional file synchronization method according to an embodiment of the present invention;
[0025] Figure 2 This is a schematic diagram of an optional file state transition diagram according to an embodiment of the present invention;
[0026] Figure 3 This is a flowchart of another optional file synchronization method according to an embodiment of the present invention;
[0027] Figure 4 This is a schematic diagram of an optional file synchronization device according to an embodiment of the present invention. Detailed Implementation
[0028] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0029] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0030] For ease of description, some of the terms or nouns involved in this invention will be explained below.
[0031] File checkout: Downloads the file from the server to the local machine for modification, which cannot be modified by others.
[0032] File checkout status: This indicates that the file is being modified by a certain business terminal (an individual operation that can be performed by that business).
[0033] File check-in: Uploads the modified file checked out locally to the server, cancels the file check-out status, and the file can be checked out again.
[0034] File synchronization: Files exist on both the local terminal and a remote server, and synchronization ensures that the files on the local terminal and the server are consistent.
[0035] Example 1
[0036] According to an embodiment of the present invention, an optional file synchronization method is provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.
[0037] Figure 1 This is a flowchart of an optional file synchronization method according to an embodiment of the present invention, such as... Figure 1 As shown, the method includes the following steps:
[0038] Step S101: Respond to the synchronization request for the target file and extract the synchronization operation identifier of the synchronization operation in the synchronization request.
[0039] The aforementioned synchronization request can be used to ensure that the target file exists in the same state on the local terminal and server within the management information system. The decision to initiate a synchronization request can be based on the target file's state within the management information system. For example: if the target file does not exist on the local terminal but exists on the server, the synchronization request can be used to request downloading the target file from the server to the local terminal; the synchronization operation can then be considered a download operation. If the target file exists on the local terminal but not on the server, the synchronization request can be used to request uploading the target file to the server; the synchronization operation can then be considered an upload operation. If the target file is in a checked-out state, the synchronization request can be used to request the invocation of the "check-in method" to synchronize the local file to the server; the synchronization operation can then be considered a check-in operation. If a "collaborator" has published the target file on the server, the synchronization request can be used to synchronize the target file to the local machine. The synchronization operation identifier can be the name, code, etc., of the synchronization operation.
[0040] It should be noted that the synchronization operations in the above synchronization requests may include, but are not limited to, operations such as creating, deleting, uploading, deleting server files, checking in, checking out, and downloading.
[0041] Step S102: Based on the synchronization operation identifier and the current state of the target file in the management information system, find the target triplet and the target plugin array related to the synchronization operation. The target triplet is used to represent the file state migration path of the target file in the management information system. The target triplet consists of the current state of the target file, the synchronization operation identifier, and the first target state.
[0042] In this embodiment, a target triple containing the synchronization operation identifier and the current state of the target file in the management information system can be found based on the synchronization operation identifier and the current state of the target file in the management information system. If the target triple is found, the target plugin array can be found based on the synchronization operation identifier.
[0043] The first target state mentioned above can be the state of the target file in the management information system when the above synchronization operation is performed on the target file in its current state and the synchronization operation is successfully executed.
[0044] Step S103: Execute the plugins in the target plugin array, and if the plugins in the target plugin array are executed successfully, update the current state of the target file in the management information system to the first target state, so that the existence state of the target file on the local terminal and the server in the management information system is consistent.
[0045] In this embodiment, the plugins in the target plugin array can be executed according to their order of execution. If a plugin in the target plugin array is executed successfully, the current state of the target file in the management information system is updated to the first target state in the found target triplet, so that the existence state of the target file on the local terminal and the server in the management information system is consistent.
[0046] It should be noted that the status in this embodiment can refer to the status of the management information system, which may include, but is not limited to, the status of a file, the folder or part to which the file belongs, the status of the project to which the file belongs, the local client, the remote server, and other indicators. For example, the file exists on the local client, but does not exist on the remote server; the part to which the file belongs has been published, etc.
[0047] Through the above steps, in this embodiment, the target file is synchronized using a triplet list and plugins in the operation configuration file. This avoids the problem of hard-coding the synchronization of files between the server and the local terminal, which makes it difficult to flexibly adjust the file synchronization operation. This improves the configurability and scalability of the file synchronization operation. Furthermore, it solves the technical problem in related technologies where the file synchronization method between the local terminal and the server is hard-coded, resulting in poor synchronization performance.
[0048] Optionally, based on the synchronization operation identifier and the current state of the target file in the management information system, the target triplet and target plugin array related to the synchronization operation are searched, including: searching for the target triplet in the triplet list of the file state transition graph based on the synchronization operation identifier and the current state, wherein each triplet in the triplet list is used to represent the file state transition path in the file state transition graph; if the target triplet is found, searching for the target plugin array in the operation configuration file of the file state transition graph according to the synchronization operation identifier, wherein the operation configuration file is used to record the plugins that perform the path-related operations of each file state transition in the file state transition graph.
[0049] Figure 2 This is a schematic diagram of an optional file state transition diagram according to an embodiment of the present invention, such as... Figure 2 As shown, an optional file state transition diagram is presented. Figure 2 The document describes five file states, as shown in Table 1. The state is described by whether the file exists on the local client (referred to as "local") or the remote server (referred to as "server"). S1 and S3 are stable states, while S2, S4, and S5 are transient states.
[0050] Table 1
[0051] state describe S1 The file does not exist locally and does not exist on the server. S2 The file exists locally but not on the server. S3 The file exists locally and on the server, and the files on both are identical. S4 The file exists locally and on the server, but the local and server files are inconsistent. S5 The file does not exist locally but exists on the server.
[0052] Figure 2 The diagram illustrates seven operation methods, which are explained below with reference to Table 2:
[0053] Table 2
[0054] Method Name illustrate New local Software tools such as CAD and Office (office software) can be used to create files locally. Local deletion Delete locally saved files Upload Upload local files to the server Delete server Delete server files Detected Download the server file to your local machine and modify it. Inspection Modify the detected files and upload them to the server. download Download the server file to your local machine; do not modify it.
[0055] For example, if the target file's current status in the management information system is "Initial State," and the synchronization operation name is "Operation" (corresponding to the synchronization operation identifier mentioned above), a search is performed in the triplet list using "Initial State" and "Operation" as search criteria. If the search finds a target triplet with "Initial State" as "Local = Available, Server = None" and "Operation" as "Upload," then the "Operation" definition can be searched in the "Operation Configuration" (corresponding to the operation configuration file mentioned above). For example, "Upload" can find a target plugin array, which may include two plugins: "upload" and "send_email." If no results are found, it means that the "Operation" or "Initial State" is not under control and does not need to be synchronized. The synchronization operation program can then be exited, thus achieving the technical effect of ensuring the reliability of file synchronization operations.
[0056] Optionally, the target plugin array includes multiple plugins. Executing the plugins in the target plugin array includes: executing multiple plugins in the target plugin array according to their order in the target plugin array; receiving the execution results of multiple plugins; and determining that the plugins in the target plugin array have been executed successfully if the execution results indicate that all multiple plugins have been executed successfully.
[0057] In this embodiment, plugins in the target plugin array are executed sequentially according to their definition order. If any plugin fails to execute, the program exits. If all plugins in the target plugin array execute successfully, the system state is set to the queried target triplet "target state" (i.e., the first target state). This achieves the technical effect of providing reliable file synchronization operations.
[0058] Optionally, before searching for the target triplet in the triplet list of the file state transition graph based on the synchronization operation identifier and the current state, the file synchronization method further includes: obtaining N triplets, combining the N triplets to obtain a triplet list, wherein each triplet in the N triplets includes: initial state, operation identifier, and second target state, and N is a positive integer greater than or equal to 1; obtaining the operation identifiers of multiple operations and the plugin array corresponding to each operation identifier, and determining the operation configuration file based on the operation identifiers of multiple operations and the plugin array corresponding to each operation identifier, wherein the multiple operations are synchronization operations performed on files on servers or local terminals in the management information system, and the plugin array is used to store multiple plugins that execute the operation corresponding to each operation identifier; and determining the file state transition graph based on the triplet list and the operation configuration file.
[0059] The file state transition diagram described above can represent how performing a certain operation on a file can transform the current state into another state transition diagram. Figure 2 The diagram illustrates one possible file state transition graph.
[0060] The file state transition diagram described above can be defined in the following way:
[0061] 1. Define operation configuration files. Operations can be described by arrays of plugin executables. For example, a file upload operation includes two plugin executables: upload and post-upload email notification. The standard product operation configuration definitions of the management information system meet the product specifications. For customized customer needs, standard product plugin definitions can be replaced with customer-customized plugins, or customer-customized plugins can be defined before and after existing plugin execution to implement pre-execution checks and post-execution notifications for standard plugins. Taking JSON (a lightweight data exchange format) as an example, the configuration can include: operation identifiers, such as operation names: operation 1, operation 2; a plugin array, where one operation can execute multiple plugins, which can be stored in an array and executed sequentially to implement pre- and post-execution logic. Plugin descriptions can at least include: a plugin body, such as dll, jar, or so, and a plugin execution function.
[0062]
[0063]
[0064] 2. Define a list of (starting state, operation, target state) triples to describe the state transition path. The operation is a plugin configuration operation. The triple list can be stored in various formats, including but not limited to XML (Extensible Markup Language), JSON, YAML (YAML, a highly readable markup language used to express data serialization), and database tables. Data structures include, but are not limited to, arrays, linked lists, and hash tables. An empty operation plugin array is allowed, indicating that the operation does not need to perform any action to achieve state transition. For example, in collaborative design, if a designer publishes a file, and the user's local file is identical to the one on the server, only state transition is needed; no operation on the file is required. The following example uses JSON format:
[0065]
[0066]
[0067] The operation configuration file can be modified as follows: If the customer wants the target application to notify them after uploading, they only need to write a notification plugin for the target application and replace the email notification plugin in the operation configuration file; if the customer wants to notify users who have saved the file by email after deletion, they can configure the "email notification" plugin to be added to the operation configuration file after "deleting" the plugin.
[0068]
[0069]
[0070] The state transition path is defined in the (starting state, operation, target state) triple list description file as follows.
[0071] The "upload" operation enables the state transition from "local = available server = no server" to "local = available server = available".
[0072]
[0073]
[0074] Based on the triple list and operation configuration file, a file state transition diagram is determined, which can support collaborative design by multiple people. Furthermore, by modifying the triple list and operation configuration file, the configurability of file synchronization operations in the management information system can be increased.
[0075] Optionally, a file state transition diagram is determined based on a triplet list and an operation configuration file, including: determining an initial state transition diagram based on the triplet list and the operation configuration file; performing a first verification on the initial state transition diagram based on the state types of the file states in the initial state transition diagram to obtain a first verification result, wherein the state types include at least: a first state type and a second state type, and the stability of the state corresponding to the first state type is higher than that of the state corresponding to the second state type in the management information system; performing a second verification on the initial state transition diagram based on the triplets in the triplet list in the initial state transition diagram to obtain a second verification result; if both the first verification result and the second verification result indicate that the verification has passed, the initial state transition diagram is determined as a file state transition diagram.
[0076] In this embodiment, the file state transition graph also provides an optional integrity verification algorithm. The defined initial state transition graph can be verified before determining the file state transition graph.
[0077] The first state type mentioned above can be a stable state, which can be the target state of a file in a management information system, for example: Figure 2 States S1 and S3 represent two states: the file does not exist locally and it does not exist on the server; the file exists locally and it exists on the server, and the local and server files are identical. The second state type mentioned above is a temporary state, which can be an intermediate state to reach a stable state. For example: Figure 2In the states S2, S4, and S5, the file exists locally but not on the server; the file exists locally and on the server, but the files are inconsistent; the file does not exist locally but on the server, etc., in this embodiment, all "stable states" can be reached through one or more "temporary states"; any "stable state" can return to its own "stable state" through one or more "temporary states". Therefore, the first verification mentioned above can verify whether all "stable states" in the initial state transition diagram can be reached through one or more "temporary states"; and whether any "stable state" can return to its own "stable state" through one or more "temporary states".
[0078] In this embodiment, the same "starting state" and "operation" can only lead to one "target state." Each "operation" appearing in the triplet list (corresponding to the operation identifier in the triplet list) must be defined in the "operation configuration" (i.e., the operation configuration file). Therefore, the aforementioned second verification can be performed on the initial state transition graph based on the triplets in the triplet list of the initial state transition graph, yielding the second verification result.
[0079] If both the first and second verification results indicate that the verification has passed, the initial state transition diagram is determined as the file state transition diagram. By verifying the initial file state transition diagram, the technical effect of ensuring the reliability of file synchronization operations in the management information system is achieved.
[0080] Optionally, based on the triples in the triple list of the initial state transition graph, a second verification is performed on the initial state transition graph to obtain a second verification result, including: verifying whether the number of second target states corresponding to the same initial state and operation identifier in the triple list is one, to obtain a third verification result; verifying whether the operation identifier in each triple exists in the operation configuration file, to obtain a fourth verification result; and determining the second verification result based on the third and fourth verification results.
[0081] In this embodiment, the same "starting state" and "operation" can only reach one "target state". Therefore, the above-mentioned third verification can be to verify whether the number of second target states corresponding to the same starting state and operation identifier in the triplet list is one, and obtain the third verification result.
[0082] The "operation" (corresponding to the operation identifier in the triplet list) appearing in each triplet in the above triplet list must be defined in the "operation configuration" (i.e., the operation configuration file). Therefore, the fourth check described above can verify whether the operation identifier in each triplet exists in the operation configuration file, and obtain the fourth check result.
[0083] If both the third and fourth verification results are successful, the second verification result can be determined to be successful.
[0084] By verifying the file state transition diagram, the technical effect of ensuring the reliability of file synchronization operations in the management information system was achieved.
[0085] Optionally, the file synchronization method further includes: obtaining the configuration information of the target operation and the triplet corresponding to the target operation, wherein the configuration information of the target operation includes at least: the target operation identifier and the plugin corresponding to the target operation identifier; adding the configuration information of the target operation to the operation configuration file corresponding to the file state transition graph, and adding the triplet corresponding to the target operation to the triplet list corresponding to the file state transition graph.
[0086] In this embodiment, to facilitate configuration adjustments to the file state transition graph, if a customer wishes to add a new state transition, for example, if the current synchronization operation does not meet the requirements and a new operation is configured, a new state triplet can be configured. A plugin for this operation is then added to the operation configuration file. The configuration information of the target operation and the corresponding triplet can be used for the new synchronization operation and its corresponding triplet. The configuration information of the target operation can be added to the operation configuration file corresponding to the file state transition graph, and the triplet corresponding to the target operation can be added to the triplet list corresponding to the file state transition graph. For example, a customer might require synchronized release of a version file instead of the latest version based on management needs. In this case, only a "download and release version file" plugin needs to be written and configured in the "not found locally, exists on server" state handling program.
[0087] It should be noted that after adding the triple corresponding to the target operation to the triple list corresponding to the file state transition graph, the updated file state transition graph can still be subjected to a first verification and a second verification.
[0088] This embodiment defines new state transitions and new operations according to user needs without affecting the functions of the already defined file synchronization operations, thus achieving the technical effect of increasing the scalability and stability of file synchronization operations in the management information system.
[0089] Figure 3 This is a flowchart of another optional file synchronization method according to an embodiment of the present invention, such as... Figure 3 As shown, the file synchronization process is as follows:
[0090] 1) S301: Receive a synchronization request, obtain the file operation from the request, the synchronization request may include the "operation" name (i.e. file operation identifier), and parse the "operation" name from the request.
[0091] 2) S302: Search in the triplet array (i.e., the triplet list) based on the current file status and file operation. The current system status is "Starting State". The search is performed using "Starting State" and "Operation" as the query conditions. For example, if "Starting State" is "Local = Yes, Server = No" and the operation is "Upload", the search will return the triplet ("Local = Yes, Server = No", "Upload", "Local = Yes, Server = Yes").
[0092]
[0093]
[0094] 3) S303: Unknown operation exception. If the query is performed in the triple list with "starting state" and "operation" as the query conditions and no result is found, it means that "operation" or "starting state" is not within the control scope and synchronization is not required. The file synchronization program will exit.
[0095] 4) S304: Use the file operation name to find the plugin definition in the operation plugin configuration file (corresponding to the operation configuration file mentioned above), and use "operation" to find the "operation" definition in the "operation configuration" (i.e., operation configuration file). For example, "upload" can find two plugins: "upload" and "send_email".
[0096]
[0097] 5) S305: Operation plugin undefined exception. If you search for the definition of "operation" in "operation configuration" (i.e. operation configuration file) using "operation", and no definition of "operation" is found, the operation definition is abnormal and the file synchronization program exits.
[0098] 6) S306: Execute the synchronization plugins sequentially according to the order of the operation array, and execute the plugins sequentially according to the definition order of the queried plugins.
[0099] 7) S307: Plugin execution error, the program exits if any plugin fails to execute.
[0100] 8) S308: If all plugins execute successfully, then set the file status in the management information system to the triple "target status" found in S302.
[0101] This embodiment defines a file state transition graph as the synchronization of various temporary states of a file to a stable state through file operations. A file synchronization method based on this graph is designed, supporting collaborative design by multiple users. The system is scalable, configurable, and stable. Scalability is demonstrated by defining new state transitions and operations according to user needs; configurability is demonstrated by allowing modification of configurations to meet specific business scenarios; and stability is demonstrated by ensuring that implementing customized customer requirements does not affect existing functionality. File synchronization is associated with system states, and state transition rules are defined (e.g., disallowing uploads of published files, adding a state verification plugin before the upload plugin, and notifying collaborators via email upon file check-in). This supports collaborative design by multiple users.
[0102] Example 2
[0103] This embodiment provides an optional file synchronization device, wherein each implementation unit in the synchronization device corresponds to each implementation step in Embodiment 1.
[0104] Figure 4 This is a schematic diagram of an optional file synchronization device according to an embodiment of the present invention, such as... Figure 4 As shown, the file synchronization device includes: extraction unit 41, search unit 42, and processing unit 43.
[0105] Specifically, extraction unit 41 is used to respond to a synchronization request for the target file and extract the synchronization operation identifier of the synchronization operation in the synchronization request;
[0106] The lookup unit 42 is used to look up the target triplet and the target plug-in array related to the synchronization operation based on the synchronization operation identifier and the current state of the target file in the management information system. The target triplet is used to represent the file state migration path of the target file in the management information system. The target triplet consists of the current state of the target file, the synchronization operation identifier, and the first target state.
[0107] Processing unit 43 is used to execute the plugins in the target plugin array, and if the plugins in the target plugin array are executed successfully, update the current state of the target file in the management information system to the first target state, so that the existence state of the target file in the local terminal and the server in the management information system is consistent.
[0108] In the file synchronization device provided in Embodiment 2 of this application, the extraction unit 41 responds to the synchronization request for the target file and extracts the synchronization operation identifier of the synchronization operation in the synchronization request. The search unit 42, based on the synchronization operation identifier and the current state of the target file in the management information system, searches for the target triplet and target plugin array related to the synchronization operation. The target triplet represents the file state migration path of the target file in the management information system and consists of the current state of the target file, the synchronization operation identifier, and a first target state. The processing unit 43 executes the plugins in the target plugin array, and if the plugins in the target plugin array execute successfully, updates the current state of the target file in the management information system to the first target state, so that the existence state of the target file on the local terminal and the server in the management information system is consistent. This solves the technical problem in related technologies where the file synchronization method between the local terminal and the server is implemented using hard coding, resulting in poor synchronization effects when synchronizing files on the server and the local terminal. In this embodiment, the target file is synchronized using a list of triples and plugins in the operation configuration file. This avoids the problem of hard-coding the synchronization of files between the server and the local terminal, which makes it difficult to flexibly adjust the file synchronization operation method. This achieves the technical effect of improving the configurability and scalability of file synchronization operations.
[0109] Optionally, in the file synchronization device provided in Embodiment 2 of this application, the search unit 42 includes: a first search subunit, used to search for a target triplet in the triplet list of the file state transition graph based on the synchronization operation identifier and the current state, wherein each triplet in the triplet list is used to represent the path of file state transition in the file state transition graph; and a second search subunit, used to search for a target plugin array in the operation configuration file of the file state transition graph based on the synchronization operation identifier when the target triplet is found, wherein the operation configuration file is used to record the plugins that perform the path association operation of each file state transition in the file state transition graph.
[0110] Optionally, in the file synchronization device provided in Embodiment 2 of this application, the target plugin array includes multiple plugins, and the processing unit 43 includes: an execution subunit, used to execute multiple plugins in the target plugin array according to the order of the multiple plugins in the target plugin array; a receiving subunit, used to receive the execution results of multiple plugins; and a first determining subunit, used to determine that the plugins in the target plugin array have been executed successfully when the execution results indicate that all multiple plugins have been executed successfully.
[0111] Optionally, in the file synchronization device provided in Embodiment 2 of this application, the search unit 42 further includes: an acquisition subunit, used to acquire N triples and combine the N triples to obtain a triple list before searching for the target triple in the triple list of the file state transition diagram based on the synchronization operation identifier and the current state of the target file in the management information system, wherein each triple in the N triples includes: a starting state, an operation identifier, and a second target state, and N is a positive integer greater than or equal to 1; a second determination subunit, used to acquire the operation identifiers of multiple operations and the plug-in array corresponding to each operation identifier, and determine the operation configuration file based on the operation identifiers of multiple operations and the plug-in array corresponding to each operation identifier, wherein the multiple operations are synchronization operations performed on files of a server or local terminal in the management information system, and the plug-in array is used to store multiple plug-ins that execute the operation corresponding to each operation identifier; and a third determination subunit, used to determine the file state transition diagram based on the triple list and the operation configuration file.
[0112] Optionally, in the file synchronization device provided in Embodiment 2 of this application, the third determining subunit includes: a determining module, used to determine an initial state transition diagram based on a triplet list and an operation configuration file; a first verification module, used to perform a first verification on the initial state transition diagram based on the state type of the file state in the initial state transition diagram, and obtain a first verification result, wherein the state type includes at least: a first state type and a second state type, and the stability of the state corresponding to the first state type in the management information system is higher than that of the state corresponding to the second state type; a second verification module, used to perform a second verification on the initial state transition diagram based on the triplet list in the initial state transition diagram, and obtain a second verification result; and a determining module, used to determine the initial state transition diagram as a file state transition diagram if both the first verification result and the second verification result indicate that the verification has passed.
[0113] Optionally, in the file synchronization device provided in Embodiment 2 of this application, the second verification module includes: a first verification submodule, used to verify whether the number of second target states corresponding to the same starting state and operation identifier in the triplet list is one, and obtain a third verification result; a second verification submodule, used to verify whether the operation identifier in each triplet exists in the operation configuration file, and obtain a fourth verification result; and a determination submodule, used to determine the second verification result based on the third verification result and the fourth verification result.
[0114] Optionally, in the file synchronization device provided in Embodiment 2 of this application, the file synchronization device further includes: an acquisition unit, used to acquire configuration information of a target operation and a triplet corresponding to the target operation, wherein the configuration information of the target operation includes at least: a target operation identifier and a plugin corresponding to the target operation identifier; and an adding unit, used to add the configuration information of the target operation to the operation configuration file corresponding to the file state transition graph, and add the triplet corresponding to the target operation to the triplet list corresponding to the file state transition graph.
[0115] The aforementioned file synchronization device may also include a processor and a memory. The aforementioned extraction unit 41, search unit 42, and processing unit 43 are all stored in the memory as program units, and the processor executes the aforementioned program units stored in the memory to realize the corresponding functions.
[0116] The aforementioned processor contains a kernel, which retrieves the corresponding program units from memory. One or more kernels can be configured, and by adjusting kernel parameters, synchronization operations on target files can be performed using a triplet list and plugins in the operation configuration file. This avoids the difficulty of flexibly adjusting file synchronization methods when using hard-coded methods for synchronizing server and local terminal files, thus achieving the technical effect of improving the configurability and scalability of file synchronization operations.
[0117] The aforementioned memory may include non-permanent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip.
[0118] According to another aspect of the present invention, an electronic device is also provided, including: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to perform the file synchronization method of any of the above-mentioned methods by executing the executable instructions.
[0119] According to another aspect of the present invention, a computer-readable storage medium is also provided, which stores a computer program, wherein the computer program controls the device where the computer-readable storage medium is located to execute the file synchronization method described above when it is running.
[0120] The sequence numbers of the above embodiments of the present invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0121] In the above embodiments of the present invention, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0122] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units can be a logical functional division, and in actual implementation, there may be other division methods. For instance, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual coupling, direct coupling, or communication connection may be through some interfaces; the indirect coupling or communication connection between units or modules may be electrical or other forms.
[0123] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0124] Furthermore, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0125] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks.
[0126] The above description is only a preferred embodiment of the present invention. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.
Claims
1. A file synchronization method, characterized by, The method comprises the following steps: in response to a synchronization request for a target file, extracting a synchronization operation identifier of a synchronization operation in the synchronization request; based on the synchronization operation identifier and the current state of the target file in the management information system, finding a target triple related to the synchronization operation and a target plug-in array, wherein the target triple is used to represent a file state migration path of the target file in the management information system, and the target triple is composed of the current state of the target file, the synchronization operation identifier and a first target state; executing the plug-ins in the target plug-in array, and updating the current state of the target file in the management information system to the first target state if the execution of the plug-ins in the target plug-in array is successful, so that the existence state of the target file in the management information system is consistent with that of the server and the local terminal.
2. The file synchronization method of claim 1, wherein, Based on the synchronization operation identifier and the current state of the target file in the management information system, finding a target triple related to the synchronization operation and a target plug-in array, comprising: based on the synchronization operation identifier and the current state, finding the target triple in a triple list of a file state migration graph, wherein each triple in the triple list is used to represent a path of file state migration in the file state migration graph; if the target triple is found, finding the target plug-in array in an operation configuration file of the file state migration graph according to the synchronization operation identifier, wherein the operation configuration file is used to record plug-ins of associated operations for executing each path of file state migration in the file state migration graph.
3. The file synchronization method of claim 1, wherein, The target plug-in array includes a plurality of plug-ins, and the execution of the plug-ins in the target plug-in array comprises: executing the plurality of plug-ins in the target plug-in array according to the arrangement order of the plurality of plug-ins in the target plug-in array; receiving the execution results of the plurality of plug-ins; if the execution results indicate that the plurality of plug-ins are all executed successfully, it is determined that the execution of the plug-ins in the target plug-in array is successful.
4. The file synchronization method of claim 2, wherein, Before finding the target triple in the triple list of the file state migration graph based on the synchronization operation identifier and the current state, the file synchronization method further comprises: obtaining N triples, combining the N triples to obtain the triple list, wherein each triple in the N triples comprises a starting state, an operation identifier and a second target state, and N is a positive integer greater than or equal to 1; obtaining operation identifiers of a plurality of operations and plug-in arrays corresponding to each operation identifier, and determining the operation configuration file based on the operation identifiers of the plurality of operations and the plug-in arrays corresponding to each operation identifier, wherein the plurality of operations are synchronization operations performed on files in the server or the local terminal in the management information system, and the plug-in array is used to store a plurality of plug-ins for executing each operation identifier corresponding operation; determining the file state migration graph based on the triple list and the operation configuration file.
5. The file synchronization method of claim 4, wherein, Determining the file state migration graph based on the triple list and the operation configuration file comprises: determine an initial state transition graph based on the triple list and the operation configuration file; perform a first check on the initial state transition graph based on a state type of a file state in the initial state transition graph, to obtain a first check result, wherein the state type at least includes a first state type and a second state type, and a stability degree of a state corresponding to the first state type is higher than a stability degree of a state corresponding to the second state type in the management information system; perform a second check on the initial state transition graph based on a triple in the triple list in the initial state transition graph, to obtain a second check result; in a case where the first check result and the second check result both indicate that the check is passed, determine the initial state transition graph as the file state transition graph.
6. The file synchronization method of claim 5, wherein, perform a second check on the initial state transition graph based on a triple in the triple list in the initial state transition graph, to obtain a second check result, including: checking whether a number of second target states corresponding to a same initial state and an operation identifier in the triple list is one, to obtain a third check result; checking whether the operation identifier in each triple exists in the operation configuration file, to obtain a fourth check result; determining the second check result according to the third check result and the fourth check result.
7. The file synchronization method of claim 2, wherein, The method further includes: obtaining configuration information of a target operation and a triple corresponding to the target operation, wherein the configuration information of the target operation at least includes a target operation identifier and a plug-in corresponding to the target operation identifier; adding the configuration information of the target operation in an operation configuration file corresponding to the file state transition graph, and adding the triple corresponding to the target operation in a triple list corresponding to the file state transition graph.
8. A file synchronization apparatus characterized by comprising: including: an extraction unit configured to extract a synchronization operation identifier of a synchronization operation in a synchronization request in response to the synchronization request; a finding unit configured to find a target triple related to the synchronization operation and a target plug-in array based on the synchronization operation identifier and a current state of a target file in a management information system, wherein the target triple is used to represent a file state transition path of the target file in the management information system, and the target triple is composed of a current state of the target file, the synchronization operation identifier and a first target state; a processing unit configured to execute plug-ins in the target plug-in array, and update the current state of the target file in the management information system to the first target state in a case where the plug-ins in the target plug-in array are executed successfully, so that an existence state of the target file in the management information system is consistent with that of a local terminal.
9. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a computer program, wherein the computer program controls a device where the computer readable storage medium is located to execute the file synchronization method in any one of claims 1 to 7 when the computer program runs.
10. An electronic device, comprising: An apparatus including one or more processors and memory storing one or more programs for execution by the one or more processors, wherein the one or more programs, when executed by the one or more processors, cause the one or more processors to implement the file synchronization method of any one of claims 1-7. An apparatus including one or more processors and memory storing one or more programs for execution by the one or more processors, wherein the one or more programs, when executed by the one or more processors, cause the one or more processors to implement the file synchronization method of any one of claims 1-7. An apparatus including one or more processors and memory storing one or more programs for execution by the one or more processors, wherein the one or more
Citation Information
Patent Citations
File synchronization method, electronic equipment and synchronization system
CN102346740A
File synchronization method, server and terminal
CN104488248A