File synchronization method and device, equipment and storage medium

By building and comparing file trees and action trees, the problem of low accuracy of file synchronization in offline environments and complex meta information is solved, and efficient and accurate file synchronization operations are achieved.

CN119415486APending Publication Date: 2025-02-11CETC CYBERSPACE SECURITY TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411631523.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-15
Publication Date
2025-02-11

AI Technical Summary

Technical Problem

When operating files in offline environments, the accuracy of file synchronization after networking is very low, and the meta information stored in the file is complicated, resulting in errors in the file synchronization process.

Method used

By obtaining the user's operation information on local files and cloud files based on preset monitoring tools, building a local file tree and cloud file tree, and determining the change information by comparing the current synchronous file tree, building a local action tree, cloud action tree and synchronous action tree to achieve file synchronization operation.

Benefits of technology

Simplify file synchronization operations, improve file synchronization accuracy and program stability, and ensure unified file management on different computer devices.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119415486A_ABST
    Figure CN119415486A_ABST
Patent Text Reader

Abstract

The invention discloses a file synchronization method and device, equipment and a storage medium, and relates to the technical field of computer file management, and the method comprises the steps: obtaining the operation information of a user side on a local file and a cloud file based on a preset monitoring tool; comparing the obtained local file tree with the current synchronous file tree, and constructing a local action tree; the current synchronous file tree is a node tree constructed based on file information determined after a previous file synchronization operation; comparing the obtained cloud file tree with the current synchronous file tree, and constructing a cloud action tree; and constructing a synchronous action tree based on the local action tree and the cloud action tree so as to perform file synchronization operation on the local file and the cloud file through the synchronous action tree. According to the method, the local action tree and the cloud action tree are compared, and then the file synchronization operation is completed according to the obtained synchronization action tree, so that the file synchronization operation is simplified, and the accuracy of a program is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of computer file management, and in particular to a file synchronization method, device, equipment and storage medium. Background Art

[0002] With the increase in files and computer devices, cloud disks are usually used to centrally manage files. When different computer devices use files, they are downloaded from the cloud disk, and the newly added or modified files are uploaded to the cloud disk, realizing the unified management of files on different computer devices. However, when operating files in an offline environment, the accuracy of file synchronization after networking is very low, and the metadata stored in the file is extremely complex. In addition to the basic information of the file, the operations that should be performed when storing the file are also required. This process is prone to errors.

[0003] As can be seen from the above, how to simplify the file synchronization operation while realizing file synchronization is a problem that needs to be solved urgently. Summary of the invention

[0004] In view of this, the purpose of the present invention is to provide a file synchronization method, device, equipment and storage medium, which can simplify the file synchronization operation while realizing file synchronization. The specific scheme is as follows:

[0005] In a first aspect, the present application provides a file synchronization method, comprising:

[0006] Acquire the operation information of the user terminal on the local files and the cloud files based on the preset monitoring tool, and determine the corresponding local file tree and cloud file tree respectively according to the operation information;

[0007] Determine first change information corresponding to the local file by comparing the local file tree with the current synchronization file tree, and construct a corresponding local action tree based on the first change information;

[0008] By comparing the cloud file tree with the current synchronization file tree to determine the second change information corresponding to the cloud file, and constructing a corresponding cloud action tree based on the second change information; the current synchronization file tree is a node tree constructed based on the file information determined after the previous file synchronization operation;

[0009] Corresponding third change information is determined based on the local action tree and the cloud action tree, and a corresponding synchronization action tree is constructed based on the third change information, so as to perform corresponding file synchronization operations on the local file and the cloud file through the synchronization action tree.

[0010] Optionally, the obtaining of operation information of the user terminal on the local file and the cloud file based on a preset monitoring tool, and determining the corresponding local file tree and cloud file tree respectively according to the operation information, includes:

[0011] Based on a preset local monitoring tool, the user terminal's operation on the local file is monitored to obtain corresponding first operation information, and through a preset cloud monitoring tool, the user terminal's operation on the cloud file is monitored to obtain corresponding second operation information;

[0012] A preset ternary model is used to construct a node tree for the first operation information and the second operation information respectively, so as to obtain a corresponding local file tree and a cloud file tree.

[0013] Optionally, comparing the local file tree with the current synchronization file tree to determine first change information corresponding to the local file, and constructing a corresponding local action tree based on the first change information includes:

[0014] By performing hierarchical traversal on the local file tree and the current synchronization file tree, and comparing the first node information corresponding to the same node position in the local file tree and the current synchronization file tree; the first node information includes node status information, node meta information and node operation information;

[0015] If the first node information corresponding to the same node position in the local file tree and the current synchronization file tree changes, the first node information corresponding to the same node position of the local file is determined as the first change information;

[0016] A node tree is constructed based on the preset ternary model and the first change information to obtain a corresponding local action tree.

[0017] Optionally, comparing the cloud file tree with the current synchronization file tree to determine second change information corresponding to the cloud file, and constructing a corresponding cloud action tree based on the second change information includes:

[0018] By performing hierarchical traversal on the cloud file tree and the current synchronization file tree, and comparing the second node information corresponding to the same node position in the cloud file tree and the current synchronization file tree; the second node information includes node status information, node hash value and node operation information;

[0019] If the second node information corresponding to the same node position in the cloud file tree and the current synchronization file tree changes, the second node information corresponding to the same node position of the cloud file is determined as the second change information;

