File synchronization method and device based on synchronization check point and computer equipment

By using checkpoints to record synchronization progress during file synchronization, the problem of rescanning the file list after file synchronization is solved in the prior art, and quickly synchronizing changed files is achieved, saving time and CPU resources.

CN119396790APending Publication Date: 2025-02-07杭州美创科技股份有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311263991.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-09-28
Publication Date
2025-02-07

AI Technical Summary

Technical Problem

The existing file synchronization method lacks the mechanism to record the synchronization location when synchronizing multiple files, resulting in the need to rescan the file list when recovering after a server failure, which is time-consuming and CPU-consuming.

Method used

Using a file synchronization method based on synchronization checkpoints, the file synchronization progress is recorded by obtaining and loading checkpoint files, and when resynchronizing, the checkpoint files are compared with the properties of the checkpoint files and the folder sorting results, and the elements that need to be synchronized are determined to avoid duplication. synchronous.

Benefits of technology

In an unstable file synchronization environment, the cost of synchronization is reduced, and the files that are rapidly synchronized are realized, saving time and CPU resources, and avoiding repeated comparison of hash values ​​of synchronized files.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119396790A_ABST
    Figure CN119396790A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a file synchronization method and device based on a synchronization check point and computer equipment. The method comprises the following steps: when a system performs file synchronization, obtaining a check point file; judging whether the check point file exists or not; if the check point file exists, loading the check point file; scanning folders needing to be synchronized, and sorting the folders needing to be synchronized to obtain a sorting result; comparing the sorting results with the check point files one by one to determine elements needing to be synchronized; judging whether the element needing to be synchronized is a file or not; if the element needing to be synchronized is a file, file synchronization is conducted, and the check point file is updated. And if the element needing to be synchronized is not the file, scanning the folder needing to be synchronized, and sorting the folder needing to be synchronized to obtain a sorting result. By implementing the method provided by the embodiment of the invention, the changing file can be quickly synchronized, and time and a CPU (Central Processing Unit) can be saved when the file which is interrupted to be synchronized is synchronized again.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to a file synchronization method, and more specifically to a file synchronization method, device and computer equipment based on synchronization checkpoints. Background Art

[0002] File synchronization refers to the process of copying files in the operating system from one computer to another, making the file contents consistent across multiple computers.

[0003] There are three ways to synchronize multiple files in the existing file synchronization methods. The first is to sort by the file names of the files to be synchronized; the second is to sort by the file sizes to be synchronized; the third is to use a random order; the existing methods do not record the synchronization position, that is, the checkpoint method, when synchronizing files. When the server fails and then recovers, such as in power outages and other scenarios, when the synchronization program is restarted, it is necessary to rescan to determine the list of files to be synchronized and resynchronize from the beginning of the file list, which is both time-consuming and CPU-consuming. Although there are some solutions that divide files into blocks and compare hash values ​​for file synchronization, when the synchronization of multiple files is not completed, restarting the file synchronization program will not synchronize the file data, but will still compare the hash values ​​of the files that have been synchronized, which is both time-consuming and CPU-consuming.

[0004] Therefore, it is necessary to design a new method to achieve fast synchronization of changed files, which can save time and CPU when resynchronizing files that have been interrupted. Summary of the invention

[0005] The purpose of the present invention is to overcome the defects of the prior art and provide a file synchronization method, device and computer equipment based on synchronization checkpoints.

[0006] To achieve the above object, the present invention adopts the following technical solution: a file synchronization method based on synchronization checkpoints, comprising:

[0007] When the system performs file synchronization, obtain the checkpoint file;

[0008] Determine whether the checkpoint file exists;

[0009] If the checkpoint file exists, load the checkpoint file;

[0010] Scan the folders that need to be synchronized, and sort the folders that need to be synchronized to obtain sorting results;

[0011] Compare the sorting result with the checkpoint file one by one to determine the elements that need to be synchronized;

[0012] Determine whether the element to be synchronized is a file;

[0013] If the element to be synchronized is a file, the file is synchronized and the checkpoint file is updated.

[0014] If the element to be synchronized is not a file, the scanning of the folders to be synchronized is performed, and the folders to be synchronized are sorted to obtain a sorting result.

[0015] A further technical solution is: loading the checkpoint file includes:

[0016] Gets the synchronized folder path attribute, synchronized folder time attribute, synchronized file path attribute, and synchronized file time attribute in the checkpoint file.

[0017] Its further technical solution is: after determining whether the checkpoint file exists, it also includes:

[0018] If the checkpoint file does not exist, create a new checkpoint file, set the folder location attribute in the checkpoint file to the synchronization folder path, and set the folder time attribute to the modification time of the synchronization folder; set the file location attribute to null, and set the file time attribute to null;

[0019] Scan the folders that need to be synchronized and sort the folders that need to be synchronized;

[0020] The files in the sorted folders are synchronized, and checkpoints are recorded to update the checkpoint files.