[0020] A node tree is constructed based on the preset ternary model and the second change information to obtain a corresponding cloud action tree.

[0021] Optionally, determining corresponding third change information based on the local action tree and the cloud action tree, and constructing a corresponding synchronization action tree based on the third change information includes:

[0022] By performing hierarchical traversal on the local action tree and the cloud action tree, and comparing third node information corresponding to the target node position in the cloud action tree and the local action tree; the third node information includes node state information and node operation information;

[0023] If the node operation information in the third node information is different, the node corresponding to the target node position is determined as the update node, and the corresponding third change information is determined based on the update node, and then the corresponding synchronization action tree is constructed using the third change information.

[0024] Optionally, performing corresponding file synchronization operations on the local file and the cloud file through the synchronization action tree includes:

[0025] By traversing the synchronous action tree, generating corresponding action execution operations and action conflict operations based on the action conflict nodes and the action execution nodes, and saving the action execution operations and the action conflict operations into a synchronous operation queue;

[0026] Performing corresponding file update operations on the local file and the cloud file based on the action execution operation in the synchronization operation queue to obtain an updated local file and an updated cloud file;

[0027] The updated local file and the updated cloud file are used to perform a corresponding file backup operation on the action conflict operation to complete the file synchronization operation.

[0028] In a second aspect, the present application provides a file synchronization device, comprising:

[0029] An operation information acquisition module is used to acquire the operation information of the user terminal on the local files and the cloud files based on the preset monitoring tool, and determine the corresponding local file tree and cloud file tree respectively according to the operation information;

[0030] A local action tree construction module, configured to determine first change information corresponding to the local file by comparing the local file tree with the current synchronization file tree, and to construct a corresponding local action tree based on the first change information;

[0031] A cloud action tree construction module, used to determine the second change information corresponding to the cloud file by comparing the cloud file tree with the current synchronization file tree, and to construct a corresponding cloud action tree based on the second change information; the current synchronization file tree is a node tree constructed based on the file information determined after the previous file synchronization operation;

[0032] The file synchronization module is used to determine the corresponding third change information based on the local action tree and the cloud action tree, and to construct a corresponding synchronization action tree based on the third change information, so as to perform corresponding file synchronization operations on the local file and the cloud file through the synchronization action tree.

[0033] In a third aspect, the present application provides an electronic device, including:

[0034] Memory, used to store computer programs;

[0035] The processor is used to execute the computer program to implement the aforementioned file synchronization method.

[0036] In a fourth aspect, the present application provides a computer-readable storage medium for storing a computer program, wherein the computer program implements the aforementioned file synchronization method when executed by a processor.

[0037] The present application obtains the operation information of the user terminal on local files and cloud files based on a preset monitoring tool, and determines the corresponding local file tree and cloud file tree respectively through the operation information; determines the first change information corresponding to the local file by comparing the local file tree with the current synchronization file tree, and constructs a corresponding local action tree based on the first change information; the current synchronization file tree is a node tree constructed based on the file information determined after the previous file synchronization operation; determines the second change information corresponding to the cloud file by comparing the cloud file tree with the current synchronization file tree, and constructs a corresponding cloud action tree based on the second change information; determines the corresponding third change information based on the local action tree and the cloud action tree, and constructs a corresponding synchronization action tree based on the third change information, so as to perform corresponding file synchronization operations on the local file and the cloud file through the synchronization action tree. As can be seen from the above, the current synchronization file tree is compared with the local file tree and the cloud file tree respectively to obtain the corresponding first change information and the second change information, and the corresponding local action tree and the cloud action tree are respectively constructed based on the first change information and the second change information, and then the local action tree and the cloud action tree are compared to obtain the corresponding third change information, and finally the corresponding synchronization action tree is constructed based on the third change information, and the corresponding file synchronization operation is performed on the local file and the cloud file through the synchronization action tree, thereby simplifying the file synchronization operation and improving the stability and accuracy of the program. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.

[0039] Figure 1 A flow chart of a file synchronization method disclosed in this application;

[0040] Figure 2 A flowchart of a specific file synchronization method disclosed in this application;

[0041] Figure 3 A comparative schematic diagram of six trees provided for this application;

[0042] Figure 4 An overall flow chart of a file synchronization method provided by this application;

[0043] Figure 5 A structural flow chart of a file synchronization device disclosed in this application;

[0044] Figure 6 This is a structural diagram of an electronic device disclosed in this application. DETAILED DESCRIPTION

[0045] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0046] At present, as the number of files and computer devices increases, cloud disks are usually used to centrally manage files. Files used by different computer devices are downloaded from cloud disks, and files are added or modified before being uploaded to cloud disks, thereby achieving unified management of files on different computer devices. However, when operating files in an offline environment, the accuracy of file synchronization after networking is very low, and the meta information stored in files is extremely complex, which makes the file synchronization process prone to errors. To this end, the present application provides a file synchronization method that can simplify file synchronization operations while achieving file synchronization.

[0047] See also Figure 1 As shown, an embodiment of the present invention discloses a file synchronization method, including:

[0048] Step S11: obtaining the user's operation information on local files and cloud files based on a preset monitoring tool, and determining the corresponding local file tree and cloud file tree respectively through the operation information.