[0021] A further technical solution is: scanning the folders to be synchronized and sorting the folders to be synchronized to obtain a sorting result includes:

[0022] Scan the folder path that needs to be synchronized to obtain the list of files and folders to be synchronized;

[0023] The list of files and folders to be synchronized is sorted in ascending order by modification time, and then in ascending order by file name to obtain the sorting result.

[0024] A further technical solution is: comparing the sorting result with the checkpoint file one by one to determine the elements that need to be synchronized, including:

[0025] Taking an element from the first position in the sorted result, and removing the taken element from the sorted result;

[0026] Determine whether the value corresponding to the synchronized folder path attribute contains or is equal to the file path of the retrieved element;

[0027] If the value corresponding to the synchronized folder path attribute does not contain and is not equal to the file path of the extracted element, determine whether the upper folder path of the extracted element is equal to the value corresponding to the synchronized folder path attribute;

[0028] If the upper folder path of the retrieved element is equal to the value corresponding to the synchronized folder path attribute, then the modification time of the retrieved element is compared with the value corresponding to the synchronized file time attribute to determine the element that needs to be synchronized;

[0029] If the upper folder path of the retrieved element is not equal to the value corresponding to the synchronized folder path attribute, the first two branch paths of the two paths are obtained by combining the value of the synchronized folder path attribute and the path of the folder where the element is located;

[0030] Based on the comparison of the initial branch path times of the two paths, the elements that need to be synchronized are determined.

[0031] A further technical solution is: comparing the value corresponding to the synchronized file time attribute with the modification time of the retrieved element to determine the element that needs to be synchronized, including:

[0032] Determine the elements corresponding to the values ​​of the synchronized file time attributes whose modification time of the retrieved elements is greater than the value of the synchronized file time attribute, and the elements corresponding to the values ​​of the synchronized file path attributes whose modification time of the retrieved elements is equal to the value of the synchronized file time and whose file paths of the retrieved elements are greater than the value of the synchronized file path attribute, so as to obtain the elements that need to be synchronized.

[0033] A further technical solution is: the step of determining the elements to be synchronized based on the comparison of the initial branch path times of the two paths includes:

[0034] Determine the element whose modification time of the branch path of the element taken out is greater than the element corresponding to the value of the modification time attribute of the synchronized branch path, the element whose modification time of the branch path of the element taken out is equal to the value of the modification time attribute of the synchronized branch path and the element corresponding to the value of the branch file path of the element taken out is greater than that of the synchronized branch file path, so as to obtain the elements that need to be synchronized.

[0035] The present invention also provides a file synchronization device based on synchronization checkpoints, comprising:

[0036] A checkpoint file acquisition unit, used to acquire a checkpoint file when the system performs file synchronization;

[0037] A file determination unit, used to determine whether the checkpoint file exists;

[0038] A loading unit, configured to load the checkpoint file if the checkpoint file exists;

[0039] A scanning unit, used for scanning the folders to be synchronized, and sorting the folders to be synchronized to obtain a sorting result;

[0040] A comparison unit, used to compare the sorting result with the checkpoint file one by one to determine the elements that need to be synchronized;

[0041] An element judgment unit, used to judge whether the element to be synchronized is a file; if the element to be synchronized is not a file, the scanning of the folders to be synchronized is performed, and the folders to be synchronized are sorted to obtain a sorting result;

[0042] The file updating unit is used for performing file synchronization and updating the checkpoint file if the element to be synchronized is a file.

[0043] The present invention further provides a computer device, which includes a memory and a processor. The memory stores a computer program, and the processor implements the above method when executing the computer program.

[0044] The present invention also provides a storage medium, wherein the storage medium stores a computer program, and the computer program implements the above method when executed by a processor.

[0045] Compared with the prior art, the present invention has the following beneficial effects: the present invention uses checkpoints to record the progress of file synchronization during the file synchronization process. When re-synchronizing text, the elements that need to be synchronized are determined after a one-to-one comparison between the attributes in the checkpoint file and the sorted contents of the folders that need to be synchronized. The files that have been synchronized last time are no longer synchronized, which reduces the synchronization cost in an unstable file synchronization environment, enables fast synchronization of changed files, and saves time and CPU when resynchronizing files that have been synchronized.

[0046] The present invention is further described below in conjunction with the accompanying drawings and specific embodiments. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0048] Figure 1 A schematic diagram of an application scenario of a file synchronization method based on synchronization checkpoints provided in an embodiment of the present invention;

[0049] Figure 2A flowchart of a file synchronization method based on synchronization checkpoints provided by an embodiment of the present invention;

[0050] Figure 3 A schematic diagram of a sub-process of a file synchronization method based on synchronization checkpoints provided in an embodiment of the present invention;

[0051] Figure 4 A schematic diagram of a sub-process of a file synchronization method based on synchronization checkpoints provided in an embodiment of the present invention;

[0052] Figure 5 A schematic block diagram of a file synchronization device based on synchronization checkpoints provided by an embodiment of the present invention;

[0053] Figure 6 A schematic block diagram of a scanning unit of a file synchronization device based on synchronization checkpoints provided by an embodiment of the present invention;

[0054] Figure 7 A schematic block diagram of a comparison unit of a file synchronization device based on synchronization checkpoints provided in an embodiment of the present invention;

[0055] Figure 8 A schematic block diagram of a computer device provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0056] 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 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.

[0057] It should be understood that when used in this specification and the appended claims, the terms "include" and "comprises" indicate the presence of described features, integers, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or combinations thereof.

[0058] It should also be understood that the terms used in this specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. As used in the specification of the present invention and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.

[0059] It should be further understood that the term "and / or" used in the present description and the appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.

[0060] See also Figure 1 and Figure 2 , Figure 1 A schematic diagram of an application scenario of a file synchronization method based on synchronization checkpoints provided in an embodiment of the present invention. Figure 2 A schematic flow chart of a file synchronization method based on synchronization checkpoints provided in an embodiment of the present invention. The server interacts with a receiving end, i.e., a terminal or another server, to obtain a folder that needs to be synchronized provided by the terminal or another server, scans and sorts it, and determines the files that need to be synchronized in combination with the checkpoint file, so as to continue the last synchronization progress when the file synchronization is interrupted and restored, without the need to resynchronize all the files in the entire folder, so as to realize the ability to quickly synchronize the changed files, and save time and CPU when resynchronizing the files that have been interrupted.

[0061] Figure 2 FIG. 1 is a flowchart of a file synchronization method based on synchronization checkpoints provided by an embodiment of the present invention. Figure 2 As shown, the method includes the following steps S110 to S200.

[0062] S110. When the system performs file synchronization, a checkpoint file is obtained.

[0063] In this embodiment, the checkpoint file refers to a file used to record the synchronized folder path, synchronized folder time, synchronized file path, and synchronized file time.

[0064] Before synchronizing files, you can determine which files are not synchronized based on the checkpoint file, so that you can accurately synchronize the files that need to be synchronized.

[0065] S120, determining whether the checkpoint file exists;

[0066] S130: If the checkpoint file exists, load the checkpoint file.

[0067] In this embodiment, the synchronized folder path attribute, the synchronized folder time attribute, the synchronized file path attribute, and the synchronized file time attribute in the checkpoint file are obtained.

[0068] S140: Scan the folders that need to be synchronized, and sort the folders that need to be synchronized to obtain a sorting result.

[0069] In this embodiment, the sorting result refers to the result obtained by arranging the file and folder list in ascending order according to the modification time and then sorting them in ascending order according to the file name.

[0070] In one embodiment, see Figure 3 , the above-mentioned step S140 may include steps S141 to S142.

[0071] S141, scanning the folder path to be synchronized to obtain a list of files and folders to be synchronized;

[0072] S142. The list of files and folders to be synchronized is sorted in ascending order according to modification time, and then in ascending order according to file name, to obtain a sorting result.

[0073] In this embodiment, the folder path is scanned to obtain a list of files and folders to be synchronized, which is recorded as List; this List is first sorted in ascending order by modification time and then in ascending order by file name.

[0074] S150: Compare the sorting result with the checkpoint file one by one to determine the elements that need to be synchronized.

[0075] In this embodiment, the elements that need to be synchronized refer to files or folders that have not been synchronized.

[0076] In one embodiment, see Figure 4 , the above-mentioned step S150 may include steps S151 to S156.

[0077] S151. Take an element from the first position in the sorting result, and remove the taken element from the sorting result.

[0078] In this embodiment, an element is taken from the beginning of the List and removed from the List to avoid the problem of repeated judgment.

[0079] S152, determining whether the value corresponding to the synchronized folder path attribute contains or is equal to the file path of the retrieved element;

[0080] If the value corresponding to the synchronized folder path attribute contains or is equal to the file path of the retrieved element, the element has been synchronized, and step S140 is executed.

[0081] S153: If the value corresponding to the synchronized folder path attribute does not contain and is not equal to the file path of the extracted element, determine whether the upper folder path of the extracted element is equal to the value corresponding to the synchronized folder path attribute;

[0082] S154. If the upper folder path of the retrieved element is equal to the value corresponding to the synchronized folder path attribute, a comparison is performed between the value corresponding to the synchronized file time attribute and the modification time of the retrieved element to determine the element that needs to be synchronized.

[0083] Specifically, determine the element whose modification time of the retrieved element is greater than the value of the synchronized file time attribute, the element whose modification time of the retrieved element is equal to the value of the synchronized file time and the element whose file path is greater than the value of the synchronized file path attribute, so as to obtain the elements that need to be synchronized.

[0084] S155. If the upper folder path of the retrieved element is not equal to the value corresponding to the synchronized folder path attribute, the first two branch paths of the two paths are obtained by combining the value of the synchronized folder path attribute and the path of the folder where the element is located;