[0049] In this embodiment, in an online situation, based on a preset local monitoring tool, the first operation information of the user terminal on the local file is monitored in real time, the first operation information includes but is not limited to addition, deletion and modification, and then the first operation information obtained is passed to a preset scanning tool, and the local file system is scanned based on the preset scanning tool and the first operation information to obtain a corresponding scanning result, and the corresponding local file tree is constructed using the scanning result and the preset ternary model. It can be understood that the local file and the corresponding first operation information are scanned through the system interface using the preset scanning tool, including the file name, creation time, modification time and file size, and then the preset ternary model is used to construct a tree structure to obtain the corresponding local file tree.

[0050] Correspondingly, based on the preset cloud monitoring tool, the second operation information of the user terminal on the cloud file is monitored in real time, and the cloud file and the corresponding second operation information are scanned by the preset scanning tool and through the server interface, including the file name, creation time, modification time, file size and hash value, etc., and then the preset ternary model is used to construct the tree structure to obtain the corresponding cloud file tree. Specifically, the preset monitoring tool is used to obtain the user terminal's operation information on local files and cloud files, and the corresponding local file tree and cloud file tree are determined respectively by the operation information, including: based on the preset local monitoring tool, the user terminal's operation on the local file is monitored to obtain the corresponding first operation information, and the preset cloud monitoring tool is used to monitor the user terminal's operation on the cloud file to obtain the corresponding second operation information; the preset ternary model is used to construct the node tree of the first operation information and the second operation information respectively to obtain the corresponding local file tree and cloud file tree.

[0051] Step S12: Determine the first change information corresponding to the local file by comparing the local file tree with the current synchronization file tree, and construct a corresponding local action tree based on the first change information; the current synchronization file tree is a node tree constructed based on the file information determined after the previous file synchronization operation.

[0052] In this embodiment, after the last file synchronization operation is completed, the database is updated based on the file information after the file synchronization operation is completed, and the file information after the synchronization is completed is obtained through the database, including the file name, creation time, modification time, file size and hash value, etc., and a tree is constructed for the file information after the synchronization is completed using a preset ternary model to obtain a corresponding current synchronized file tree, and then the local file tree is compared with the current synchronized file tree to obtain the first change information corresponding to the local file, and a tree is constructed using the preset ternary model and the first change information to obtain a corresponding local file tree. Specifically, the method of comparing the local file tree with the current synchronization file tree to determine the first change information corresponding to the local file, and constructing a corresponding local action tree based on the first change information, includes: hierarchically traversing the local file tree and the current synchronization file tree, and comparing the first node information corresponding to the same node position in the local file tree and the current synchronization file tree; the first node information includes node status information, node meta information and node operation information; if the first node information corresponding to the same node position in the local file tree and the current synchronization file tree changes, the first node information corresponding to the local file at the same node position is determined as the first change information; and constructing a node tree based on a preset ternary model and the first change information to obtain a corresponding local action tree.

[0053] It is understandable that the local file tree and the current synchronization file tree are hierarchically traversed to compare whether the file nodes corresponding to the same node positions in the local file tree and the current synchronization file tree exist. If the node of the local file tree exists but the node of the synchronization file tree does not exist, it is considered that a new file has been added locally; if the node of the local file tree does not exist but the node of the synchronization file tree exists, it is considered that the file has been deleted locally; if the nodes of the local file tree and the cloud file tree both exist, the meta information of the nodes is compared, including the file modification time and size. If the meta information is different, it is considered that the file has been updated locally. After the comparison is completed, a local action tree is generated to record the changes in local files.

[0054] Step S13: Determine the second change information corresponding to the cloud file by comparing the cloud file tree with the current synchronization file tree, and construct a corresponding cloud action tree based on the second change information.

[0055] In this embodiment, the second change information of the cloud file tree relative to the current synchronization file tree is determined by comparing the cloud file tree with the current synchronization file tree, and a tree is constructed using a preset ternary model and the second change information to obtain a corresponding cloud action tree. Specifically, the second change information corresponding to the cloud file is determined by comparing the cloud file tree with the current synchronization file tree, and a corresponding cloud action tree is constructed based on the second change information, including: hierarchically traversing the cloud file tree and the current synchronization file tree, and comparing the second node information corresponding to the same node position in the cloud file tree and the current synchronization file tree; the second node information includes node status information, node hash value and node operation information; if the second node information corresponding to the same node position in the cloud file tree and the current synchronization file tree changes, the second node information corresponding to the cloud file at the same node position is determined as the second change information; and a node tree is constructed based on the preset ternary model and the second change information to obtain a corresponding cloud action tree.

[0056] It is understandable that the cloud file tree and the synchronization file tree are hierarchically traversed to compare whether the file nodes corresponding to the same node positions in the cloud file tree and the synchronization file tree exist. If the node of the cloud file tree exists but the node of the synchronization file tree does not exist, it is considered that a new file has been added to the cloud; if the node of the cloud file tree does not exist but the node of the synchronization file tree exists, it is considered that the file has been deleted from the cloud; if the nodes of the cloud file tree and the synchronization file tree both exist, the hash values ​​of the nodes are compared. If the hash values ​​are different, it is considered that the file has been updated in the cloud. If the hash values ​​are the same and the nodes corresponding to the same node positions in the cloud file tree and the synchronization file tree are both folders, then the node is no longer compared downward hierarchically, thereby speeding up the comparison efficiency. After the comparison is completed, a cloud action tree is generated to record the changes in the cloud files.