[0085] S156: Determine the elements that need to be synchronized based on the comparison of the initial branch path times of the two paths.

[0086] In this embodiment, it is determined that the modification time of the extracted element branch path is greater than the element corresponding to the value of the modification time attribute of the synchronized branch path, the modification time of the extracted element branch path is equal to the value of the modification time attribute of the synchronized branch path and the branch file path of the extracted element is greater than the element corresponding to the value of the synchronized branch file path, so as to obtain the elements that need to be synchronized.

[0087] Specifically, if the "synchronized folder path" contains or is equal to the file path of the element, it means that the element is a folder and has been synchronized, and does not need to be synchronized again; if the element's upper folder path is equal to the "synchronized folder path", it means that the previous synchronization process is processing the files in the current folder, and then compare the "synchronized file time" and the element's modification time: if the element's modification time is greater than the "synchronized file time", it means that the file is not synchronized and needs to be synchronized; if the element's modification time is equal to the "synchronized file time" and the element's file path is greater than the "synchronized file path", it means that the file is not synchronized and needs to be synchronized; in other cases, no synchronization will occur.

[0088] In other cases, that is, if the upper folder path of the element is not equal to the "synchronized folder path", the first two branch paths of the "synchronized folder path" and the path of the folder where the element is located are taken, that is, the next level directory of the intersection of the two paths. They are recorded as f1 and f2 respectively. For example, the first branch paths of / a / b / c / d / e and / a / b / x / y / z are: / a / b / c and / a / b / x. Compare the time of the two first branch paths. If the modification time of the element branch path is greater than the "modification time of the synchronized branch path", it means that the file is not synchronized and needs to be synchronized; if the modification time of the element branch path is equal to the "modification time of the synchronized branch path", and the element branch file path is greater than the "synchronized branch file path", it means that the file is not synchronized and needs to be synchronized; in other cases, it is not synchronized.

[0089] S160, determining whether the element to be synchronized is a file;

[0090] S170: If the element to be synchronized is a file, perform file synchronization and update the checkpoint file.

[0091] In this embodiment, file synchronization is to copy the elements to be synchronized to the specified location for file synchronization and update the checkpoint file, including: "file location" attribute is set to the current file path, and "file time" attribute is the modification time of this file.

[0092] If the element to be synchronized is not a file, step S140 is executed.

[0093] If the element is a folder, the synchronized folder path returns to step S140 to continue scanning the element to be synchronized, ie, the folder.

[0094] S180. If the checkpoint file does not exist, create a new checkpoint file, set the folder location attribute in the checkpoint file to the synchronization folder path, and set the folder time attribute to the modification time of the synchronization folder; set the file location attribute to empty, and set the file time attribute to empty.

[0095] S190. Scan the folders that need to be synchronized, and sort the folders that need to be synchronized.

[0096] In this embodiment, the method of step S190 is consistent with that of step S140 and will not be repeated here.

[0097] S200: Synchronize the files in the sorted folder and record the checkpoints to update the checkpoint files.

[0098] If this element is a folder, update the checkpoint file, set the "Folder Location" to the current folder path, and the "Folder Time" to the modification time of this folder; set the "File Location" to empty, and set the "File Time" to empty; if the element to be synchronized is a file, this step S200 is consistent with step S170 and will not be repeated here.

[0099] The above-mentioned file synchronization method based on synchronization checkpoints uses checkpoints to record the progress of file synchronization during the file synchronization process. When re-synchronizing text, the attributes in the checkpoint file and the sorted contents of the folder that needs to be synchronized are compared one by one to determine the elements that need to be synchronized and synchronize them. The files that have been synchronized last time are no longer synchronized, which reduces the synchronization cost in an unstable file synchronization environment, enables fast synchronization of changed files, and saves time and CPU when resynchronizing files that have been synchronized.

[0100] Figure 5 FIG. 3 is a schematic block diagram of a file synchronization device 300 based on synchronization checkpoints provided by an embodiment of the present invention. Figure 5 As shown, corresponding to the above file synchronization method based on synchronization checkpoints, the present invention also provides a file synchronization device 300 based on synchronization checkpoints. The file synchronization device 300 based on synchronization checkpoints includes a unit for executing the above file synchronization method based on synchronization checkpoints, and the device can be configured in a server. Figure 5 The file synchronization device 300 based on synchronization checkpoint includes a checkpoint file acquisition unit 301, a file judgment unit 302, a loading unit 303, a scanning unit 304, a comparison unit 305, an element judgment unit 306, a file update unit 307, a new creation unit 308, a scanning sorting unit 309 and a recording unit 310.

[0101] A checkpoint file acquisition unit 301 is used to acquire a checkpoint file when the system performs file synchronization; a file judgment unit 302 is used to judge whether the checkpoint file exists; a loading unit 303 is used to load the checkpoint file if the checkpoint file exists; a scanning unit 304 is used to scan the folders that need to be synchronized, and sort the folders that need to be synchronized to obtain a sorting result; a comparison unit 305 is used to compare the sorting result with the checkpoint file one by one to determine the elements that need to be synchronized; an element judgment unit 306 is used to judge whether the element that needs to be synchronized is a file; if the element that needs to be synchronized is not a file, the scanning of the folders that need to be synchronized is performed, and the folders that need to be synchronized are sorted to obtain a sorting result; a file update unit 307 is used to perform file synchronization and update the checkpoint file if the element that needs to be synchronized is a file. The new creation unit 308 is used to create a new checkpoint file if the checkpoint file does not exist, set the folder location attribute in the checkpoint file to the synchronization folder path, and the folder time attribute to the modification time of the synchronization folder; set the file location attribute to null, and set the file time attribute to null. The scanning and sorting unit 309 is used to scan the folders that need to be synchronized and sort the folders that need to be synchronized; the recording unit 310 is used to synchronize the files in the sorted folders and record the checkpoints to update the checkpoint file.

[0102] In one embodiment, the loading unit 303 is used to obtain synchronized folder path attributes, synchronized folder time attributes, synchronized file path attributes, and synchronized file time attributes in the checkpoint file.

[0103] In one embodiment, if Figure 6As shown, the scanning unit 304 includes a path scanning subunit 3041 and an ascending order sorting subunit 3042 .

[0104] The path scanning subunit 3041 is used to scan the folder path to be synchronized to obtain a list of files and folders to be synchronized; the ascending sorting subunit 3042 is used to sort the list of files and folders to be synchronized in ascending order according to the modification time, and then in ascending order according to the file name to obtain the sorting result.

[0105] In one embodiment, if Figure 7 As shown, the comparison unit 305 includes a fetching subunit 3051 , a first judging subunit 3052 , a second judging subunit 3053 , a time comparison subunit 3054 , a branch path determination subunit 3055 and a time comparison subunit 3056 .

[0106] The extraction subunit 3051 is used to extract an element from the first position in the sorting result and remove the extracted element from the sorting result; the first judgment subunit 3052 is used to judge whether the value corresponding to the synchronized folder path attribute contains or is equal to the file path of the extracted element; the second judgment subunit 3053 is used to judge whether the upper folder path of the extracted element is equal to the value corresponding to the synchronized folder path attribute if the value corresponding to the synchronized folder path attribute does not contain and is not equal to the file path of the extracted element; the time comparison subunit 3054 is used to judge whether the upper folder path of the extracted element is equal to the value corresponding to the synchronized folder path attribute if the upper folder path of the extracted element is equal to the value corresponding to the synchronized folder path attribute If the upper-layer folder path is equal to the value corresponding to the synchronized folder path attribute, then the value corresponding to the synchronized file time attribute and the modification time of the retrieved element are compared to determine the element that needs to be synchronized; the branch path determination subunit 3055 is used to, if the upper-layer folder path of the retrieved element is not equal to the value corresponding to the synchronized folder path attribute, take the first two branch paths of the two paths of the value of the synchronized folder path attribute and the path of the folder where the element is located; the time comparison subunit 3056 is used to determine the element that needs to be synchronized based on the comparison of the first branch path time of the two paths.

[0107] It should be noted that those skilled in the art can clearly understand that the specific implementation process of the above-mentioned file synchronization device 300 based on synchronization checkpoints and each unit can refer to the corresponding description in the aforementioned method embodiment, and for the convenience and brevity of description, it will not be repeated here.

[0108] The above-mentioned file synchronization device 300 based on synchronization checkpoint can be implemented in the form of a computer program. The computer program can be used in Figure 8 Runs on the computer device shown.

[0109] See also Figure 8 , Figure 85 is a schematic block diagram of a computer device provided in an embodiment of the present application. The computer device 500 may be a terminal or a server, wherein the terminal may be an electronic device with communication functions such as a smart phone, a tablet computer, a laptop computer, a desktop computer, a personal digital assistant, and a wearable device. The server may be an independent server or a server cluster composed of multiple servers.

[0110] See also Figure 8 The computer device 500 includes a processor 502 , a memory and a network interface 505 connected via a system bus 501 , wherein the memory may include a non-volatile storage medium 503 and an internal memory 504 .

[0111] The non-volatile storage medium 503 can store an operating system 5031 and a computer program 5032. The computer program 5032 includes program instructions, and when the program instructions are executed, the processor 502 can execute a file synchronization method based on synchronization checkpoints.

[0112] The processor 502 is used to provide computing and control capabilities to support the operation of the entire computer device 500 .

[0113] The internal memory 504 provides an environment for the operation of the computer program 5032 in the non-volatile storage medium 503. When the computer program 5032 is executed by the processor 502, the processor 502 can execute a file synchronization method based on synchronization checkpoints.

[0114] The network interface 505 is used to communicate with other devices over the network. Figure 8 The structure shown in the figure is merely a block diagram of a portion of the structure related to the solution of the present application, and does not constitute a limitation on the computer device 500 to which the solution of the present application is applied. The specific computer device 500 may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0115] The processor 502 is used to run the computer program 5032 stored in the memory to implement the following steps:

[0116] When the system performs file synchronization, it obtains a checkpoint file; determines whether the checkpoint file exists; if the checkpoint file exists, it loads the checkpoint file; scans the folders that need to be synchronized, and sorts the folders that need to be synchronized to obtain a sorting result; compares the sorting result with the checkpoint file one by one to determine the elements that need to be synchronized; determines whether the elements that need to be synchronized are files; if the elements that need to be synchronized are files, it performs file synchronization and updates the checkpoint file. If the elements that need to be synchronized are not files, it performs the scanning of the folders that need to be synchronized, and sorts the folders that need to be synchronized to obtain a sorting result.

[0117] In one embodiment, when implementing the step of loading the checkpoint file, the processor 502 specifically implements the following steps:

[0118] Gets the synchronized folder path attribute, synchronized folder time attribute, synchronized file path attribute, and synchronized file time attribute in the checkpoint file.

[0119] In one embodiment, after implementing the step of determining whether the checkpoint file exists, the processor 502 further implements the following steps:

[0120] If the checkpoint file does not exist, create a new checkpoint file, set the folder location attribute in the checkpoint file to the synchronization folder path, and set the folder time attribute to the modification time of the synchronization folder; set the file location attribute to empty, and set the file time attribute to empty; scan the folders that need to be synchronized, and sort the folders that need to be synchronized; synchronize the files in the sorted folders, and record the checkpoint to update the checkpoint file.

[0121] In one embodiment, when the processor 502 implements the step of scanning the folders to be synchronized and sorting the folders to be synchronized to obtain the sorting result, the processor 502 specifically implements the following steps:

[0122] Scan the folder path to be synchronized to obtain a list of files and folders to be synchronized; sort the list of files and folders to be synchronized in ascending order by modification time, and then in ascending order by file name to obtain a sorting result.

[0123] In one embodiment, when the processor 502 implements the step of comparing the sorting result with the checkpoint file one by one to determine the elements that need to be synchronized, the processor 502 specifically implements the following steps:

[0124] An element is taken out from the first position in the sorting result, and the taken out element is removed from the sorting result; whether the value corresponding to the synchronized folder path attribute contains or is equal to the file path of the taken out element is determined; if the value corresponding to the synchronized folder path attribute does not contain and is not equal to the file path of the taken out element, whether the upper folder path of the taken out element is equal to the value corresponding to the synchronized folder path attribute; if the upper folder path of the taken out element is equal to the value corresponding to the synchronized folder path attribute, a comparison is performed based on the value corresponding to the synchronized file time attribute and the modification time of the taken out element to determine the element that needs to be synchronized; if the upper folder path of the taken out element is not equal to the value corresponding to the synchronized folder path attribute, the value of the synchronized folder path attribute and the path of the folder where the element is located are taken from the first two branch paths of the two paths; based on the comparison of the first branch path times of the two paths, the element that needs to be synchronized is determined.

[0125] In one embodiment, when the processor 502 implements the step of comparing the value corresponding to the synchronized file time attribute with the modification time of the retrieved element to determine the element to be synchronized, the processor 502 specifically implements the following steps:

[0126] Determine the elements corresponding to the values ​​of the synchronized file time attributes whose modification time of the retrieved elements is greater than the value of the synchronized file time attribute, and the elements corresponding to the values ​​of the synchronized file path attributes whose modification time of the retrieved elements is equal to the value of the synchronized file time and whose file paths of the retrieved elements are greater than the value of the synchronized file path attribute, so as to obtain the elements that need to be synchronized.

[0127] In one embodiment, when the processor 502 implements the step of determining the elements that need to be synchronized based on the comparison of the initial branch path times of the two paths, the processor 502 specifically implements the following steps:

[0128] Determine the element whose modification time of the branch path of the element taken out is greater than the element corresponding to the value of the modification time attribute of the synchronized branch path, the element whose modification time of the branch path of the element taken out is equal to the value of the modification time attribute of the synchronized branch path and the element corresponding to the value of the branch file path of the element taken out is greater than that of the synchronized branch file path, so as to obtain the elements that need to be synchronized.

[0129] It should be understood that in the embodiment of the present application, the processor 502 may be a central processing unit (CPU), and the processor 502 may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Among them, the general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.

[0130] It can be understood by those skilled in the art that all or part of the processes in the method for implementing the above embodiment can be completed by instructing the relevant hardware through a computer program. The computer program includes program instructions, and the computer program can be stored in a storage medium, which is a computer-readable storage medium. The program instructions are executed by at least one processor in the computer system to implement the process steps of the embodiment of the above method.

[0131] Therefore, the present invention also provides a storage medium. The storage medium may be a computer-readable storage medium. The storage medium stores a computer program, wherein when the computer program is executed by a processor, the processor executes the following steps:

[0132] When the system performs file synchronization, it obtains a checkpoint file; determines whether the checkpoint file exists; if the checkpoint file exists, it loads the checkpoint file; scans the folders that need to be synchronized, and sorts the folders that need to be synchronized to obtain a sorting result; compares the sorting result with the checkpoint file one by one to determine the elements that need to be synchronized; determines whether the elements that need to be synchronized are files; if the elements that need to be synchronized are files, it performs file synchronization and updates the checkpoint file. If the elements that need to be synchronized are not files, it performs the scanning of the folders that need to be synchronized, and sorts the folders that need to be synchronized to obtain a sorting result.

[0133] In one embodiment, when the processor executes the computer program to implement the step of loading the checkpoint file, the processor specifically implements the following steps:

[0134] Gets the synchronized folder path attribute, synchronized folder time attribute, synchronized file path attribute, and synchronized file time attribute in the checkpoint file.

[0135] In one embodiment, after executing the computer program to implement the step of determining whether the checkpoint file exists, the processor further implements the following steps:

[0136] If the checkpoint file does not exist, create a new checkpoint file, set the folder location attribute in the checkpoint file to the synchronization folder path, and set the folder time attribute to the modification time of the synchronization folder; set the file location attribute to empty, and set the file time attribute to empty; scan the folders that need to be synchronized, and sort the folders that need to be synchronized; synchronize the files in the sorted folders, and record the checkpoint to update the checkpoint file.

[0137] In one embodiment, when the processor executes the computer program to implement the step of scanning the folders to be synchronized and sorting the folders to be synchronized to obtain the sorting result, the processor specifically implements the following steps:

[0138] Scan the folder path to be synchronized to obtain a list of files and folders to be synchronized; sort the list of files and folders to be synchronized in ascending order by modification time, and then in ascending order by file name to obtain a sorting result.

[0139] In one embodiment, when the processor executes the computer program to implement the step of comparing the sorting result with the checkpoint file one by one to determine the elements that need to be synchronized, the processor specifically implements the following steps:

[0140] An element is taken out from the first position in the sorting result, and the taken out element is removed from the sorting result; whether the value corresponding to the synchronized folder path attribute contains or is equal to the file path of the taken out element is determined; if the value corresponding to the synchronized folder path attribute does not contain and is not equal to the file path of the taken out element, whether the upper folder path of the taken out element is equal to the value corresponding to the synchronized folder path attribute; if the upper folder path of the taken out element is equal to the value corresponding to the synchronized folder path attribute, a comparison is performed based on the value corresponding to the synchronized file time attribute and the modification time of the taken out element to determine the element that needs to be synchronized; if the upper folder path of the taken out element is not equal to the value corresponding to the synchronized folder path attribute, the value of the synchronized folder path attribute and the path of the folder where the element is located are taken from the first two branch paths of the two paths; based on the comparison of the first branch path times of the two paths, the element that needs to be synchronized is determined.

[0141] In one embodiment, when the processor executes the computer program to implement the step of comparing the value corresponding to the synchronized file time attribute with the modification time of the retrieved element to determine the element to be synchronized, the processor specifically implements the following steps:

[0142] Determine the elements corresponding to the values ​​of the synchronized file time attributes whose modification time of the retrieved elements is greater than the value of the synchronized file time attribute, and the elements corresponding to the values ​​of the synchronized file path attributes whose modification time of the retrieved elements is equal to the value of the synchronized file time and whose file paths of the retrieved elements are greater than the value of the synchronized file path attribute, so as to obtain the elements that need to be synchronized.

[0143] In one embodiment, when the processor executes the computer program to implement the step of determining the elements that need to be synchronized based on the comparison of the initial branch path times of the two paths, the processor specifically implements the following steps:

[0144] Determine the element whose modification time of the branch path of the element taken out is greater than the element corresponding to the value of the modification time attribute of the synchronized branch path, the element whose modification time of the branch path of the element taken out is equal to the value of the modification time attribute of the synchronized branch path and the element corresponding to the value of the branch file path of the element taken out is greater than that of the synchronized branch file path, so as to obtain the elements that need to be synchronized.

[0145] The storage medium may be a USB flash drive, a mobile hard disk, a read-only memory (ROM), a magnetic disk, or an optical disk, etc., which are computer-readable storage media that can store program codes.

[0146] Those of ordinary skill in the art will 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 terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can 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 the present invention.

[0147] In the several embodiments provided by the present invention, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of each unit is only a logical function division, and there may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed.

[0148] The steps in the method of the embodiment of the present invention can be adjusted in order, combined and deleted according to actual needs. The units in the device of the embodiment of the present invention can be combined, divided and deleted according to actual needs. In addition, 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.

[0149] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a storage medium. Based on this understanding, the technical solution of the present invention is essentially 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, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, terminal, or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention.

[0150] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed by the present invention, and these modifications or replacements should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be based on the protection scope of the claims.

Claims