[0057] Step S14: determining corresponding third change information based on the local action tree and the cloud action tree, and constructing a corresponding synchronization action tree based on the third change information, so as to perform corresponding file synchronization operations on the local file and the cloud file through the synchronization action tree.

[0058] In this embodiment, the local action tree and the cloud action tree are hierarchically traversed and merged. Based on the premise of user data first, the way of merging actions is abstracted into the following preset merging formula, which is as follows:

[0059] Add / Delete / Update + No Action = Add / Delete / Update;

[0060] Add + Add = No action / Conflict Rename Save Copy;

[0061] delete + delete = delete;

[0062] delete + update = update;

[0063] Update + Update = No Action / Conflict Rename Save Copy;

[0064] The two sides of the plus sign represent local actions and cloud actions, and their directions are interchangeable. The part after the equal sign is the result of the merged action. The executor is the end of the merged operation. That is, when the action of the target end is merged, the target end is the executor of the action. If there is a conflict, both ends must perform the action.

[0065] It is understandable that by comparing the third node information corresponding to the target node position in the local action tree and the cloud action, the corresponding third change information can be determined based on the comparison result of the third node information obtained, and then the corresponding synchronous action tree can be constructed using the third change information and the preset ternary model.

[0066] As can be seen from the above, the current synchronization file tree is compared with the local file tree and the cloud file tree respectively to obtain the corresponding first change information and the second change information, and the corresponding local action tree and the cloud action tree are respectively constructed based on the first change information and the second change information, and then the local action tree and the cloud action tree are compared to obtain the corresponding third change information, and finally the corresponding synchronization action tree is constructed based on the third change information, and the corresponding file synchronization operation is performed on the local file and the cloud file through the synchronization action tree, thereby simplifying the file synchronization operation and improving the stability and accuracy of the program.

[0067] As can be seen from the above embodiments, the present application obtains a synchronization action tree based on the comparison between the local action tree and the cloud action tree, and performs corresponding file synchronization operations on the local file and the cloud file based on the synchronization action tree. Therefore, the construction and use of the synchronization action tree are described.

[0068] See also Figure 2 As shown, the embodiment of the present invention discloses a specific file synchronization method, including:

[0069] Step S21: obtaining the user's operation information on the local files and the cloud files based on the preset monitoring tool, and determining the corresponding local file tree and cloud file tree respectively through the operation information.

[0070] Step S22: Determine the first change information corresponding to the local file by comparing the local file tree with the current synchronization file tree, and construct a corresponding local action tree based on the first change information; the current synchronization file tree is a node tree constructed based on the file information determined after the previous file synchronization operation.

[0071] Step S23, hierarchically traverse the local action tree and the cloud action tree, and compare the third node information corresponding to the target node position in the cloud action tree and the local action tree; the third node information includes node status information and node operation information.

[0072] In this embodiment, the local action tree and the cloud action tree are hierarchically traversed, and the third node information corresponding to the target node position where the action change occurs in the cloud action tree and the local action tree is compared. Specifically, it is determined whether the node state information in the third node information is the same, and whether the node operation information in the third node information is the same. Based on the comparison of the third node information corresponding to the target node position in the cloud action tree and the local action tree, a corresponding comparison result is obtained.

[0073] Step S24: If the node state information in the third node information is the same and the node operation information is different, the update node corresponding to the target node position is determined as an action conflict node.

[0074] In this embodiment, if the node status information of the local action tree and the cloud action both exist, that is, the nodes corresponding to the target node positions of the local action tree and the cloud action both exist, but the node operation information of the local action tree and the cloud action tree is different, then the update node corresponding to the target node position is determined to be an action conflict node. In a specific implementation, the nodes corresponding to the target node positions of the local action tree and the cloud action both exist and are newly added files, but the file contents of the newly added files corresponding to the target node position of the local action tree and the newly added files corresponding to the target node position of the cloud action tree are inconsistent, which indicates that the update node corresponding to the target node position is an action conflict node.

[0075] In another specific implementation, the nodes corresponding to the target node positions of the local action tree and the cloud action tree both exist and are update files, but the file contents of the update file corresponding to the target node position of the local action tree and the update file corresponding to the target node position of the cloud action tree are inconsistent, indicating that the update node corresponding to the target node position is an action conflict node.

[0076] Step S25: If the node status information and the node operation information in the third node information are different, the update node corresponding to the target node position is determined as the action execution node, and the corresponding third change information is determined based on the action conflict node and the action execution node, and then the corresponding synchronization action tree is constructed using the third change information.

[0077] In this embodiment, the update node corresponding to the target node position is determined based on judging the node status information and the node operation information in the third node information, the corresponding third change information is determined based on the action execution information of the update node, and the synchronization action tree is constructed using the third change information and the preset ternary model. In a specific embodiment, the update node corresponding to the target node position on the local action tree is a newly added file, and there is no update node corresponding to the target node position in the cloud action tree, then the update node corresponding to the target node position of the synchronization action tree is a newly added file; in another embodiment, the update node corresponding to the target node position on the local action tree is an update file, and the update node corresponding to the target node position on the cloud action tree is a deleted file, then the update node corresponding to the target node position of the synchronization action tree is an update file. It should be pointed out that the update node includes update files, deleted files and newly added files.

[0078] Step S26: traverse the synchronous action tree, generate corresponding action execution operations and action conflict operations based on the action conflict nodes and the action execution nodes, and save the action execution operations and the action conflict operations into a synchronous operation queue.

[0079] In this embodiment, when traversing the synchronous action tree, the action conflict nodes and action execution nodes in the synchronous action tree can be extracted according to different traversal algorithms, and the action conflict nodes and the action execution nodes are placed in a preset node queue for execution. Based on the hierarchical traversal, in a specific implementation, when encountering the action execution node, the action execution node is a new or deleted action, and a pre-order traversal method can be adopted, that is, first traverse the root node, then traverse the left subtree corresponding to the root node, and then traverse the right subtree corresponding to the root node; in another specific implementation, the action execution node is an update action, and a post-order traversal method can be adopted, that is, first traverse the left subtree, then traverse the right subtree, and then traverse the root nodes corresponding to the left subtree and the right subtree. It can be understood that the action execution operation and the action conflict operation generated by the action conflict node and the action execution node are saved in the synchronous operation queue.

[0080] Step S27: performing corresponding file update operations on the local file and the cloud file based on the action execution operation in the synchronization operation queue to obtain an updated local file and an updated cloud file.

[0081] In this embodiment, when there is an action execution operation in the synchronization operation queue, a piece of information corresponding to the action execution operation is obtained from the synchronization operation queue to perform corresponding file update operations on the local file and the cloud file. In a specific implementation, if the action execution operation is to add a new file, based on the new node position corresponding to the new file in the synchronization action tree, a corresponding file update operation is performed at the node position corresponding to the new node position in the local file and the cloud file to obtain the updated local file and the updated cloud file.

[0082] Step S28: Use the updated local file and the updated cloud file to perform a corresponding file backup operation on the action conflict operation to complete the file synchronization operation.

[0083] In this embodiment, a file backup operation is performed on the updated local file and the updated cloud file based on the action conflict operation. Specifically, the file information on the conflict node corresponding to the action conflict operation in the updated cloud file is saved to the conflict node corresponding to the action conflict operation in the updated local file. Similarly, the file information on the conflict node corresponding to the action conflict operation in the updated local file is saved to the conflict node corresponding to the action conflict operation in the updated cloud file to complete the corresponding file synchronization operation. It can be understood that if an action conflict occurs at a node, the user end can decide which node to leave between the two nodes where the action conflict occurs, and build a new synchronization file tree based on the remaining nodes.

[0084] Among them, the specific implementation process of the above steps S21 and S22 can refer to the corresponding content in the above embodiments, and will not be repeated here.

[0085] As can be seen from the above, by performing hierarchical traversal on the local action tree and the cloud action tree, and comparing the third node information corresponding to the target node position obtained based on the traversal, the node status information and the node operation information are judged on the third node information to obtain the third change information, and the synchronization action tree is constructed using the third change information, and then the synchronization action tree is traversed to obtain corresponding action execution operations and action conflict operations, and then the file synchronization operation is completed based on the action execution operation and the action conflict operation, thereby simplifying the steps of performing the file synchronization operation and improving the stability of the program.

[0086] See also Figure 3As shown, an embodiment of the present invention provides a comparison diagram of six trees. In this embodiment, + is used to represent a newly added file, - is used to represent a deleted file, ' is used to represent an updated file, and # is used to represent a file conflict. In order to improve the accuracy of the comparison, the branch nodes can be compared first, and the root node can be determined by the branch nodes. The first comparison is the comparison between the local file tree and the current synchronization file tree. If there is a C1 node in the current synchronization file tree, but there is no C1 node in the local file tree, it proves that the file has been deleted locally, so the C1 node in the local action tree is C1-. If there is a C2 node in the current synchronization file tree, and there is a C2' node in the local file tree, it proves that the file has been updated locally, so the C2 node in the local action tree is C2'. If there is a C3 node in the current synchronization file tree, but there is no C3 node in the local file tree, it proves that the file has been deleted locally, so the C3 node in the local action tree is C3-. Because the B1 node is the root node of C1, C2, and C3, when C1, C2, and C3 change, the B1 node in the local action tree needs to be updated, that is, B1'. There is a C4 node in the current synchronization file tree, and there is a C4' node in the local file tree, which proves that the file has been updated locally, so the C4 node in the local action tree is C4'. There is no C5 node in the current synchronization action tree, and there is a C5+ node in the local file tree, which proves that a new file has been added locally, so the C5 node in the local action tree is C5+. Because B2 is the root node of C4 and C5, when C4 and C5 change, the B2 node in the local action tree needs to be updated, that is, B2'. Because A1 is the root node of B1 and B2, when B1 and B2 change, the A1 node in the local action tree needs to be updated, that is, A1'.

[0087] The second comparison is the comparison between the current synchronization action tree and the cloud file tree. If there is a C1 node in the current synchronization file tree, but there is no C1 node in the cloud file tree, it proves that the cloud has deleted the file, so the C1 node in the cloud action tree is C1-. There are C2 nodes and C3 nodes in the current synchronization file tree, and there are also C2 nodes and C3 nodes in the cloud file tree, and neither C2 node nor C3 node has changed, so there is no C2 node and C3 node in the cloud action tree; because B1 is the root node of C1, C2, and C3, when C1 changes, the B1 node in the local action tree needs to be updated, that is, B1'. There is a C4 node in the current synchronization file tree, but there is no C4 node in the cloud file tree, which proves that the cloud has deleted the file, so the C4 node in the cloud action tree is C4-. There is no C5 node in the current synchronization file tree, but there is a C5+ node in the cloud file tree, which proves that a new file has been added to the cloud, so the C5 node in the cloud action tree is C5+. Because the B2 node is the root node of C4 and C5, when C4 and C5 change, the B2 node in the cloud action tree needs to be updated, that is, B2'. The B3 node does not exist in the current synchronization file tree, but the B3+ node exists in the cloud file tree, which proves that the cloud has added files, so the B3 node in the cloud action tree needs to be updated, that is, B3'. Because A1 is the root node of B1, B2, and B3, when B1, B2, and B3 change, the A1 node in the cloud action tree needs to be updated, that is, A1'.