1. A file synchronization method based on synchronization checkpoints, characterized in that: include: When the system performs file synchronization, obtain the checkpoint file; Determine whether the checkpoint file exists; If the checkpoint file exists, load the checkpoint file; Scan the folders that need to be synchronized, and sort the folders that need to be synchronized to obtain sorting results; Compare the sorting result with the checkpoint file one by one to determine the elements that need to be synchronized; Determine whether the element to be synchronized is a file; If the element to be synchronized is a file, the file is synchronized and the checkpoint file is updated. If the element to be synchronized is not a file, the scanning of the folders to be synchronized is performed, and the folders to be synchronized are sorted to obtain a sorting result.

2. The file synchronization method based on synchronization checkpoint according to claim 1, characterized in that: The loading of the checkpoint file comprises: Gets the synchronized folder path attribute, synchronized folder time attribute, synchronized file path attribute, and synchronized file time attribute in the checkpoint file.

3. The file synchronization method based on synchronization checkpoint according to claim 1, characterized in that: After determining whether the checkpoint file exists, the method further includes: If the checkpoint file does not exist, create a new checkpoint file, set the folder location attribute in the checkpoint file to the synchronization folder path, and set the folder time attribute to the modification time of the synchronization folder; set the file location attribute to null, and set the file time attribute to null; Scan the folders that need to be synchronized and sort the folders that need to be synchronized; The files in the sorted folders are synchronized, and checkpoints are recorded to update the checkpoint files.

4. The file synchronization method based on synchronization checkpoint according to claim 2, characterized in that: The scanning of the folders to be synchronized and sorting the folders to be synchronized to obtain sorting results includes: Scan the folder path that needs to be synchronized to obtain the list of files and folders to be synchronized; The list of files and folders to be synchronized is sorted in ascending order by modification time, and then in ascending order by file name to obtain the sorting result.

5. The file synchronization method based on synchronization checkpoint according to claim 2, characterized in that: The step of comparing the sorting result with the checkpoint file one by one to determine the elements that need to be synchronized includes: Taking an element from the first position in the sorted result, and removing the taken element from the sorted result; Determine whether the value corresponding to the synchronized folder path attribute contains or is equal to the file path of the retrieved element; If the value corresponding to the synchronized folder path attribute does not contain and is not equal to the file path of the extracted element, determine whether the upper folder path of the extracted element is equal to the value corresponding to the synchronized folder path attribute; If the upper folder path of the retrieved element is equal to the value corresponding to the synchronized folder path attribute, then the modification time of the retrieved element is compared with the value corresponding to the synchronized file time attribute to determine the element that needs to be synchronized; If the upper folder path of the retrieved element is not equal to the value corresponding to the synchronized folder path attribute, the first two branch paths of the two paths are obtained by combining the value of the synchronized folder path attribute and the path of the folder where the element is located; Based on the comparison of the initial branch path times of the two paths, the elements that need to be synchronized are determined.

6. The file synchronization method based on synchronization checkpoint according to claim 5, characterized in that: The step of comparing the value corresponding to the synchronized file time attribute with the modification time of the retrieved element to determine the element that needs to be synchronized includes: Determine the elements corresponding to the values ​​of the synchronized file time attributes whose modification time of the retrieved elements is greater than the value of the synchronized file time attribute, and the elements corresponding to the values ​​of the synchronized file path attributes whose modification time of the retrieved elements is equal to the value of the synchronized file time and whose file paths of the retrieved elements are greater than the value of the synchronized file path attribute, so as to obtain the elements that need to be synchronized.

7. The file synchronization method based on synchronization checkpoint according to claim 5, characterized in that: The step of determining the elements to be synchronized based on the comparison of the initial branch path times of the two paths includes: Determine the element whose modification time of the branch path of the element taken out is greater than the element corresponding to the value of the modification time attribute of the synchronized branch path, the element whose modification time of the branch path of the element taken out is equal to the value of the modification time attribute of the synchronized branch path and the element corresponding to the value of the branch file path of the element taken out is greater than that of the synchronized branch file path, so as to obtain the elements that need to be synchronized.

8. A file synchronization device based on synchronization checkpoints, characterized in that: include: A checkpoint file acquisition unit, used to acquire a checkpoint file when the system performs file synchronization; A file determination unit, used to determine whether the checkpoint file exists; A loading unit, configured to load the checkpoint file if the checkpoint file exists; A scanning unit, used for scanning the folders to be synchronized, and sorting the folders to be synchronized to obtain a sorting result; A comparison unit, used to compare the sorting result with the checkpoint file one by one to determine the elements that need to be synchronized; An element judgment unit, used to judge whether the element to be synchronized is a file; If the element to be synchronized is not a file, the scanning of the folders to be synchronized is performed, and the folders to be synchronized are sorted to obtain a sorting result; The file updating unit is used for performing file synchronization and updating the checkpoint file if the element to be synchronized is a file.

9. A computer device, characterized in that: The computer device comprises a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the method according to any one of claims 1 to 7 is implemented.

10. A storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.