[0088] The third comparison is the comparison between the local action tree and the cloud action tree. The C1 node in the local action tree is a C1-node, and the C1 node corresponding to the cloud action tree is also a C1-node. The node operation information at the same node position is the same, which proves that the C1 node has no action, so the C1 node is not displayed in the synchronization action tree. The C2 node in the local action tree is a C2' node, and the C2 node does not exist in the cloud action tree, which proves that the file has been updated locally, so the C2 node in the synchronization action tree needs to be updated, that is, C2'. The C3 node in the local action tree is a C3-node, and the C3 node does not exist in the cloud action tree, which proves that the file has been deleted locally, so the C3 node in the synchronization action tree needs to be updated, that is, C3'. Because B1 is the root node of C1, C2, and C3, when C1, C2, and C3 change, the B1 node in the synchronization action tree needs to be updated, that is, B1'. The C4 node in the local action tree is a C4' node, and the C4 node corresponding to the cloud action tree is a C4- node. Because the node operation information of the local action tree and the cloud action tree is different, the C4 node of the synchronization action tree is an update node, that is, C4'. The C5 node in the local action tree is a C5+ node, and the C5 node in the cloud action tree is also a C5+ node, which proves that files have been added locally and in the cloud, but because the content of the added files is different, that is, the node status information of the C5 node is the same, but the node operation information is different, the C5 node is determined as an action conflict point, so the C5 node in the synchronization action tree is a C5# node. Since the C5 node is an action conflict node, it is necessary to perform corresponding file backup operations on the action conflict operations corresponding to the action conflict node for the updated local file and the updated cloud file. Because the B2 node is the root node of C4 and C5, when C4 and C5 change, the B2 node in the synchronization action tree needs to be updated, that is, B2'. The B3 node does not exist in the local action tree, and the B3 node in the cloud action tree is the B3+ node, which proves that the cloud has added a file, so the B3 node in the synchronization action tree is B3+. A1 is the root node of B1, B2, and B3, so when B1, B2, and B3 change, the A1 node in the synchronization action tree needs to be updated, that is, A1'.

[0089] See also Figure 4 As shown, an embodiment of the present invention provides an overall flow chart of a file synchronization method, including:

[0090] The user end performs corresponding first and second file operations on the local file and the cloud file respectively, and uses a preset monitoring tool to monitor the first and second file operations respectively to obtain corresponding first operation information and second operation information, and then uses a preset scanning tool to scan the first and second operation information respectively, and constructs a local file tree and a cloud file tree based on the scanned file data and using a preset ternary model. During the scanning, the file information after the last file synchronization operation is completed is obtained from the database, and a synchronization file tree is constructed based on the preset ternary model. The synchronization file is compared with the local file tree and the cloud file tree respectively, and a corresponding local action tree and a cloud action tree are generated based on the first comparison result and the preset ternary model. Then, the local action tree and the cloud action tree are compared, and a corresponding synchronization action tree is generated based on the second comparison result and the preset ternary model. The synchronization action tree is traversed to obtain corresponding file synchronization information, and the file synchronization information is notified to the user end. Then, the file synchronization information is used to perform corresponding file synchronization operations on the local file and the cloud file, and the obtained execution result is notified to the user end.

[0091] Accordingly, see Figure 5 As shown, the present application also provides a file synchronization device, including:

[0092] An operation information acquisition module 11 is used to acquire the operation information of the user terminal on the local file and the cloud file based on a preset monitoring tool, and determine the corresponding local file tree and cloud file tree respectively according to the operation information;

[0093] A local action tree construction module 12 is used to determine the first change information corresponding to the local file by comparing the local file tree with the current synchronization file tree, and to construct a corresponding local action tree based on the first change information; the current synchronization file tree is a node tree constructed based on the file information determined after the previous file synchronization operation;

[0094] A cloud action tree construction module 13, configured to determine second change information corresponding to the cloud file by comparing the cloud file tree with the current synchronization file tree, and to construct a corresponding cloud action tree based on the second change information;

[0095] The file synchronization module 14 is used to determine corresponding third change information based on the local action tree and the cloud action tree, and to construct a corresponding synchronization action tree based on the third change information, so as to perform corresponding file synchronization operations on the local file and the cloud file through the synchronization action tree.

[0096] As can be seen from the above, the current synchronization file tree is compared with the local file tree and the cloud file tree respectively to obtain the corresponding first change information and the second change information, and the corresponding local action tree and the cloud action tree are respectively constructed based on the first change information and the second change information, and then the local action tree and the cloud action tree are compared to obtain the corresponding third change information, and finally the corresponding synchronization action tree is constructed based on the third change information, and the corresponding file synchronization operation is performed on the local file and the cloud file through the synchronization action tree, thereby simplifying the file synchronization operation and improving the stability and accuracy of the program.

[0097] In some specific implementations, the operation information acquisition module 11 may specifically include:

[0098] A file monitoring unit, configured to monitor the operation of the user terminal on the local file based on a preset local monitoring tool to obtain corresponding first operation information, and to monitor the operation of the user terminal on the cloud file through a preset cloud monitoring tool to obtain corresponding second operation information;

[0099] The file tree construction unit is used to construct a node tree for the first operation information and the second operation information respectively by using a preset ternary model to obtain a corresponding local file tree and a cloud file tree.

[0100] In some specific implementations, the local action tree construction module 12 may specifically include:

[0101] A first node information comparison unit is used to perform hierarchical traversal on a local file tree and a current synchronization file tree, and compare first node information corresponding to the same node position in the local file tree and the current synchronization file tree; the first node information includes node status information, node meta information and node operation information;

[0102] A first change information determining unit, configured to determine the first node information of the local file corresponding to the same node position in the local file tree and the current synchronization file tree as the first change information if the first node information corresponding to the same node position in the local file tree and the current synchronization file tree changes;

[0103] The local action tree construction unit is used to construct a node tree based on a preset ternary model and the first change information to obtain a corresponding local action tree.

[0104] In some specific implementations, the cloud action tree construction module 13 may specifically include:

[0105] A second node information comparison unit is used to perform hierarchical traversal on the cloud file tree and the current synchronization file tree, and compare the second node information corresponding to the same node position in the cloud file tree and the current synchronization file tree; the second node information includes node status information, node hash value and node operation information;

[0106] A second change information determining unit, configured to determine the second node information corresponding to the same node position in the cloud file tree and the current synchronization file tree as the second change information if the second node information corresponding to the same node position in the cloud file tree and the current synchronization file tree changes;

[0107] The cloud action tree construction unit is used to construct a node tree based on the preset ternary model and the second change information to obtain a corresponding cloud action tree.

[0108] In some specific implementations, the file synchronization module 14 may specifically include:

[0109] A third node information comparison unit, configured to perform hierarchical traversal on the local action tree and the cloud action tree, and compare third node information corresponding to the target node position in the cloud action tree and the local action tree; the third node information includes node state information and node operation information;

[0110] A synchronization action tree construction unit is used to determine the node corresponding to the target node position as an update node if the node operation information in the third node information is different, and determine the corresponding third change information based on the update node, and then use the third change information to construct a corresponding synchronization action tree.

[0111] In some specific implementations, the file synchronization module 14 may specifically include:

[0112] a conflict node determination unit, configured to determine the update node corresponding to the target node position as an action conflict node if the node state information in the third node information is the same and the node operation information is different;

[0113] The execution node determination unit is used to determine the update node corresponding to the target node position as the action execution node if the node state information and the node operation information in the third node information are different.

[0114] In some specific implementations, the file synchronization module 14 may specifically include:

[0115] An operation saving unit, configured to traverse the synchronous action tree, generate corresponding action execution operations and action conflict operations based on the action conflict nodes and the action execution nodes, and save the action execution operations and the action conflict operations into a synchronous operation queue;

[0116] A file updating unit, configured to perform corresponding file updating operations on the local file and the cloud file based on the action execution operation in the synchronization operation queue, so as to obtain an updated local file and an updated cloud file;

[0117] The file backup unit is used to perform a corresponding file backup operation on the action conflict operation by using the updated local file and the updated cloud file to complete the file synchronization operation.

[0118] Furthermore, the present application also discloses an electronic device. Figure 6 This is a structural diagram of an electronic device 20 according to an exemplary embodiment, and the content in the figure cannot be regarded as any limitation on the scope of use of this application. The electronic device 20 may specifically include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 is used to store a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the file synchronization method disclosed in any of the aforementioned embodiments. In addition, the electronic device 20 in this embodiment may specifically be an electronic computer.

[0119] In this embodiment, the power supply 23 is used to provide working voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and the external device, and the communication protocol it follows is any communication protocol that can be applied to the technical solution of the present application, and is not specifically limited here; the input and output interface 25 is used to obtain external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs and is not specifically limited here.

[0120] In addition, the memory 22 as a carrier for resource storage may be a read-only memory, a random access memory, a disk or an optical disk, etc. The resources stored thereon may include an operating system 221, a computer program 222, etc., and the storage method may be temporary storage or permanent storage.

[0121] The operating system 221 is used to manage and control the hardware devices and computer programs 222 on the electronic device 20, and may be Windows Server, Netware, Unix, Linux, etc. In addition to the computer program that can be used to complete the file synchronization method performed by the electronic device 20 disclosed in any of the aforementioned embodiments, the computer program 222 may further include computer programs that can be used to complete other specific tasks.

[0122] Furthermore, the present application also discloses a computer-readable storage medium for storing a computer program; wherein the computer program, when executed by a processor, implements the aforementioned disclosed file synchronization method. The specific steps of the method can refer to the corresponding contents disclosed in the aforementioned embodiments, and will not be repeated here.

[0123] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.

[0124] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0125] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.

[0126] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.

[0127] The technical solution provided by the present application is introduced in detail above. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for general technicians in this field, according to the idea of ​​the present application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.

Claims

1. A file synchronization method, characterized in that: include: Acquire the operation information of the user terminal on the local files and the cloud files based on the preset monitoring tool, and determine the corresponding local file tree and cloud file tree respectively according to the operation information; By comparing the local file tree with the current synchronization file tree to determine the first change information corresponding to the local file, and building a corresponding local action tree based on the first change information; the current synchronization file tree is a node tree built based on the file information determined after the previous file synchronization operation; Determine second change information corresponding to the cloud file by comparing the cloud file tree with the current synchronization file tree, and construct a corresponding cloud action tree based on the second change information; Corresponding third change information is determined based on the local action tree and the cloud action tree, and a corresponding synchronization action tree is constructed based on the third change information, so as to perform corresponding file synchronization operations on the local file and the cloud file through the synchronization action tree.

2. The file synchronization method according to claim 1, characterized in that: The method of obtaining operation information of the user terminal on the local file and the cloud file based on the preset monitoring tool, and determining the corresponding local file tree and cloud file tree respectively according to the operation information, includes: Based on a preset local monitoring tool, the user terminal's operation on the local file is monitored to obtain corresponding first operation information, and through a preset cloud monitoring tool, the user terminal's operation on the cloud file is monitored to obtain corresponding second operation information; A preset ternary model is used to construct a node tree for the first operation information and the second operation information respectively, so as to obtain a corresponding local file tree and a cloud file tree.

3. The file synchronization method according to claim 1 or 2, characterized in that: The step of comparing the local file tree with the current synchronization file tree to determine the first change information corresponding to the local file, and constructing a corresponding local action tree based on the first change information includes: By performing hierarchical traversal on the local file tree and the current synchronization file tree, and comparing the first node information corresponding to the same node position in the local file tree and the current synchronization file tree; the first node information includes node status information, node meta information and node operation information; If the first node information corresponding to the same node position in the local file tree and the current synchronization file tree changes, the first node information corresponding to the same node position of the local file is determined as the first change information; A node tree is constructed based on the preset ternary model and the first change information to obtain a corresponding local action tree.

4. The file synchronization method according to claim 3, characterized in that: The step of comparing the cloud file tree with the current synchronization file tree to determine the second change information corresponding to the cloud file, and constructing a corresponding cloud action tree based on the second change information includes: By performing hierarchical traversal on the cloud file tree and the current synchronization file tree, and comparing the second node information corresponding to the same node position in the cloud file tree and the current synchronization file tree; the second node information includes node status information, node hash value and node operation information; If the second node information corresponding to the same node position in the cloud file tree and the current synchronization file tree changes, the second node information corresponding to the same node position of the cloud file is determined as the second change information; A node tree is constructed based on the preset ternary model and the second change information to obtain a corresponding cloud action tree.

5. The file synchronization method according to claim 4, characterized in that: The determining corresponding third change information based on the local action tree and the cloud action tree, and constructing a corresponding synchronization action tree based on the third change information, includes: By performing hierarchical traversal on the local action tree and the cloud action tree, and comparing third node information corresponding to the target node position in the cloud action tree and the local action tree; the third node information includes node state information and node operation information; If the node operation information in the third node information is different, the node corresponding to the target node position is determined as the update node, and the corresponding third change information is determined based on the update node, and then the corresponding synchronization action tree is constructed using the third change information.

6. The file synchronization method according to claim 5, characterized in that: If the third node operation information is different, determining the node corresponding to the target node position as the update node includes: If the node state information in the third node information is the same and the node operation information is different, determining the update node corresponding to the target node position as the action conflict node; If the node state information and the node operation information in the third node information are different, the update node corresponding to the target node position is determined as the action execution node.

7. The file synchronization method according to claim 6, characterized in that: The performing corresponding file synchronization operations on the local file and the cloud file through the synchronization action tree includes: By traversing the synchronous action tree, generating corresponding action execution operations and action conflict operations based on the action conflict nodes and the action execution nodes, and saving the action execution operations and the action conflict operations into a synchronous operation queue; Performing corresponding file update operations on the local file and the cloud file based on the action execution operation in the synchronization operation queue to obtain an updated local file and an updated cloud file; The updated local file and the updated cloud file are used to perform a corresponding file backup operation on the action conflict operation to complete the file synchronization operation.

8. A file synchronization device, characterized in that: include: An operation information acquisition module is used to acquire the operation information of the user terminal on the local files and the cloud files based on the preset monitoring tool, and determine the corresponding local file tree and cloud file tree respectively according to the operation information; A local action tree construction module, configured to determine first change information corresponding to the local file by comparing the local file tree with the current synchronization file tree, and to construct a corresponding local action tree based on the first change information; the current synchronization file tree is a node tree constructed based on the file information determined after the previous file synchronization operation; A cloud action tree construction module, configured to determine second change information corresponding to the cloud file by comparing the cloud file tree with the current synchronization file tree, and to construct a corresponding cloud action tree based on the second change information; The file synchronization module is used to determine the corresponding third change information based on the local action tree and the cloud action tree, and to construct a corresponding synchronization action tree based on the third change information, so as to perform corresponding file synchronization operations on the local file and the cloud file through the synchronization action tree.

9. An electronic device, characterized in that: include: Memory, used to store computer programs; A processor, configured to execute the computer program to implement the steps of the file synchronization method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: Used to store a computer program, wherein when the computer program is executed by a processor, the steps of the file synchronization method according to any one of claims 1 to 7 are implemented.