File synchronization method and related apparatus
By analyzing the set of change operations in local and cloud folders, planning and executing the target change operations, the problem of file synchronization failure and inefficiency caused by redundant operations is solved, and efficient file synchronization is achieved.
Patent Information
- Application Number
- PCT/CN2025/099010
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2024-07-25
- Filing Date
- 2025-06-04
- Publication Date
- 2026-01-29
AI Technical Summary
In existing technologies, redundant operations in folder operations increase the probability of conflict events, leading to file synchronization failures and excessive time consumption, thus affecting synchronization efficiency.
By obtaining the directories of local and cloud folders and the synchronized directory, analyzing the set of change operations, planning the target change operations, and executing them in sequence, file synchronization is achieved.
This reduces redundant operations, lowers the probability of conflicts, and improves the efficiency and accuracy of file synchronization.
Smart Images

Figure CN2025099010_29012026_PF_FP_ABST
Abstract
Description
A file synchronization method and related device
[0001] Related applications
[0002] The present application claims priority to the Chinese patent application No. 202411009416.X, filed on July 25, 2024, and entitled "A file synchronization method and related device", the contents of which are hereby incorporated by reference in its entirety. TECHNICAL FIELD
[0003] The present application relates to the technical field of computers, and provides a file synchronization method and related device. BACKGROUND
[0004] File synchronization refers to keeping the file content in the local folder in the client consistent with the file content in the cloud folder in the cloud server.
[0005] In the related art, the client generates a corresponding set of operation events according to the operation log of the cloud folder, and generates a corresponding set of operation events according to the operation log of the local folder. Then, according to the two sets of operation events, the corresponding operations of the operation events are respectively performed on the local folder and the cloud folder to realize file synchronization.
[0006] However, there may be redundant operations in the operations on the folder. The redundant operations increase the probability of conflict events, resulting in file synchronization failure. In addition, the redundant operations cause the file synchronization to take too long, affecting the file synchronization efficiency.
[0007] For example, if the set of operation events of the local folder represents that a certain field in document 1 is modified first, and then the field is restored to the initial value, when data synchronization is performed, two modification operations need to be performed on the document 1 in the cloud folder. However, the document 1 is not actually modified, which seriously affects the data synchronization efficiency. SUMMARY
[0008] The present application provides a file synchronization method and related device.
[0009] In a first aspect, the present application provides a file synchronization method applied to an electronic device, comprising:
[0010] When file synchronization is performed on the local folder and the cloud folder, the local directory of the local folder at a synchronization time, the cloud directory of the cloud folder at the synchronization time, and the synchronization directory of the local folder and the cloud folder in a synchronized state after the last file synchronization are obtained.
[0011] Based on the local directory, the cloud directory and the synchronization directory, a set of local change operations occurred in the local folder from the last file synchronization completion to the synchronization time and a set of cloud change operations occurred in the cloud folder are obtained respectively;
[0012] The local change operation set and the cloud change operation set are analyzed for differences, and based on the analysis result, target change operations to be executed in this file synchronization are planned; and
[0013] Based on the operation types of the target change operations respectively, execution orders of the target change operations are obtained, and the target change operations are executed in sequence according to the execution orders to complete this file synchronization.
[0014] In a second aspect, an embodiment of the present application provides a file synchronization device, comprising:
[0015] A data acquisition unit is configured to acquire a local directory of a local folder at a synchronization time, a cloud directory of a cloud folder at the synchronization time, and a synchronization directory of the local folder and the cloud folder in a synchronized state after the last file synchronization completion when file synchronization is performed on the local folder and the cloud folder.
[0016] A directory analysis unit is configured to obtain a set of local change operations occurred in the local folder from the last file synchronization completion to the synchronization time and a set of cloud change operations occurred in the cloud folder based on the local directory, the cloud directory and the synchronization directory respectively.
[0017] A difference analysis unit is configured to analyze the local change operation set and the cloud change operation set for differences, and based on the analysis result, target change operations to be executed in this file synchronization are planned; and
[0018] An operation execution unit is configured to obtain execution orders of the target change operations based on the operation types of the target change operations respectively, and execute the target change operations in sequence according to the execution orders to complete this file synchronization.
[0019] In a third aspect, an embodiment of the present application provides an electronic device comprising a processor and a memory, wherein the memory stores a computer program, and when the computer program is executed by the processor, the computer program causes the processor to execute the steps of the above method.
[0020] In a fourth aspect, an embodiment of the present application provides a computer readable storage medium comprising a computer program, and when the computer program is run on an electronic device, the computer program is configured to cause the electronic device to execute the steps of the method of any one of the above aspects.
[0021] In a fifth aspect, an embodiment of the present application provides a computer program product, the program product comprising a computer program stored in a computer readable storage medium, and a processor of an electronic device reads and executes the computer program from the computer readable storage medium, so that the electronic device executes the steps of the method of any one of the above aspects.
[0022] Additional features and advantages of the application will be set forth in the description that follows, and in part will be apparent from the description, or can be learned by practice of the application. The objectives and other advantages of the application will be realized and attained by the structure particularly pointed out in the written description and claims thereof as well as the appended drawings. BRIEF DESCRIPTION OF DRAWINGS
[0023] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the embodiments will be briefly introduced as follows. Obviously, the drawings in the following description are only embodiments of the present application, and other drawings can be obtained by those skilled in the art without any creative effort on the basis of the disclosed drawings.
[0024] Fig. 1 is a schematic diagram of an application scenario provided in an embodiment of the present application;
[0025] Fig. 2 is a schematic diagram of a file synchronization method provided in an embodiment of the present application;
[0026] Fig. 3 is a logical diagram of a cloud directory construction provided in an embodiment of the present application;
[0027] Fig. 4 is a logical diagram of constructing a cloud folder directory provided in an embodiment of the present application;
[0028] Fig. 5 is a logical diagram of constructing a cloud folder directory provided in another embodiment of the present application;
[0029] Fig. 6 is a schematic diagram of a local directory and a synchronization directory provided in an embodiment of the present application;
[0030] Fig. 7A is a schematic diagram of a first local file object and a synchronization file object provided in an embodiment of the present application;
[0031] Fig. 7B is a schematic diagram of a second local file object and a synchronization file object provided in an embodiment of the present application;
[0032] Fig. 8 is a schematic diagram of a task group provided in an embodiment of the present application;
[0033] Fig. 9 is a logical diagram of a task group execution process provided in an embodiment of the present application;
[0034] FIG. 10 is a schematic diagram of a file synchronization process according to an embodiment of the present application;
[0035] FIG. 11 is a schematic diagram of an operation interface for creating a synchronization disk according to an embodiment of the present application;
[0036] FIG. 12 is a schematic diagram of a configuration interface for a local folder corresponding to a synchronization folder according to an embodiment of the present application;
[0037] FIG. 13 is a schematic diagram of a configuration interface for a conflict processing mode according to an embodiment of the present application;
[0038] FIG. 14 is a schematic diagram of a configuration interface for a synchronization mode according to an embodiment of the present application;
[0039] FIG. 15A is a schematic diagram of a first type of notification information according to an embodiment of the present application;
[0040] FIG. 15B is a schematic diagram of a second type of notification information according to an embodiment of the present application;
[0041] FIG. 16 is a schematic diagram of an operation interface for selecting a conflict processing mode according to an embodiment of the present application;
[0042] FIG. 17 is a schematic diagram of an operation interface for viewing synchronization information according to an embodiment of the present application;
[0043] FIG. 18 is a schematic diagram of a structure of a file synchronization device according to an embodiment of the present application;
[0044] FIG. 19 is a schematic diagram of a structure of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0045] The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by a person of ordinary skill in the art without creative work fall within the scope of protection of the present application.
[0046] In the embodiments of the present application, the term "module" or "unit" refers to a computer program or a part of a computer program with a predetermined function, and works together with other related parts to achieve a predetermined target, and can be implemented entirely or partially by using software, hardware (such as a processing circuit or a memory), or a combination thereof. Similarly, one processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be a part of an overall module or unit that includes the functions of the module or unit.
[0047] It can be understood that when the embodiments of the present application are applied to specific products or technologies, relevant permissions or consents need to be obtained, and the collection, use and processing of relevant data need to comply with relevant laws, regulations and standards of the country and region.
[0048] Referring to FIG. 1, a schematic diagram of an application scenario provided by an embodiment of the present application is shown. The application scenario includes a terminal device 110 and a server 120. The number of the terminal device 110 and the server 120 is not specifically limited by the present application.
[0049] The terminal device 110 is installed with a client providing a cloud storage service. The client can be an application program, but is not limited to this. The terminal device 110 can be a smart phone, a tablet computer, a notebook computer, a desktop computer, a smart speaker, a smart watch, an Internet of Things device, a smart voice interaction device, a smart home appliance, a vehicle-mounted terminal, an aircraft, etc., but is not limited to this.
[0050] The server 120 is a background server corresponding to the client. The server 120 can be a standalone physical server, a server cluster or a distributed system composed of multiple physical servers, or a cloud server providing cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms, etc. basic cloud computing services.
[0051] The terminal device 110 and the server 120 can be directly or indirectly connected through wired or wireless communication, which is not limited by the present application.
[0052] The file synchronization method mentioned in the present application can be applied to the client side. For example, when the client performs file synchronization on a local folder and a cloud folder, the local directory of the local folder at the synchronization time, the cloud directory of the cloud folder at the synchronization time, and the synchronization directory of the local folder and the cloud folder in the synchronized state after the last file synchronization are obtained. Then, based on the local directory, the cloud directory and the synchronization directory, the set of local change operations that occur in the local folder from the last file synchronization to the synchronization time, and the set of cloud change operations that occur in the cloud folder are obtained respectively. The local change operation set and the cloud change operation set are analyzed, and based on the analysis result, each target change operation to be executed in this file synchronization is planned. Based on the operation type of each target change operation, the execution order of each target change operation is obtained, and each target change operation is executed in turn according to the execution order, so as to complete this file synchronization.
[0053] It is worth emphasizing that the collection and processing of relevant data (such as local folders and cloud folders) in this application should strictly comply with legal regulations, obtain the informed consent or separate consent of the personal information subject, and carry out subsequent data use and processing within the scope of legal regulations and the authorization of the personal information subject.
[0054] Referring to FIG. 2, it is a flowchart of a file synchronization method provided in an embodiment of the present application, which is applied to a client, and the specific process is as follows:
[0055] S201, when file synchronization is performed on the local folder and the cloud folder, the local directory of the local folder at the synchronization time, the cloud directory of the cloud folder at the synchronization time, and the synchronization directory of the local folder and the cloud folder in the synchronized state after the last file synchronization are obtained.
[0056] Among them, the folder is a virtual container for storing and organizing files, and the file type includes but is not limited to documents, pictures, videos, etc. The folder can be nested to form a tree structure to help the target object build a hierarchical file management system. A folder can contain one or more of subfolders and files, and the number of subfolders and files is not limited.
[0057] The local folder is a folder stored in the terminal device, and the cloud folder is a folder stored in the cloud server. The synchronization time refers to the time when it is determined that file synchronization needs to be performed on the local folder and the cloud folder. After the last file synchronization is completed, the local folder and the cloud folder converge to the same state, i.e., the local folder and the cloud folder are in a synchronized state.
[0058] When file synchronization is performed on the local folder and the cloud folder, it can be based on existing local files to create synchronization, or based on existing cloud files to create synchronization. The method of creating synchronization based on existing local files can also be referred to as synchronizing the local folder, and the method of creating synchronization based on existing cloud files can also be referred to as synchronizing the cloud folder. Since the process of synchronizing the local folder and synchronizing the cloud folder is similar, in this paper, only the synchronization of the local folder is taken as an example for description.
[0059] The synchronization type of file synchronization includes but is not limited to bidirectional synchronization or backup to the cloud. Among them, bidirectional synchronization means that the local folder and the cloud folder remain real-time and completely consistent, and any change in one end will be synchronized to the other end. Backup to the cloud means that the changes of the local folder will be synchronized to the cloud, but the file changes of the cloud will not affect the local file content, and backup to the cloud can also be referred to as one-way synchronization. The synchronization type of file synchronization can be pre-configured by the target object.
[0060] The synchronization manner of file synchronization includes, but is not limited to, manual synchronization or automatic synchronization. The manual synchronization refers to that the file synchronization is performed after the target object triggers the file synchronization operation for the local folder and the cloud folder. The automatic synchronization refers to that the folder state of the local folder and the cloud folder is automatically detected, and the file synchronization is updated in time upon any change.
[0061] In a possible case, if the synchronization type of the current file synchronization is two-way synchronization, as a possible implementation manner, the client can periodically perform file synchronization for the local folder and the cloud folder according to the set synchronization period. At this time, S201-S204 are the file synchronization process in one period. As another possible implementation manner, when the local folder and the cloud folder do not change within the set time length, the client determines that the file synchronization needs to be performed for the local folder and the cloud folder.
[0062] In a possible case, if the synchronization type of the current file synchronization is backup to the cloud, the client determines that the file synchronization needs to be performed for the local folder and the cloud folder in response to the file synchronization operation triggered by the target object. For example, the file synchronization operation can be triggered by the target object by clicking the synchronization button in the operation interface presented in the client, but is not limited thereto.
[0063] In some embodiments, the client can periodically construct the local folder directory of the local folder and the cloud folder directory of the cloud folder according to the set detection period, and record the local folder directory and the cloud folder directory at the current time. The data recording manner can adopt caching or persistence. In addition, the client can also record the synchronization folder directory in the synchronized state of the local folder and the cloud folder after each file synchronization, and the data recording manner can adopt caching or persistence. In this way, when the file synchronization is performed for the local folder and the cloud folder, the recorded local folder directory at the synchronization time, the cloud folder directory at the synchronization time, and the recorded synchronization folder directory in the synchronized state of the local folder and the cloud folder after the last file synchronization are obtained for subsequent processing. For ease of description, the local folder directory at the synchronization time is referred to as the local directory, the cloud folder directory at the synchronization time is referred to as the cloud directory, and the synchronization folder directory in the synchronized state of the local folder and the cloud folder after the last file synchronization is referred to as the synchronization directory.
[0064] In some embodiments, the client updates the local recorded local folder directory using the local folder directory constructed by the detection period, and updates the local recorded cloud folder directory using the cloud folder directory constructed by the detection period. In this way, when performing file synchronization for the local folder and the cloud folder, the local folder directory and the cloud folder directory currently recorded in the client are directly used as the local directory and the cloud directory.
[0065] Next, the creation processes of the local folder directory and the cloud folder directory recorded in the client are described.
[0066] In some embodiments, the client detects whether a change occurs in the local folder, and when a change occurs in the local folder, updates the local recorded local folder directory according to the change occurred in the local folder. The change occurred in the local folder includes but is not limited to one or more of the following operations: file or subfolder addition operation, file or subfolder deletion operation, file or subfolder modification operation, file or subfolder movement operation, etc. For example, the client can start a file hook, and when a change occurs in the local folder, the operating system actively calls the file hook to inform what change occurs in the local folder, thereby constructing the directory structure of the local folder in near real time.
[0067] In some embodiments, the client detects whether a change occurs in the cloud folder, and when a change occurs in the cloud folder, updates the local recorded cloud folder directory according to the change occurred in the cloud folder. The change occurred in the cloud folder includes but is not limited to one or more of the following operations: file or subfolder addition operation, file or subfolder deletion operation, file or subfolder modification operation, file or subfolder movement operation, etc.
[0068] Specifically, the cloud folder directory can be constructed in the following two ways, but is not limited to the following two ways:
[0069] The first construction method: the client obtains the historical operation data of the cloud folder through the cloud server, and the historical operation data includes the operation data from the last file synchronization to the synchronization time; based on the historical operation data, the cloud folder directory of the cloud folder at the synchronization time is obtained in combination with the historical cloud directory of the cloud folder after the last file synchronization is completed.
[0070] Specifically, the historical operations can be sorted based on the operation time corresponding to each historical operation in the historical operation data, to obtain the operation sequence of the historical operations. For different types of historical operations, the execution manner is as follows: if the historical operation is an adding operation, a new file or folder is added to the corresponding position in the historical cloud directory; if the historical operation is a modifying operation, the relevant information of the corresponding file or folder in the historical cloud directory is updated, such as file content, modification time, etc.; if the historical operation is a deleting operation, the corresponding file or folder is removed from the historical cloud directory; if the historical operation is a moving operation, the position of the corresponding file or folder in the historical cloud directory is updated to a new path. Based on the operation sequence of the historical operations, the above operations are sequentially executed to obtain the cloud directory.
[0071] The client can send a data acquisition request to the cloud server, and the cloud server returns the historical operation data of the cloud folder to the client after receiving the data acquisition request. The cloud server can also periodically push the historical operation data of the cloud folder to the client, so that the client obtains the historical operation data and performs subsequent processing.
[0072] The historical operation data can record each historical operation and the corresponding operation time of the cloud folder from the last file synchronization to the synchronization time. The historical operation includes but is not limited to one or more of creating, modifying, deleting, renaming, moving, and accessing.
[0073] The client sorts each historical operation based on the operation time corresponding to each historical operation in the historical operation data, to obtain the operation sequence of the historical operations, and executes each historical operation on the historical cloud directory of the cloud folder after the last file synchronization based on the operation sequence of the historical operations, to obtain the cloud folder directory of the cloud folder at the synchronization time.
[0074] Specifically, if the historical operation data records the historical operations in the cloud folder from the last file synchronization to the synchronization time in the order of operation time as follows: adding operation (adding a file in a subfolder), modifying operation (editing the content of a file), and moving operation (moving a file from a subfolder to the root directory), then the adding operation, the modifying operation, and the moving operation are sequentially executed on the cloud folder directory after the last file synchronization, to obtain the cloud directory.
[0075] For example, refer to FIG. 3, which is a logical diagram of a cloud directory construction provided in an embodiment of the present application. Assume that the historical cloud directory after the last file synchronization is composed of a subfolder (a folder named game) and a file 1 (1.txt), wherein the subfolder contains a file 2 (2.txt), and the file 1 and the file 2 are different documents in content. The client obtains the historical operation data of the cloud folder through the cloud server, and the historical operation data is sorted in the order of operation events from the last file synchronization to the synchronization time, and the historical operations of the cloud folder are as follows: an adding operation (adding a file 3 in the subfolder), a modifying operation (editing the content of the file 3), and a moving operation (moving the file 3 from the subfolder to the root directory), and the file 3 is 3.txt. Then, the client performs the adding operation, the modifying operation, and the moving operation in sequence for the historical cloud directory after the last file synchronization, and obtains the cloud directory of the cloud folder at the synchronization time, which is composed of the subfolder, the file 1, and the file 3, and the subfolder contains the file 2.
[0076] In the first construction mode, the directory architecture of the cloud folder can be constructed simply and quickly through the historical operation data, thereby improving the file synchronization efficiency.
[0077] However, in the first construction mode, a large number of redundant operations that need to be merged may be generated due to a large number of incomplete and unchunked operation logs and various timing problems. For example, all the files in a subfolder under the root directory of the cloud folder are deleted, then the subfolder is deleted, then a subfolder with the same name as the deleted subfolder is created under the root directory, and finally all the deleted files are added to the created subfolder. At this time, a large number of deletion and adding logs may be generated, but the actual cloud folder does not change, and therefore these redundant operations can be considered to be merged.
[0078] In an embodiment of the present application, a simpler directory structure construction mode, i.e., the second construction mode, is designed for a complex merging scenario.
[0079] The second construction mode: the client constructs the cloud folder directory recorded locally based on the incremental synchronization mode. Specifically, the client obtains the set of file objects that have changed in the cloud folder according to a set detection period, and updates the cloud folder directory recorded locally based on the set of file objects that have changed, to obtain the cloud directory.
[0080] The set of file objects that have changed in the cloud folder can be obtained in the following two ways, but is not limited to the following two ways:
[0081] In a first possible implementation, the client sends a detection request to the cloud server according to a set detection period, the detection request carrying local state information of each file object in the cloud folder recorded by the client at a current time, each local state information being used to represent whether a target processing operation occurs to the corresponding file object; and the client receives a set of file objects with changes returned by the cloud server, wherein the set of file objects is determined by the cloud server based on cloud state information of each file object recorded by the cloud server at the current time and in combination with the local state information of each file object.
[0082] Each file object includes, but is not limited to, one or more of a file and a subfolder.
[0083] The local state information and the cloud state information can be represented by a synchronization sequence number (SSN). For each file object in the cloud folder, a metadata can be added to describe the SSN of the file object. The SSN of the file object can be generated by a millisecond server clock, but is not limited thereto. For convenience of distinction, the local state information is denoted as SSN, and the cloud state information is denoted as SSN'. The synchronization sequence number is a metadata used to describe the state of the file object, and for each file object in the cloud folder, a metadata can be added, which can be generated by a millisecond server clock. The local state information and the cloud state information can be represented by a synchronization sequence number, and by comparing the synchronization sequence numbers of the local and cloud file objects, it can be determined whether a target processing operation occurs to the file object.
[0084] In a possible implementation, when the client initializes the cloud folder directory, the cloud server stores the cloud folder and the cloud state information of each file object in the cloud folder, and based on the cloud folder, the client obtains the initialized cloud folder directory recorded locally, and the cloud state information of each file object is recorded locally as the local state information of each file object in the initialized cloud folder recorded locally.
[0085] As an example, the client sends a query request for obtaining the cloud folder to the cloud server. After receiving the query request, the cloud server returns the cloud folder at a current time to the client, and returns the SSN' of each file and each subfolder in the cloud folder at the current time to the client. The client takes the received cloud folder as the initialized cloud folder directory recorded locally, and takes the SSN' of each file and each subfolder in the received cloud folder as the SSN of each file and each subfolder recorded locally.
[0086] Referring to FIG. 4, which is a logic diagram illustrating construction of a cloud folder directory according to an embodiment of the present application. The client sends a query request for obtaining a cloud folder to the cloud server. After receiving the query request, the cloud server returns the current cloud folder directory and the SSN' of each file and each subfolder in the current cloud folder directory to the client. The cloud folder directory is composed of subfolder 1, subfolder 2 and file 1 (1.txt), subfolder 1 contains file 2 (2.txt), and subfolder 2 contains file 3 (1.txt) and file 4 (3.txt), that is, the file objects contained in the cloud folder directory include subfolder 1, subfolder 2, file 1, file 2, file 3 and file 4. The client obtains the locally recorded initial cloud folder directory and the SSN of each file object based on the received cloud folder directory and the SSN of each file object.
[0087] In a possible implementation, for each file in the cloud folder, when a target processing operation occurs to the file, the cloud server updates the SSN' of the file to indicate that the file has changed. The target processing operation for the file includes but is not limited to one or more of the following: an adding operation and a modifying operation.
[0088] In a possible implementation, for each subfolder in the cloud folder, when a target processing operation occurs to the subfolder, the cloud server updates the SSN' of the subfolder to indicate that a file deletion or a file movement has occurred under the subfolder. The target processing operation for the subfolder includes but is not limited to one or more of the following: a file deletion operation and a file movement operation.
[0089] In this way, when an adding / editing operation occurs to a file, the cloud server updates the SSN' of the file to indicate that the remote file has changed; and when a file deletion / movement operation occurs under a folder, the cloud server updates the SSN of the folder to indicate that the file under the remote subfolder has changed.
[0090] In a possible implementation, the metadata of each file object can contain identification information for indicating whether the file is moved or deleted. The identification information can be represented by a file special identifier (inode), but is not limited thereto. When a file object is moved or deleted, the identification information of the file object will change. Therefore, when the inode of a file object changes, the cloud server can regard the file object as a changed file object.
[0091] In a possible implementation, when the SSN' is updated, the cloud server can generate a new SSN' of the current time by using a server clock, and update the SSN' based on the new SSN'.
[0092] In a possible implementation, if the value of each SSN' increases when the corresponding file object is subjected to the target processing operation, the file object that is subjected to the change is a file object whose value of the SSN' exceeds the value of the SSN.
[0093] In a possible implementation, although it can be determined from the state information whether the file is subjected to the target processing operation, the state information can be used to indicate whether the file object is changed, but even if the file is subjected to the target processing operation, the substantial content of the file can not be changed. Therefore, in the embodiment of the application, for the file whose SSN' exceeds the SSN, the cloud server can further use, but is not limited to, one or more file metadata such as a file size, a modification time, a cyclic redundancy check (CRC64) value, to determine whether the content of the file is substantially changed, and further regard the file as the file object that is subjected to the change when the content of the file is substantially changed.
[0094] In a possible implementation, if the SSN' of a subfolder exceeds the SSN, and there is a file whose SSN' exceeds the SSN in the subfolder, the subfolder can be regarded as the file object that is subjected to the change, and the file under the subfolder is not regarded as the file object that is subjected to the change.
[0095] In a possible implementation, the file object returned by the cloud server includes the content of the file object that is subjected to the change, and can also include the object identifier of the file object that is subjected to the change. If the object identifier is returned, the client can pull the corresponding file object according to the object identifier.
[0096] For example, still referring to FIG. 4, assume that the operation triggered by the target object for the cloud folder includes modifying and then deleting file 2 (2.txt) in subfolder 1 and modifying file 3 (1.txt) in subfolder 2. Since the operation on the file in the subfolder affects the state information of the subfolder, the values of the SSN' of subfolder 1, file 2, and file 3 all change, the updated SSN' of subfolder 1 is the timestamp generated by the server clock at the time of deletion of file 2, the updated SSN' of file 2 is the timestamp generated by the server clock at the time of modification of file 2, and the updated SSN' of file 3 is the timestamp generated by the server clock at the time of modification of file 3. In the first detection period, the client sends a detection request to the cloud server, and the detection request carries the SSN of subfolder 1, subfolder 2, file 1, file 2, file 3, and file 4 recorded locally by the client. After receiving the detection request carrying the SSN, the cloud server compares the corresponding SSN and SSN' for subfolder 1, subfolder 2, file 1, file 2, file 3, and file 4. At this time, the SSN' of subfolder 1 is greater than the SSN of subfolder 1, the SSN' of file 2 is greater than the SSN of file 2, and the SSN' of file 3 is greater than the SSN of file 3. Since file 2 is a file in subfolder 1, when the SSN' of the subfolder is greater than the SSN of the subfolder and there is a file in the subfolder whose SSN' is also greater than the SSN of the file, the subfolder is regarded as a changed subfolder, and the change of the file in the subfolder is not considered separately. Therefore, the cloud server regards subfolder 1 as a changed subfolder and file 3 as a changed file, and returns them to the client.
[0097] In the above implementation, whether it is a file or a subfolder, if the SSN' of a file object is greater than the SSN, the cloud server can regard the file object as a file object that may have changed. The changed file can be regarded as an incremental action in the file, and the changed subfolder can be regarded as a deletion action in the subfolder. Therefore, after the client obtains the set of changed file objects, the client can perform incremental synchronization according to the set of file objects, thereby improving the efficiency of file synchronization.
[0098] In a possible implementation, after the cloud server returns the set of changed file objects, at least one of the following situations exists:
[0099] Case 1: If the file object set includes at least one file, the client pulls at least one file through the cloud server, and updates the locally recorded cloud folder directory based on the at least one file, to obtain the cloud directory. That is, the changed file can be regarded as an incremental action in the file, and after the client obtains the incremental file, the client can perform incremental synchronization according to the file object set, thereby improving the file synchronization efficiency.
[0100] Specifically, if the file object set includes at least one file, the at least one file is pulled through the cloud server. For each pulled file, it is checked whether the file exists in the locally recorded cloud folder directory, if not, the file information is added in the corresponding position; if yes, the related information of the file, such as the file content, the modification time, etc., is updated. Based on the above operation, the locally recorded cloud folder directory is updated to obtain the cloud directory. If the file object set includes at least one folder, the files under the at least one folder are pulled through the cloud server. For each pulled folder and the files thereunder, it is checked whether the folder exists in the locally recorded cloud folder directory, if not, the information of the folder and all the files thereunder is added in the corresponding position; if yes, the related information of the folder and the files thereunder is updated. Based on the above operation, the locally recorded cloud folder directory is updated to obtain the cloud directory.
[0101] Case 2: If the file object set includes at least one folder, the client pulls the files under at least one subfolder through the cloud server, and updates the locally recorded cloud folder directory based on the files, to obtain the cloud directory. That is, the changed subfolder is regarded as a deletion action in the subfolder, so that after the client obtains the changed subfolder, the client can directly pull the files under the changed subfolder, and update the changed subfolder, thereby improving the file synchronization efficiency.
[0102] For example, still referring to FIG. 4, the client reconstructs the locally recorded cloud folder directory according to the file 3, and pulls all the files under the subfolder 1 from the cloud server again, reconstructs the locally recorded cloud folder directory, and updates the SSN of the file 3 and the subfolder 1 recorded in the client. The updated SSN of the subfolder 1 is the timestamp generated by the server clock at the time of the deletion of the file 2, and the updated SSN of the file 3 is the timestamp generated by the server clock at the time of the modification of the file 3. Similarly, in each subsequent detection period, incremental detection can be performed, so that the remote folder directory recorded in the client can be updated in real time according to the data in the cloud server.
[0103] In a second possible implementation, the client acquires cloud state information of each file object in the cloud folder according to a set detection period; for each detection period, if it is determined, based on the cloud state information and the local state information of each file object in the current detection period, that at least one file object has changed, the cloud folder directory cached locally is updated based on the at least one file object.
[0104] That is, the client can periodically acquire the SSN' of each file object in the cloud folder through the cloud server, and then filter the changed file object from each file object according to the SSN of each file object recorded in the client and in combination with the SSN' of each file object, and then update the cloud folder directory recorded locally according to the changed file object. In this way, when performing the current file synchronization, the client takes the cloud directory recorded currently locally as the cloud directory.
[0105] Since the process of determining the changed file object by the client and the process of updating the cloud folder directory recorded locally according to the changed file object are the same as those in the first possible implementation, they will not be described herein again.
[0106] For example, referring to FIG. 5, which is a schematic diagram of another logic for constructing a cloud folder directory provided in an embodiment of the present application.
[0107] First, the client sends a query request for acquiring the cloud folder to the cloud server. After receiving the query request, the cloud server returns the current cloud folder and the SSN' of each file and each subfolder in the current cloud folder to the client.
[0108] The client obtains the SSN of the initialized cloud folder directory and each file object recorded locally based on the received SSN' of the cloud folder and each file object. The directory structure of the initialized cloud folder directory is the same as that of the current cloud folder in the cloud server, and the SSN of the subfolder 1, the subfolder 2, the file 1, the file 2, the file 3 and the file 4 recorded in the client is the same as the received SSN'.
[0109] Suppose that the operation triggered by the target object on the cloud folder includes editing and then deleting the file 2 in the subfolder 1, and editing the file 3 in the subfolder 2. The subfolder 1, the file 2 and the file 3 all have target processing operations, and therefore the value of the SSN' of the subfolder 1, the file 2 and the file 3 increases.
[0110] In the first detection cycle, the client sends a detection request to the cloud server, and the cloud server returns the SSN' of the subfolder 1, the subfolder 2, the file 1, the file 2, the file 3 and the file 4 to the client after receiving the detection request. The client compares the corresponding SSN and SSN' for the subfolder 1, the subfolder 2, the file 1, the file 2 and the file 3, respectively. At this time, the SSN' of the subfolder 1 is greater than the SSN of the subfolder 1, the SSN' of the file 2 is greater than the SSN of the file 2, the SSN' of the file 3 is greater than the SSN of the file 3, the subfolder 1, the file 2 and the file 3 all change, but since the file 2 is a file in the folder 1, the subfolder 1 is regarded as a changed subfolder, and the file 3 is regarded as a changed file.
[0111] Then, the client reconstructs the cloud folder directory recorded locally according to the file 3, and re-pulls all the files under the subfolder 1 from the cloud server, reconstructs the cloud folder directory recorded locally, and updates the SSN of the file 3 and the subfolder 1 recorded in the client.
[0112] Similarly, in each subsequent detection cycle, incremental file detection can be performed, so that the remote folder directory recorded in the client can be updated in real time according to the data in the cloud server.
[0113] It should be noted that in the embodiments of the present application, only the generation and update of the SSN by using the server clock are taken as examples for description, and other ways of generating and updating the SSN can also be used in actual application.
[0114] In a possible implementation, when the local folder directory recorded by the client and the cloud folder directory remain stable for a period of time, it is considered that the current synchronization task is to be started, and the current file synchronization is triggered at this time, the cached local folder directory, the local folder directory and the synchronization directory are obtained, and subsequent processing is performed.
[0115] It should be noted that the local folder directory and the cloud folder directory can also be persisted, for example, the local folder directory and the cloud folder directory are stored in a database, in which case the client can obtain the local directory and the cloud directory through the database.
[0116] S202, based on the local directory, the cloud directory and the synchronization directory, a set of local change operations occurring in the local folder from the last file synchronization to the synchronization time is obtained, and a set of cloud change operations occurring in the cloud folder is obtained.
[0117] In the embodiment of the present application, the client can obtain the set of local change operations that occur in the local folder from the completion of the last file synchronization to the synchronization time based on the local directory and the synchronization directory, and can obtain the set of cloud change operations that occur in the cloud folder from the completion of the last file synchronization to the synchronization time based on the cloud directory and the synchronization directory. The obtaining process of the set of local change operations and the set of cloud change operations is similar, and below, only the local change operations are described.
[0118] The set of local change operations refers to a set of operations that occur in the local folder from the completion of the last file synchronization to the synchronization time, and the operations include but are not limited to adding, deleting, modifying, and moving operations of files or sub-folders. The set of cloud change operations refers to a set of operations that occur in the cloud folder from the completion of the last file synchronization to the synchronization time, and the operations include but are not limited to adding, deleting, modifying, and moving operations of files or sub-folders.
[0119] Specifically, in the embodiment of the present application, the set of local change operations is obtained by the following method:
[0120] The client compares the directory positions of each synchronization file object in the synchronization directory with the directory position of one local file object in each local file object in the local directory based on the directory structure of the local directory.
[0121] The directory positions of each synchronization file object in the synchronization directory are compared with the directory position of one local file object in each local file object.
[0122] Based on the comparison result, a reference change operation corresponding to the local file object is determined.
[0123] Based on the reference change operation corresponding to each local file object, the set of local change operations that occur in the local folder from the completion of the last file synchronization to the synchronization time is obtained.
[0124] The reference change operation is the operation corresponding to the local file object determined by the client based on the comparison result of the directory positions of the local file object in the local directory and the synchronization file object in the synchronization directory, and is used to obtain the set of local change operations that occur in the local folder from the completion of the last file synchronization to the synchronization time.
[0125] In this paper, the process of comparing the local directory with the synchronization directory and outputting the set of local change operations can also be referred to as the Diff process.
[0126] In one possible implementation, the client uses hierarchical traversal to sequentially traverse each local file object in the local directory based on the directory structure of the local directory. The local file object can be a file in the local folder or a sub-folder in the local folder.
[0127] For example, refer to Fig. 6, which is a schematic diagram of a local directory and a synchronization directory provided in an embodiment of the present application. It is assumed that the root directory of the local directory contains a subfolder "game", a subfolder "movie" and a subfolder "work", wherein the subfolder "game" contains a file "planning scheme 1.txt", and the subfolder "work" contains files "proposal 1.doc" and "proposal 3.doc". The root directory of the synchronization directory contains a subfolder "game", a subfolder "work" and a file "movie.txt", wherein the subfolder "game" contains a file "planning scheme 2.txt", and the subfolder "work" contains files "proposal 1.doc" and "proposal 3.txt". The client traverses each local file object in the local directory in turn based on the directory structure of the local directory by using hierarchical traversal, for example, in the order of subfolder "game" -> subfolder "movie" -> subfolder "work" -> file "planning scheme 1.txt" -> "proposal 1.doc" -> and "proposal 3.doc", and traverses each local file object in the local directory in turn. Upon traversing to each local file object, the client compares the directory position of each synchronization file object (subfolder "game", subfolder "work", file "movie.txt", "planning scheme 2.txt", "proposal 1.doc" and "proposal 3.txt") in the synchronization directory with the directory position of the local file object respectively, and determines the reference change operation corresponding to the local file object based on the comparison result.
[0128] In a possible implementation, when the client compares the directory position of each synchronization file object in the synchronization directory with the directory position of the local file object respectively, the directory position of the synchronization file object and the directory position of the local file object can be compared to determine whether they are the same. The directory position is used to represent the route from the root directory to the file object, and the directory position can also be referred to as a path, for example, the directory position of the subfolder "game" in the local directory is: root directory / game.
[0129] In a possible implementation, when the reference change operation corresponding to a local file object is determined based on the comparison result, there can be, but are not limited to, the following possible cases:
[0130] Case A, if the comparison result indicates that there is a synchronization file object with the same directory position as a local file object, the reference change operation corresponding to the local file object is determined based on the object type of the local file object and the synchronization file object.
[0131] It is assumed that X represents the local file object, and Y represents the synchronization file object with the same directory position as X.
[0132] In some embodiments, the directory locations of the local file object and the synchronization file object are represented by file names, and since sub-folders and files can have the same name, X and Y can be the same object type or different object types, and the reference change operation determined for X can be different in different cases. The following describes the several possible cases.
[0133] Case A-1, X and Y are both sub-folders.
[0134] If X and Y are both sub-folders, the client further obtains the file identifiers of X and Y respectively (if the hash value of the file content is used as the file identifier), and compares the two hash values to determine whether they are equal. If the hash values are equal, it is determined that X and Y are the same folder, and X has not changed. If the hash values are not equal, it is determined that X and Y are different folders, and X has changed. The file identifier is used to uniquely identify a file object, and the file identifier can be the hash value of the file content, but is not limited thereto.
[0135] In the case where X and Y are different folders, the client can further determine whether there is a synchronization file object with the same file identifier as X in the file hash table corresponding to the synchronization directory (denoted as srcnode). If there is, it is determined that the reference change operation of X includes the operation of deleting the synchronization file object with the same file identifier as X in the synchronization directory and updating the file identifier of the sub-folder X. If there is not, it is determined that the reference change operation of X is to update the file identifier of the folder X.
[0136] The file hash table is a data structure used to store and retrieve file identifiers. The hash table maps file identifiers to array indices, enabling fast lookup, insertion, and deletion operations, thereby greatly improving the efficiency of file management. The file system uses the hash table to quickly find file metadata such as permissions, creation time, size, etc., without having to traverse the entire directory tree.
[0137] For example, referring to FIG. 7A, for the local directory and the synchronization directory in FIG. 6, when the client traverses to the sub-folder "game", the synchronization directory contains a synchronization file object with the same directory location: sub-folder "game". Therefore, the client further determines whether the file identifier of the sub-folder "game" under the local directory is the same as that of the sub-folder "game" under the synchronization directory. Assuming that the file identifiers of the sub-folders "game" under the local directory and the synchronization directory are the same, the client determines that the sub-folder "game" under the local directory has not changed.
[0138] Case A-2, X and Y are both files.
[0139] If X and Y are both files, the client further determines whether the file identifiers of X and Y are the same.
[0140] If the file identifiers of X and Y are the same, the client can compare the metadata of X and Y, and if the metadata of X and Y are the same, it is determined that X has no change, and if the metadata of X and Y are different, it is determined that the reference change operation of X is a modification operation. The metadata includes, but is not limited to, one or more of the modification time, the file size, etc.
[0141] If the file identifiers of X and Y are different, the client further detects whether X has been moved, and if X has not been moved, it is determined that the reference change operation of X is a modification operation, and if X has been moved, there are three file objects: the X before the move in the synchronization directory (denoted as srcnode), X and Y. In the case that the metadata of X and srcnode are the same, and the file contents of X and Y are the same, it is determined that the reference change operation of X is a delete operation and the file identifier of the file is updated. In the case that the metadata of X and srcnode are the same, but the file contents of X and Y are different, it is determined that the reference change operation of X is a move operation and a delete operation. In the case that the metadata of X and srcnode are different, it is determined that the reference change operation of X is a modification operation and a delete operation.
[0142] For example, referring to FIG. 7B, when the client traverses to the file “Proposal 1.doc” under the subfolder “Work”, the synchronization directory contains a synchronization file object with the same directory location: the file “Proposal 1.doc” under the subfolder “Work”. Here, the file “Proposal 1.doc” in the local directory corresponds to X, and the file “Proposal 1.doc” in the synchronization directory corresponds to Y. At this time, the client further judges whether the file identifiers of the file “Proposal 1.doc” in the local directory and the file “Proposal 1.doc” in the synchronization directory are the same. It is assumed that the file identifiers of the two are different, and in the hash table corresponding to the synchronization directory, there is a synchronization file with the same file identifier as the file “Proposal 1.doc” in the local directory, and the metadata and file contents of the synchronization file and the file “Proposal 1.doc” in the local directory are all different. At this time, the client determines that the reference change operation corresponding to the file “Proposal 1.doc” in the local directory is a move operation and a delete operation.
[0143] Case A-3, X and Y, one is a file and the other is a subfolder.
[0144] If X and Y, one is a file, the other is a subfolder, then the client further judges whether X has moved, if X has not moved, the reference change operation of X is delete operation and add operation, if X has moved, at this time there will be 3 file objects: X before moving in the synchronization directory (recorded as srcnode), X and Y, then in the case of X being a file, srcnode being a subfolder, and X and srcnode having the same file identifier, it is determined that the reference change operation of X is delete operation and move operation, in the case of X being a file, srcnode being a subfolder, and X and srcnode having different file identifiers, it is determined that the reference change operation of X is delete operation and add operation, in the case of srcnode being a file, X being a subfolder, it is determined that the reference change operation of X is delete operation and add operation.
[0145] Case B, if the comparison result represents that there is no synchronization file object with the same directory location as one local file object, based on the respective file identifiers of each synchronization file object, the reference change operation corresponding to one local file object is determined.
[0146] Specifically, the client searches in the file hash table corresponding to the synchronization directory with X's file identifier as the key based on the respective file identifiers of each synchronization file object. If no synchronization file object with the same file identifier is found, it is determined that the reference change operation of X is add operation; if a synchronization file object with the same file identifier is found (recorded as srcnode), based on the file types of X and srcnode, the reference change operation corresponding to X is determined.
[0147] Among them, when determining the reference change operation corresponding to one local file object based on the file types of X and srcnode, there are but not limited to the following possible cases:
[0148] Case B-1: the paths of X and srcnode are the same, and both are folders. At this time, the client determines that the reference change operation of X is move operation.
[0149] Case B-2: the paths of X and srcnode are the same, and both are files. In the case that the metadata of srcnode and X are all the same, the client determines that the reference change operation of X is move operation, in the case that the metadata of srcnode and X are different, it is determined that the reference change operation of X is modification operation.
[0150] Case B-3: the path of X is different from the path of the srcnode, and both are files. In the case that the metadata of the srcnode and X are all the same, the client determines that the reference change operation of X is a move operation, and in the case that the metadata of the srcnode and X are different, the client determines that the reference change operation of X is a delete operation and an add operation.
[0151] In some cases, if the client identifies that a delete operation occurs locally for the target file object, the reference change operation further includes a delete operation for the target file object in the cloud directory. Further, when the client performs the delete operation, if the SSN of the file object to be deleted changes, it indicates that the content of the file object may change, and then the delete operation can not be performed.
[0152] S203, difference analysis is performed on the local change operation set and the cloud change operation set, and based on the analysis result, each target change operation to be executed in this file synchronization is planned.
[0153] The target change operation refers to an operation that needs to be executed in this file synchronization after difference analysis is performed on the local change operation set and the cloud change operation set, and the purpose is to keep the file contents of the local folder and the cloud folder consistent.
[0154] Specifically, when S203 is executed, the following steps can be used, but are not limited to:
[0155] S203-1, the client obtains, based on a set instruction generation manner, a local executable instruction corresponding to each local change operation in the local change operation set, and obtains, based on the instruction generation manner, a cloud executable instruction corresponding to each cloud change operation in the cloud change operation set.
[0156] The local executable instruction is a instruction converted according to each local change operation in the local change operation set according to a set instruction generation manner, and is used to instruct to execute a corresponding operation on the local folder.
[0157] In the embodiment of the application, the local change operation includes one or more of an add operation, a delete operation, a modify operation, a move operation, and no operation. The add operation includes one or more of a file add operation and a folder add operation, the delete operation includes one or more of a file delete operation and a folder delete operation, the modify operation includes one or more of a file modify operation and a folder modify operation, and the move operation includes one or more of a file move operation and a folder move operation.
[0158] The set instruction generation manner can be as follows: the adding operation corresponds to the adding instruction {operation: 'add', path: 'file object path'}, the deleting operation corresponds to the deleting instruction {operation: 'del', path: 'file object path'}, the modifying operation corresponds to the modifying instruction {operation:'mod', path: 'file object path'}, the moving operation corresponds to the moving instruction {operation:'move', path: 'file object original path', newPath: 'file object new path'}, and the no operation corresponds to {-}.
[0159] Similarly, the cloud change operation includes one or more of the adding operation, the deleting operation, the modifying operation, the moving operation, and the no operation. The adding operation includes one or more of the file adding operation and the folder adding operation, the deleting operation includes one or more of the file deleting operation and the folder deleting operation, the modifying operation includes one or more of the file modifying operation and the folder modifying operation, and the moving operation includes one or more of the file moving operation and the folder moving operation.
[0160] Taking the file object 'A / a' as an example, A is a subfolder under the root directory, and a can be a file or a subfolder in the subfolder A. The local executable instruction includes one or more of the adding instruction {operation: 'add', path: 'A / a'}, the deleting instruction {operation: 'del', path: 'A / a'}, the modifying instruction {operation:'mod', path: 'A / a'}, the moving instruction {operation:'move', path: 'A / a', newPath: 'B / a'}, and the no operation {-}. The operation represents the operation type, and the path is used to indicate the file object on which the operation is performed.
[0161] In the set instruction generation manner, the adding operation corresponds to the adding instruction, the deleting operation corresponds to the deleting instruction, the modifying operation corresponds to the modifying instruction, the moving operation corresponds to the moving instruction, and the no operation corresponds to {-}.
[0162] For example, the adding operation is to add a file a under the folder A / . The client can convert the adding operation into the adding instruction {operation: 'add', path: 'A / a'}.
[0163] S203-2, based on the set instruction execution manner, performing rule rehearsal on the obtained local executable instructions and cloud executable instructions, and based on the rehearsal result, obtaining target change operations to be executed in this file synchronization.
[0164] The cloud executable instruction is an instruction obtained by converting each cloud change operation in the cloud change operation set according to a set instruction generation mode, and is used to instruct to perform a corresponding operation on the cloud folder.
[0165] The rule rehearsal refers to a process of analyzing and simulating execution of each local executable instruction and each cloud executable instruction based on a set instruction execution mode. Through the process, each target change operation to be executed in this file synchronization can be obtained.
[0166] In some embodiments, the specific process is as follows: first, the local executable instructions and the cloud executable instructions are sorted according to an instruction sorting rule, and the sorting rule includes that the execution of the delete instruction and the move instruction is prior to the execution of the add instruction and the modify instruction; for the delete instruction and the move instruction, the path layer is sorted, and the deeper layer is executed first, and the shallower layer is executed later; for the add instruction and the modify instruction, the path layer is sorted, and the shallower layer is executed first, and the deeper layer is executed later; if the above conditions are consistent, the cloud executable instruction is prior to the local executable instruction. Then, the sorted instructions are analyzed according to an instruction processing rule, and for different types of local executable instruction and cloud executable instruction combination, the target change operation to be executed is determined according to a preset rule, as shown in the above various cases of bidirectional synchronization. Based on the rule rehearsal result, each target change operation to be executed in this file synchronization is obtained.
[0167] The rule of the instruction execution mode can include that the execution of the delete instruction and the move instruction is prior to the execution of the add instruction and the modify instruction; for the delete instruction and the move instruction, the path layer is sorted, and the deeper layer is executed first, and the shallower layer is executed later; for the add instruction and the modify instruction, the path layer is sorted, and the shallower layer is executed first, and the deeper layer is executed later; if the above conditions are consistent, the cloud executable instruction is prior to the local executable instruction.
[0168] In a possible implementation manner, the instruction simulation process can be implemented in the following manner, but is not limited thereto:
[0169] The client sorts the local executable instructions and the cloud executable instructions according to a set instruction sorting rule, and analyzes the sorted results according to a set instruction processing rule to obtain a simulation result.
[0170] The instruction sorting rule includes at least one of the following rules 1-4:
[0171] Rule 1, the execution of the delete instruction and the move instruction is prior to the add instruction and the modify instruction. For example, the execution of the delete instruction {operation: 'del', path: 'A / a'} is prior to the add instruction {operation: 'add', path: 'B / a'}.
[0172] Rule 2, for the delete instruction and the move instruction, the path layer number is sorted, the deep layer number is executed first, and the shallow layer number is executed later. For example, the delete instruction {operation: 'del', path: 'A / a'} is executed earlier than the delete instruction {operation: 'del', path: 'A'}. For another example, the move instruction {operation:'move', path: 'A / a'} is executed earlier than the move instruction {operation:'move', path: 'A'}. The layer number can also be referred to as the directory level.
[0173] Rule 3, for the add instruction and the modify instruction, the path layer number is sorted, the shallow layer number is executed first, and the deep layer number is executed later. For example, the add instruction {operation: 'add', path: 'A'} is executed earlier than the add instruction {operation: 'add', path: 'A / a'}. For another example, the modify instruction {operation:'mod', path: 'A'} is executed earlier than the modify instruction {operation:'mod', path: 'A / a'}. The layer number can also be referred to as the directory level.
[0174] Rule 4, if the above conditions 1-3 are consistent, then the cloud executable instruction is prior to the local executable instruction.
[0175] In a possible implementation, different instruction processing rules can be set for bidirectional synchronization and unidirectional synchronization. This article only takes bidirectional synchronization as an example for description.
[0176] In the instruction processing rule for bidirectional synchronization, it is assumed that there is an add instruction {operation: 'add', path: 'A / a'} in each local executable instruction. According to the instruction type in the cloud executable instruction and the file object operated, there are the following situations:
[0177] Case 1: There is an add instruction {operation: 'add', path: 'A / a'} or a modify instruction {operation:'mod', path: 'A / a'} for the file object 'A / a' in each cloud executable instruction.
[0178] Case 1.1: 'A / a' in the local executable instruction and 'A / a' in the cloud executable instruction are both files.
[0179] If the final cloud folder and the file 'A / a' in the local file are equal, i.e., the local executable instruction and the cloud executable instruction do not conflict, the target change operation to be executed is {operation: 'updateTree', 'A / a'}, which represents updating 'A / a' in the synchronization directory.
[0180] If there is a conflict between the local executable instruction and the cloud executable instruction, select a target conflict processing mode from the conflict processing modes such as uploading the local to overwrite the cloud, downloading the cloud to overwrite the local, local renaming and uploading, etc. The target conflict processing mode can be selected by the target object after the conflict occurs, or can be pre-set by the target object, which is not limited.
[0181] If the target conflict processing mode is uploading the local to overwrite the cloud, the target change operation to be executed is {operation: 'upload', path: 'A / a'}, which represents uploading the file 'A / a'. If the target conflict processing mode is downloading the cloud to overwrite the local, the target change operation to be executed is {operation: 'download', path: 'A / a'}, which represents downloading the file 'A / a'. If the target conflict processing mode is local renaming and uploading, the target change operation to be executed includes: {operation:'moveLocal', path: 'A / a', newPath: 'A / a_timestamp'}, {operation: 'download', path: 'A / a'} and {operation: 'upload', path: 'A / a_timestamp'}, wherein {operation:'moveLocal', path: 'A / a', newPath: 'A / a_timestamp'} represents moving the file 'A / a' in the local folder to 'A / a_timestamp', {operation: 'download', path: 'A / a'} represents downloading the file 'A / a', and {operation: 'upload', path: 'A / a_timestamp'} represents uploading the file 'A / a_timestamp'.
[0182] Case 1.2: 'A / a' in the local executable instruction and 'A / a' in the cloud executable instruction are both folders. At this time, the target change operation to be executed is {operation: 'updateTree', 'A / a'}.
[0183] Case 1.3: 'A / a' in the local executable instruction and 'A / a' in the cloud executable instruction are one folder and one file.
[0184] If 'A / a' in the local executable instruction is a file, then the target change operation to be executed includes: {operation:'moveLocal', path: 'A / a', newPath: 'A / a_temp'}, {operation: 'upload', path: 'A / a_temp'}, {operation: 'createLocalFolder', path: 'A / a'}, {operation:'moveLocal', path: 'A / a', newPath: 'A / a_temp'} indicates moving 'A / a' to 'A / a_temp', {operation: 'upload', path: 'A / a_temp'} indicates uploading 'A / a_temp', and {operation: 'createLocalFolder', path: 'A / a'} indicates creating a folder 'A / a'. It should be noted that there can be a case of B / a / c→A / a / c in the cloud folder, at this time, {operation:'moveLocal', path: 'A / a', newPath: 'A / a_temp'} and {operation: 'upload', path: 'A / a_temp'} need to be inserted before all target change operations whose path starts with A / a.
[0185] If 'A / a' in the cloud executable instruction is a file, then the target change operation to be executed includes: {operation:'moveRemote', path: 'A / a', newPath: 'A / a_temp'}, {operation: 'download', path: 'A / a_temp'}, {operation: 'createRemoteFolder', path: 'A / a'}, {operation:'moveRemote', path: 'A / a', newPath: 'A / a_temp'} indicates moving 'A / a' to 'A / a_temp', {operation: 'download', path: 'A / a_temp'} indicates downloading 'A / a_temp', and {operation: 'createRemoteFolder', path: 'A / a'} indicates creating a folder 'A / a'. Similarly, there can be a case of B / a / c→A / a / c in the local folder, and at this time, {operation:'moveLocal', path: 'A / a', newPath: 'A / a_temp'} and {operation: 'upload', path: 'A / a_temp'} need to be inserted before all target change operations whose paths start with A / a.
[0186] Case 2: In each cloud executable instruction, there is a move instruction {operation:'move', path: 'A / a', newPath: 'B / a'} for the file object 'A / a'.
[0187] Case 2.1: 'A / a' in the local executable instruction and 'A / a' in the cloud executable instruction are both files. The target change operation to be executed includes: {operation: 'del', path: 'B / a'}, {operation: 'add', path: 'A / a'}, wherein {operation: 'del', path: 'B / a'} indicates deleting 'B / a', and {operation: 'add', path: 'A / a'} indicates adding 'A / a'.
[0188] Case 2.2: 'A / a' in the local executable instruction and 'A / a' in the cloud executable instruction are both folders. The target change operations to be executed include: {operation: 'deleteLocalFolder', path: 'B / a'}, {operation: 'updateTree', 'A / a'}, wherein {operation: 'deleteLocalFolder', path: 'B / a'} indicates deleting the local folder 'B / a', and {operation: 'updateTree', 'A / a'} indicates updating the synchronization tree according to 'A / a'.
[0189] Case 2.3: 'A / a' in the local executable instruction and 'A / a' in the cloud executable instruction are one folder and one file.
[0190] If 'A / a' in the local executable instruction is a file, then the target change operations to be executed include: {operation:'moveLocal', path: 'A / a', newPath: 'A / a_temp'}, {operation: 'upload', path: 'A / a_temp'}, {operation:'moveLocalFolder', path: 'B / a', newPath: 'A / a'}, {operation:'moveLocal', path: 'A / a', newPath: 'A / a_temp'} indicates moving 'A / a' to 'A / a_temp', {operation: 'upload', path: 'A / a_temp'} indicates uploading 'A / a_temp', and {operation:'moveLocalFolder', path: 'B / a', newPath: 'A / a'} indicates moving the local folder from 'B / a' to 'A / a'. Since there can be a case of B / a / c→A / a / c in the cloud folder, at this time, {operation:'moveLocal', path: 'A / a', newPath: 'A / a_temp'} and {operation: 'upload', path: 'A / a_temp'} need to be inserted before all target change operations whose paths start with A / a.
[0191] If the 'A / a' in the cloud executable instruction is a file, because the cloud performs a move operation on the 'A / a' to 'B / a', and the local believes that the 'A / a' is a file and has a corresponding operation, in order to make the local and the cloud state consistent, it is necessary to first delete 'B / a' (that is, {operation: 'del', path: 'B / a'}), and then add 'A / a' (that is, {operation: 'add', path: 'A / a'}), so the target change operation to be executed is: {operation: 'del', path: 'B / a'} and {operation: 'add', path: 'A / a'}.
[0192] Case 3: In each cloud executable instruction, there is a delete instruction {operation: 'del', path: 'A / a'} for the file object 'A / a'. At this time, because the file and the folder have the same name, there may be a case that the 'A / a' in the local executable instruction and the 'A / a' in the cloud executable instruction are one folder and one file.
[0193] If the 'A / a' in the local executable instruction is a file, then the target change operation to be executed is: {operation: 'upload', path: 'A / a'} (uploading 'A / a').
[0194] If the 'A / a' in the cloud executable instruction is a file, then the target change operation to be executed is: {operation: 'createRemoteFolder', path: 'A / a'} (creating a cloud subfolder 'A / a').
[0195] Case 4: In each cloud executable instruction, there is no operation for the file object 'A / a'.
[0196] Case 4.1: The 'A / a' in the local executable instruction is a file. At this time, the target change operation to be executed is {operation: 'upload', path: 'A / a'}. In addition, it is necessary to judge whether there is a folder with the same name in the cloud folder, if there is, then rename the upload, and the rename upload operation needs to be inserted before all path A / a operations, to avoid that there is a file 'A / a' under the original cloud folder.
[0197] Case 4.2: The 'A / a' in the local executable instruction is a folder. At this time, the target change operation to be executed is: {operation: 'createRemoteFolder', path: 'A / a'} (creating a local subfolder 'A / a').
[0198] In the instruction processing rule for bidirectional synchronization, it is assumed that there is a delete instruction {operation: 'del', path: 'A / a'} in each local executable instruction. According to the instruction type in the cloud executable instruction and the file object on which the operation is performed, there are the following cases:
[0199] Case 5: There is a delete instruction {operation: 'del', path: 'A / a'} (delete 'A / a') for the file object 'A / a' in each cloud executable instruction.
[0200] Case 5.1: 'A / a' in the local executable instruction and 'A / a' in the cloud executable instruction are both files. At this time, the target change operation to be executed is {operation: 'updateTree', 'A / a'}.
[0201] Case 5.2: 'A / a' in the local executable instruction and 'A / a' in the cloud executable instruction are both folders. At this time, the target change operation to be executed is {operation: 'updateTree', 'A / a'}.
[0202] Case 6: There is a modify instruction {operation:'mod', path: 'A / a'} for the file object 'A / a' in each cloud executable instruction.
[0203] Case 6.1: 'A / a' in the local executable instruction and 'A / a' in the cloud executable instruction are both files.
[0204] If the file object 'A / a' does not exist in the local folder, then the target change operation to be executed is {operation: 'download', path: 'A / a'} (download 'A / a').
[0205] If the file object 'A / a' exists in the local folder, then the target change operation to be executed includes {operation:'moveRemote', path: 'A / a', newPath: 'A / a_temp'} (move 'A / a' in the cloud folder to 'A / a_temp') and {operation: 'download', path: 'A / a_temp'} (download 'A / a_temp').
[0206] Since there is no modify operation for a folder, there is no case where 'A / a' in the local executable instruction and 'A / a' in the cloud executable instruction are both folders.
[0207] Case 7: In each cloud executable instruction, there is a move instruction for file object 'A / a' {operation:'move', path: 'A / a', newPath: 'B / a'}. (Move a under folder A to folder B)
[0208] Case 7.1: 'A / a' in local executable instruction and 'A / a' in cloud executable instruction are both files. At this time, the target change operation to be executed is: {operation: 'deleteRemote', path: 'B / a'} (delete file 'B / a' in cloud folder), and {operation: 'deleteRemote', path: 'B / a'} needs to be inserted before each target change operation for folder B.
[0209] Case 7.2: 'A / a' in local executable instruction and 'A / a' in cloud executable instruction are both folders. At this time, the target change operation to be executed is: {operation: 'deleteRemoteFolder', path: 'B / a'} (delete subfolder 'B / a' in cloud folder), and {operation: 'deleteRemoteFolder', path: 'B / a'} needs to be inserted before each target change operation for folder B.
[0210] Case 8: In each cloud executable instruction, there is no operation for file object 'A / a'.
[0211] Case 8.1: 'A / a' in local executable instruction is a file. At this time, the target change operation to be executed is: {operation: 'deleteRemote', path: 'A / a'} (delete file 'A / a' in cloud folder).
[0212] Case 8.2: 'A / a' in local executable instruction is a folder. At this time, the target change operation to be executed is: {operation: 'deleteRemoteFolder', path: 'B / a'} (delete subfolder 'A / a' in cloud folder).
[0213] In the instruction processing rules for bidirectional synchronization, it is assumed that there is a modification instruction {operation:'mod', path: 'A / a'} in each local executable instruction. According to the instruction type in the cloud executable instruction and the file object being operated, there are the following cases:
[0214] Case 9: In each cloud executable instruction, there is an add instruction {operation: 'add', path: 'A / a'} for file object 'A / a' (add 'A / a').
[0215] Case 9.1: 'A / a' in the local executable instruction and 'A / a' in the cloud executable instruction are both files.
[0216] If the final cloud folder and the file 'A / a' in the local file are equal, i.e., the local executable instruction and the cloud executable instruction do not conflict, the target change operation to be executed is {operation: 'updateTree', 'A / a'}.
[0217] If there is a conflict between the local executable instruction and the cloud executable instruction, select a target conflict handling mode from the conflict handling modes of uploading the local to overwrite the cloud, downloading the cloud to overwrite the local, local renaming and uploading, etc. The target conflict handling mode can be selected by the target object after the conflict occurs, or it can be pre-set by the target object, which is not limited.
[0218] If the target conflict handling mode is uploading the local to overwrite the cloud, the target change operation to be executed is {operation: 'upload', path: 'A / a'} (upload file 'A / a'). If the target conflict handling mode is downloading the cloud to overwrite the local, the target change operation to be executed is {operation: 'download', path: 'A / a'} (download file 'A / a'). If the target conflict handling mode is local renaming and uploading, the target change operation to be executed includes: {operation:'moveLocal', path: 'A / a', newPath: 'A / a_timestamp'} (move file 'A / a' in the local folder to 'A / a_timestamp'), {operation: 'download', path: 'A / a'} (download file 'A / a'), and {operation: 'upload', path: 'A / a_timestamp'} (upload file 'A / a_timestamp').
[0219] Case 9.2: 'A / a' in the local executable instruction and 'A / a' in the cloud executable instruction are one folder and one file.
[0220] The target change operations to be executed include: {operation:'moveRemote', path: 'A / a', newPath: 'A / a_temp'}, {operation: 'download', path: 'A / a_temp'}, {operation: 'createRemoteFolder', path: 'A / a'}, {operation:'moveRemote', path: 'A / a', newPath: 'A / a_temp'} indicate moving 'A / a' to 'A / a_temp', {operation: 'download', path: 'A / a_temp'} indicates downloading 'A / a_temp', and {operation: 'createRemoteFolder', path: 'A / a'} indicates creating a folder 'A / a'. {operation:'moveLocal', path: 'A / a', newPath: 'A / a_temp'} and {operation: 'upload', path: 'A / a_temp'} need to be inserted before all target change operations whose paths start with A / a.
[0221] Case 10: In each cloud executable instruction, there is a modification instruction {operation:'mod', path: 'A / a'} for the file object 'A / a' (modifying 'A / a').
[0222] Case 10.1: 'A / a' in the local executable instruction and 'A / a' in the cloud executable instruction are both files.
[0223] If the final cloud folder and the file 'A / a' in the local file are equal, that is, the local executable instruction and the cloud executable instruction do not conflict, then the target change operation to be executed is {operation: 'updateTree', 'A / a'}.
[0224] If there is a conflict between the local executable instruction and the cloud executable instruction, a target conflict processing mode is selected from the conflict processing modes such as uploading the local to overwrite the cloud, downloading the cloud to overwrite the local, local renaming uploading, and the like. The target conflict processing mode can be selected by the target object after the conflict occurs, or can be set by the target object in advance, and no limitation is made in this regard.
[0225] If the target conflict handling mode is to upload local to override cloud, the target change operation to be executed is {operation: 'upload', path: 'A / a'} (upload file 'A / a'). If the target conflict handling mode is to download cloud to override local, the target change operation to be executed is {operation: 'download', path: 'A / a'} (download file 'A / a'). If the target conflict handling mode is to rename local and upload, the target change operations to be executed include: {operation:'moveLocal', path: 'A / a', newPath: 'A / a_timestamp'} (move file 'A / a' in local folder to 'A / a_timestamp'), {operation: 'download', path: 'A / a'} (download file 'A / a'), and {operation: 'upload', path: 'A / a_timestamp'} (upload file 'A / a_timestamp').
[0226] Case 11: In each cloud executable instruction, there is a delete instruction {operation: 'del', path: 'A / a'} (delete 'A / a') for file object 'A / a'.
[0227] Case 11.1: 'A / a' in local executable instruction and 'A / a' in cloud executable instruction are both files.
[0228] If there is no file 'A / a' in local folder, the target change operation to be executed is: {operation: 'upload', path: 'A / a'} (upload 'A / a').
[0229] If there is file 'A / a' in local folder, the target change operations to be executed include: {operation:'moveLocal', path: 'A / a', newPath: 'A / a_temp'} (move 'A / a' in local folder to 'A / a_temp'), {operation: 'upload', path: 'A / a_temp'} (upload file 'A / a_temp').
[0230] Case 12: In each cloud executable instruction, there is a move instruction {operation:'move', path: 'A / a', newPath: 'B / a'} (move 'a' under folder A to folder B) for file object 'A / a'.
[0231] Case 12.1: 'A / a' in the local executable instructions and 'A / a' in the cloud executable instructions are both files.
[0232] If file 'B / a' does not exist in the local folder, the target change operation to be executed includes: {operation:'moveLocal', path: 'A / a', newPath: 'B / a'} (moving 'A / a' in the local folder to 'B / a'), {operation: 'upload', path: 'A / a'} (uploading 'A / a').
[0233] If file 'B / a' exists in the local folder, the target change operation to be executed includes: {operation: 'add', path: 'B / a'}, {operation: 'del', path: 'A / a'}.
[0234] Case 13: There is no operation for file object 'A / a' in each cloud executable instruction.
[0235] Case 13.1: 'A / a' in the local executable instructions and 'A / a' in the cloud executable instructions are both files. At this time, the target change operation to be executed includes: {operation: 'upload', path: 'A / a'} (uploading file 'A / a').
[0236] In the instruction processing rules for bidirectional synchronization, it is assumed that there is a move instruction {operation:'move', path: 'A / a', newPath: 'B / a'} in each local executable instruction. According to the instruction type in the cloud executable instruction and the file object on which the operation is performed, there are the following cases:
[0237] Case 14: There is a delete instruction {operation: 'del', path: 'A / a'} (deleting 'A / a') for file object 'A / a' in each cloud executable instruction.
[0238] Case 14.1: 'A / a' in the local executable instructions and 'A / a' in the cloud executable instructions are both files. At this time, the target change operation to be executed is: {operation: 'delLocal', path: 'B / a'} (deleting file 'B / a' in the local folder), and {operation: 'delLocal', path: 'B / a'} needs to be inserted before each target change operation for folder B.
[0239] Case 14.2: 'A / a' in the local executable instruction and 'A / a' in the cloud executable instruction are both folders. At this point, the target change operations to be executed include: {operation: 'delLocalFolder', path: 'B / a'} (delete the subfolder 'B / a' in the local folder), {operation: 'updateTree', 'A / a'}. {operation: 'delLocalFolder', path: 'B / a'} needs to be inserted before each target change operation for folder B.
[0240] Case 15: In each cloud executable instruction, there is a modification instruction {operation:'mod', path: 'A / a'} (modify 'A / a') for the file object 'A / a'.
[0241] Case 15.1: 'A / a' in the local executable instruction and 'A / a' in the cloud executable instruction are both files.
[0242] If there is no file 'B / a' in the cloud folder, then the target change operations to be executed include: {operation:'moveRemote', path: 'A / a', newPath: 'B / a'} (move 'A / a' in the cloud folder to 'B / a'), {operation: 'download', path: 'B / a'} (download the file 'B / a').
[0243] If there is a file 'B / a' in the cloud folder, then the target change operations to be executed include: {operation: 'add', path: 'B / a'} (add 'B / a'), {operation: 'del', path: 'A / a'} (delete 'A / a').
[0244] Case 16: In each cloud executable instruction, there is an addition instruction {operation: 'add', path: 'A / a'} (add 'A / a') for the file object 'A / a'.
[0245] Case 16.1: 'A / a' in the local executable instruction and 'A / a' in the cloud executable instruction are both files.
[0246] A possible implementation, if the 'A / a' in the local folder and the 'A / a' in the cloud folder are equal, then the target change operation to be executed includes: {operation: 'del', path: 'A / a'} (delete 'A / a'), and update the 'B / a' node of the synchronization tree, otherwise the target change operation to be executed includes: {operation: 'del', path: 'A / a'} (delete 'A / a') and {operation: 'add', path: 'B / a'} (add 'B / a') for the local folder.
[0247] A possible implementation, {operation: 'del', path: 'A / a'} (delete 'A / a') and {operation: 'add', path: 'B / a'} (add 'B / a') for the local folder can also be directly taken as the target change operation to be executed.
[0248] Case 16.2: The 'A / a' in the local executable instruction and the 'A / a' in the cloud executable instruction are both folders. The target change operation to be executed includes: {operation: 'deleteRemoteFolder', path: 'B / a'} (delete the subfolder 'A / a' in the cloud folder), {operation: 'updateTree', path: 'A / a'} (update the 'A / a' node in the synchronization folder directory).
[0249] Case 16.3: The 'A / a' in the local executable instruction and the 'A / a' in the cloud executable instruction are one folder and one file.
[0250] If the 'A / a' in the local executable instruction is a file, then the target change operation to be executed includes: {operation: 'del', path: 'A / a'} (delete 'A / a') and {operation: 'add', path: 'B / a'} (add 'B / a') for the local folder.
[0251] If 'A / a' in the cloud executable instruction is a file, the target change operation to be executed includes: {operation:'moveRemote', path: 'B / a', newPath: 'B / a_temp'} (move 'B / a' to 'B / a_temp'), {operation: 'download', path: 'B / a_temp'} (download 'B / a_temp'), {operation:'moveRemoteFolder', path: 'A / a', newPath: 'B / a'} (move 'A / a' to 'B / a'). Among them, {operation:'moveRemote', path: 'B / a', newPath: 'B / a_temp'} and {operation: 'download', path: 'B / a_temp'} are inserted before the target change operation of all paths starting with B / a / .
[0252] Case 17: In each cloud executable instruction, there is a move instruction {operation:'move', path: 'A / a', newPath: 'C / a'} for the file object 'A / a'. (Move a under folder A to folder C)
[0253] Case 17.1: 'A / a' in the local executable instruction and 'A / a' in the cloud executable instruction are both files.
[0254] If there is no file 'C / a' in the local folder, then the target change operation to be executed includes: {operation:'moveLocal', path: 'B / a', newPath: 'C / a'} (move 'B / a' in the local folder to 'C / a'). {operation:'moveLocal', path: 'B / a', newPath: 'C / a'} needs to be inserted before each target change operation for folder B.
[0255] If there is a file 'B / a' in the cloud folder, since the cloud performs a move operation on 'A / a' to 'C / a', and there is an operation on 'A / a' in the local and there is 'B / a' in the cloud, in order to make the local and the cloud state consistent, 'A / a' in the local needs to be deleted (i.e., {operation: 'del', path: 'A / a'}) first, and then 'B / a' is added (i.e., {operation: 'add', path: 'B / a'}), so the target change operations to be executed include: {operation: 'del', path: 'A / a'} (delete 'A / a'), {operation: 'add', path: 'B / a'} (add 'B / a').
[0256] Case 17.2: 'A / a' in the local executable instructions and 'A / a' in the cloud executable instructions are both folders.
[0257] If there is no folder 'C / a' in the local folder, then when the directory level of 'C / a' in the cloud folder is large, the target change operations to be executed include: {operation:'moveRemoteFolder', path: 'C / a', newPath: 'B / a'}, and when the directory level of 'B / a' in the cloud folder is large, the target change operations to be executed include: {operation:'moveRemoteFolder', path: 'B / a', newPath: 'C / a'}. {operation:'moveRemoteFolder', path: 'C / a', newPath: 'B / a'} needs to be inserted before each target change operation for folder C, and {operation:'moveRemoteFolder', path: 'B / a', newPath: 'C / a'} needs to be inserted before each target change operation for folder B.
[0258] If there is a folder 'C / a' in the local folder, then the target change operations to be executed include: {operation: 'del', path: 'A / a'} (delete 'A / a'), {operation: 'add', path: 'B / a'} (add 'B / a').
[0259] Case 18: In each cloud executable instruction, there is a move instruction for file object 'A / a' {operation:'move', path: 'A / a', newPath: 'B / a'} (move 'a' under folder A to folder B).
[0260] Case 18.1: Both 'A / a' in the local executable instruction and 'A / a' in the cloud executable instruction are files. At this time, the target change operation to be executed includes: {operation: 'updateTree', 'A / a', 'B / a'} (update the A / a node and the B / a node in the synchronization tree).
[0261] Case 18.2: Both 'A / a' in the local executable instruction and 'A / a' in the cloud executable instruction are folders. At this time, the target change operation to be executed includes: {operation: 'updateTree', 'A / a', 'B / a'} (update the A / a node and the B / a node in the synchronization tree).
[0262] Case 19: In each cloud executable instruction, there is a move instruction {operation:'move', path: 'C / a', newPath: 'B / a'} (move the file a under the folder C to the folder B).
[0263] Case 19.1: Both 'C / a' in the local executable instruction and 'C / a' in the cloud executable instruction are files.
[0264] Since the cloud performs a move operation on 'C / a' to 'B / a', in order to make the local and cloud states consistent, for the remote folder, 'C / a' needs to be deleted first (that is, {operation: 'del', path: 'C / a'}), and then 'B / a' is added (that is, {operation: 'add', path: 'B / a'}); for the local folder, 'C / a' also needs to be deleted first (that is, {operation: 'del', path: 'C / a'}), and then 'B / a' is added (that is, {operation: 'add', path: 'B / a'}). Therefore, the target change operation to be executed includes: for the remote folder, {operation: 'del', path: 'C / a'} (delete 'C / a') and {operation: 'add', path: 'B / a'} (add 'B / a'), and for the local folder, {operation: 'del', path: 'C / a'} (delete 'C / a') and {operation: 'add', path: 'B / a'} (add 'B / a').
[0265] Case 19.2: Both 'C / a' in the local executable instruction and 'C / a' in the cloud executable instruction are folders.
[0266] At this time, the target change operations to be executed include: {operation: 'del', path: 'C / a'} (delete 'C / a') and {operation: 'add', path: 'B / a'} (add 'B / a') for the remote folder, and {operation: 'del', path: 'C / a'} (delete 'C / a') and {operation: 'add', path: 'B / a'} (add 'B / a') for the local folder.
[0267] Case 19.3: 'C / a' in the local executable instruction and 'C / a' in the cloud executable instruction, one is a folder and one is a file.
[0268] If 'C / a' in the local executable instruction is a file, then the target change operations to be executed include: {operation: 'del', path: 'C / a'} (delete 'C / a') and {operation: 'add', path: 'B / a'} (add 'B / a') for the local folder.
[0269] If 'C / a' in the cloud executable instruction is a file, the target change operations to be executed include: {operation: 'del', path: 'C / a'} (delete 'C / a') and {operation: 'add', path: 'B / a'} (add 'B / a') for the remote folder.
[0270] Case 20.1: 'A / a' in the local executable instruction is a file.
[0271] If the file 'B / a' does not exist in the cloud folder, then the target change operations to be executed include: {operation:'moveRemote', path: 'A / a', newPath: 'B / a'} (move 'a' under the subfolder A in the cloud folder to the subfolder B). If 'A / a' exists in the local folder directory, then {operation:'moveRemote', path: 'A / a', newPath: 'B / a'} needs to be inserted before each target change operation for 'A / a'.
[0272] Case 20.2: 'A / a' in the local executable instructions is a folder. At this time, the target change operation to be executed includes: {operation:'moveRemoteFolder', path: 'A / a', newPath: 'B / a'} (move 'A / a' in the cloud folder to 'B / a').
[0273] For the instruction processing rules of bidirectional synchronization, if there is no operation for file object 'A / a' in each local executable instruction, according to the instruction type in the cloud executable instruction and the file object on which the operation is performed, there are the following cases:
[0274] Case 21: There is an add instruction for file object 'A / a' {operation: 'add', path: 'A / a'} (add 'A / a') in each cloud executable instruction.
[0275] Case 21.1: 'A / a' in the local executable instruction and 'A / a' in the cloud executable instruction are both files. At this time, the target change operation to be executed includes: {operation: 'download', path: 'A / a'} (download file 'A / a'). In some embodiments, since there may be a file folder with the same name in the local folder directory, the client can first detect whether there is a file folder with the same name in the local folder directory, if there is, rename the upload and insert before each target change operation for the file object starting with 'A / a'.
[0276] Case 21.2: 'A / a' in the local executable instruction and 'A / a' in the cloud executable instruction are both folders. At this time, the target change operation to be executed includes: {operation: 'createLocalFolder', path: 'A / a'} (create local folder 'A / a').
[0277] Case 22: There is a modify instruction for file object 'A / a' {operation:'mod', path: 'A / a'} (modify 'A / a') in each cloud executable instruction.
[0278] Case 22.1: 'A / a' in the local executable instruction and 'A / a' in the cloud executable instruction are both files. At this time, the target change operation to be executed includes: {operation: 'download', path: 'A / a'} (download file 'A / a').
[0279] Case 23: In each cloud executable instruction, there is a delete instruction {operation: 'del', path: 'A / a'} (delete 'A / a') for file object 'A / a'.
[0280] Case 23.1: 'A / a' in the local executable instruction and 'A / a' in the cloud executable instruction are both files. At this time, the target change operation to be executed includes: {operation: 'delLocal', path: 'A / a'} (delete local file 'A / a').
[0281] Case 23.2: 'A / a' in the local executable instruction and 'A / a' in the cloud executable instruction are both folders. At this time, the target change operation to be executed includes: {operation: 'deleteLocalFolder', path: 'A / a'} (delete local folder 'A / a').
[0282] Case 24: In each cloud executable instruction, there is a move instruction {operation:'move', path: 'A / a', newPath: 'B / a'} (move file object a).
[0283] Case 24.1: 'A / a' in the local executable instruction and 'A / a' in the cloud executable instruction are both files.
[0284] If there is no file object 'B / a' in the local directory, then the target change operation to be executed includes: {operation:'moveLocal', path: 'A / a', newPath: 'B / a'} (move file a). If there is a folder 'A / a' in the cloud directory, then {operation:'moveLocal', path: 'A / a', newPath: 'B / a'} needs to be inserted before each target change operation for file objects starting with 'A / a' to be executed.
[0285] If there is a file object 'B / a' in the local directory, then the target change operation to be executed includes: {operation: 'del', path: 'A / a'} (delete 'A / a'), {operation: 'add', path: 'B / a'} (add 'B / a') for the remote folder.
[0286] Case 24.2: 'A / a' in the local executable instruction and 'A / a' in the cloud executable instruction are both folders. At this time, the target change operation to be executed includes: {operation:'moveLocalFolder', path: 'A / a', newPath: 'B / a'} (move folder a).
[0287] In some embodiments, during the rule rehearsal process, there may be an execution conflict between the local executable instruction and the cloud executable instruction. To ensure the rule rehearsal process, in the embodiments of the present application, the client can select a target conflict handling mode from the candidate conflict handling modes provided by the target object to handle the conflict, so as to meet the different use requirements of different objects and improve the use experience of file synchronization.
[0288] Specifically, if there is an execution conflict between the local executable instruction and the cloud executable instruction during the rule rehearsal process, the client presents an operation interface including each candidate conflict handling mode to the target object, and in response to the selection operation of the target object on each candidate conflict handling mode, obtains the selected target conflict handling, and according to the target conflict handling, handles the conflict between the local executable instruction and the cloud executable instruction.
[0289] The candidate conflict handling mode includes but is not limited to uploading the local version to the cloud new version, using the cloud version to overwrite the local version, and retaining all conflict files.
[0290] When a conflict occurs between the local executable instruction and the cloud executable instruction, the client can pause the rule rehearsal, remember the context at the time of the conflict, and after the target object selects the target conflict handling mode, continue the rule rehearsal according to the target conflict handling mode. In this way, after the rule rehearsal, the target change operation can be obtained.
[0291] S204, based on the operation types of each target change operation, obtaining the execution order of each target change operation, and executing each target change operation in turn according to the execution order to complete this file synchronization.
[0292] In one possible implementation, based on the operation types of each target change operation, obtaining the execution order of each target change operation includes: grouping each target change operation based on the file execution path corresponding to each target change operation, combining the preset asynchronous execution information, obtaining each task group, the intra-group execution order between at least one target change operation included in each task group, and the inter-group execution order between each task group; and obtaining the execution order of each target change operation based on the inter-group execution order and the intra-group execution order corresponding to each task group.
[0293] The asynchronous execution information is preset information used to indicate execution manners of the target change operations, wherein the uploading local file operation and the downloading cloud file operation can be executed asynchronously, and other execution operations (the moving local file operation, the moving cloud file operation, the deleting local file operation and the deleting cloud file operation) need to be executed synchronously. According to the similarity of the file execution paths and the asynchrony of the operations, the target change operations are grouped by using the information.
[0294] The task group is a set obtained by grouping the target change operations based on the file execution paths corresponding to the target change operations respectively and the preset asynchronous execution information. Each task group contains at least one target change operation, and the target change operations in each task group have an intra-group execution order, and the task groups have an inter-group execution order.
[0295] The intra-group execution order refers to an execution sequence between the at least one target change operation in a task group. The sequence is determined according to the logic of the operations. For example, if the task group contains an adding operation and a modifying operation, the adding operation is usually executed first and then the modifying operation is executed.
[0296] The inter-group execution order refers to an execution sequence between the task groups. The sequence is determined according to the dependency relationship between the task groups. If the execution result of a task group A is a prerequisite for the execution of a task group B, the task group A is executed before the task group B.
[0297] In some embodiments, the target change operations are grouped based on the file execution paths corresponding to the target change operations respectively and the preset asynchronous execution information. The grouping method is as follows: for each target change operation, the prefix of the file execution path is checked. If the file execution paths of a plurality of target change operations have the same prefix and the operation types meet the asynchronous execution rule (for example, the uploading local file operation and the downloading cloud file operation can be executed asynchronously, and other execution operations need to be executed synchronously), the operations are grouped into a task group. For each task group, the intra-group execution order is determined according to the logic of the operations. For example, if the task group contains an adding operation and a modifying operation, the adding operation is usually executed first and then the modifying operation is executed. The inter-group execution order is determined according to the dependency relationship between the task groups. If the execution result of a task group A is a prerequisite for the execution of a task group B, the task group A is executed before the task group B. Based on the grouping result, the task groups, the intra-group execution order between the at least one target change operation contained in each task group respectively and the inter-group execution order between the task groups are obtained. Based on the inter-group execution order and the intra-group execution order corresponding to each task group respectively, the execution order of the target change operations is obtained.
[0298] In some embodiments, in the preset asynchronous execution information, the uploading local file operation and the downloading cloud file operation can be executed asynchronously, and other execution operations (moving local file operation, moving cloud file operation, deleting local file operation, and deleting cloud file operation) need to be executed synchronously. According to the similarity of the file execution path and the asynchrony of the operation, if the file execution paths of multiple target change operations have the same prefix, and the operation types meet the asynchronous execution rule, the operations are grouped into a task group. For each task group, the execution order in the group is determined according to the operation logic, and the execution order between the groups is determined according to the dependency relationship between the task groups. For example, if the task group contains an adding operation and a modifying operation, the adding operation is usually executed first and then the modifying operation is executed. According to the dependency relationship between the task groups, if the execution result of the task group A is a prerequisite for the execution of the task group B, the task group A is executed before the task group B.
[0299] For example, in the asynchronous execution information, the uploading local file operation and the downloading cloud file operation can be executed asynchronously, and other execution operations (moving local file operation, moving cloud file operation, deleting local file operation, and deleting cloud file operation) need to be executed synchronously. The target change operations in a task group can be executed in series or in parallel. The task groups can be executed in series or in parallel.
[0300] For example, in a task group, the task group list, the operation list, the type, and the mode can be included. The task group list or the operation list can be empty, the type can be ForGroup or ForItem, and the mode can be series or parallel.
[0301] For example, referring to FIG. 8, which is a schematic diagram of a task group provided in an embodiment of the present application. The target change operations include operation 1, operation 2, operation 3, operation 4, operation 5, operation 6, and operation 7. Operation 1, operation 2, and operation 3 belong to task group 1, operation 4 and operation 5 belong to task group 3, operation 6 and operation 7 belong to task group 4, task group 4 and task group 5 belong to task group 2, task group 2 and task group 3 belong to task group 0, and task group 0 is a root node. The execution order in task group 1 is operation 1→operation 2→operation 3 in series, the execution order in task group 3 is operation 4 and operation 5 in parallel, the execution order in task group 4 is operation 6 and operation 7 in parallel, and the execution order between task group 1 and task group 4 is task group 1 and task group 2 in parallel, and in task group 2, task group 3 is executed first and then task group 4 is executed. The data structure of a task group includes a task group list, an operation list, a type, and a mode. The type is ForGroup or ForItem, and the mode is series or parallel.
[0302] In a possible implementation, the client sequentially executes each target change operation in the execution order to complete the current file synchronization, including:
[0303] The client executes the following operations for each task group according to the inter-group execution order:
[0304] The at least one target change operation is sequentially executed based on the intra-group execution order between the at least one target change operation in a task group;
[0305] When the at least one target change operation is executed, the synchronization directory is updated.
[0306] For example, referring to FIG. 9, the task groups are stored in the task group queue, and the client can execute task group 1 and task group 2 in parallel according to the inter-group execution order by using the task group parallel resource and in combination with the maximum parallel number of the task group parallel resource. Since task group 3 and task group 4 in task group 2 need to be executed in series, task group 1 and task group 3 are executed in parallel. When the client executes task group 1 by using the task group serial resource, operation 1, operation 2, and operation 3 are sequentially converted into corresponding instructions based on the intra-group execution order of task group 2, and then the corresponding instructions are executed to obtain the execution result of task group 1. In addition, the synchronization folder directory is updated after the execution result indicates that all operations are successfully executed, where the instructions include but are not limited to downloading, uploading, local moving, cloud moving, local adding, and local deleting. Similarly, when the client executes task group 3 in parallel, operation 4 and operation 5 are sequentially converted into corresponding instructions based on the intra-group execution order of task group 3, and then the corresponding instructions are executed to obtain the execution result of task group 3. In addition, the synchronization folder directory is updated after the execution result indicates that all operations are successfully executed. After all operations in task group 3 are successfully executed, the client executes task group 4, and operation 6 and operation 7 in task group 4 are executed in parallel. After operation 6 and operation 7 are successfully executed, the synchronization folder directory is updated. When task group 3 and task group 4 are successfully executed, it is determined that task group 2 is successfully executed. When task group 1 and task group 2 are successfully executed, it is determined that the execution is successful, that is, the file synchronization is completed. During the execution, if an execution failure occurs, the current file synchronization can be paused, and subsequent processing can be performed according to the indication of the target object, such as re-performing file synchronization.
[0307] In some embodiments, when each task group is executed successfully, the client synchronizes the operation of the execution unit to the synchronization folder directory recorded in the client, so that the synchronization folder directory always maintains the consistency of the remote and local at the synchronization time. When all task groups are executed successfully, the current synchronization task is completed, and the information of synchronization success or synchronization failure is output. If the synchronization failure information appears, the detailed information of the operation execution failure can also be output to provide the user with the failure reason. Further, the next file synchronization is performed when the cloud or local folder is detected to change next time or the target object manually triggers the next file synchronization.
[0308] In some embodiments, the client can also execute each target change operation based on the operation type corresponding to each target change operation, in combination with the execution mode of the operation type of the unsafe operation.
[0309] The unsafe operation refers to an operation that may have certain risks to the file or folder, whether in the cloud folder or the local folder. The possible unsafe operations include, but are not limited to, one or more of the following: deleting a subfolder containing a file or a subfolder, adding a file that does not exist in the file path, adding an existing subfolder, moving a file to a path where a file with the same name exists, and moving a subfolder to a path where a folder with the same name exists.
[0310] For example, when the client executes a target change operation, if the target change operation is a deletion operation, the file object deleted by the deletion operation is a subfolder in the cloud folder or the local folder, and the subfolder contains a file or a subfolder, then the client does not execute the deletion operation, and the deletion operation is directly considered as a successful execution. If the target change operation is an addition operation for a subfolder, and the file folder (the cloud folder or the local folder) where the subfolder addition operation is performed already contains the subfolder, then the client does not execute the addition operation, and the addition operation is directly considered as a successful execution. If the target change operation is an addition operation of adding a file under a target subfolder, and the file folder (the cloud folder or the local folder) where the file addition operation is performed does not contain the subfolder, then the client executes a creation operation (creating the subfolder and adding a file under the subfolder), and the addition operation is considered as a successful execution. If the target change operation is a moving operation for a file, and the target subfolder has a duplicate name (for example, moving a file b under a subfolder B to a subfolder b under the subfolder B), then the client first executes a renaming operation, and then executes a moving operation, and the current operation is considered as a successful execution.
[0311] In some embodiments, the client can also update the locally recorded synchronization folder directory after a target change operation is successfully executed, so as to ensure that the remote end and the local end are consistent in real time after the operation is successfully executed.
[0312] In some embodiments, the client can store the local folder directory, the cloud folder directory and the synchronization folder directory in a cache manner. Specifically, the client takes the locally cached local folder directory of the local folder as the local directory of the local folder at the synchronization time point, wherein the locally cached local folder directory is updated when the local folder changes; takes the locally cached cloud folder directory of the cloud folder as the cloud directory of the cloud folder at the synchronization time point, wherein the locally cached cloud folder directory is updated when the cloud folder changes; and takes the locally cached synchronization folder directory of the local folder and the cloud folder in the synchronized state after the last file synchronization is completed as the synchronization directory.
[0313] Through the data caching mechanism, the data access speed and the system response performance can be improved, the resource load pressure can be reduced, and thus the file synchronization efficiency can be improved.
[0314] Further, if a synchronization exception occurs in the current file synchronization process, the client obtains the locally cached local folder directory of the local folder at the current time point and the locally cached cloud folder directory of the cloud folder at the current time point after the exception is recovered, and re-performs the current file synchronization on the local folder and the cloud folder based on the local folder directory at the current time point, the cloud folder directory at the current time point and the synchronization directory.
[0315] Based on the local folder directory at the current time point, the cloud folder directory at the current time point and the synchronization directory, the current file synchronization on the local folder and the cloud folder is performed according to the following steps: first, based on the local directory, the cloud directory and the synchronization directory, the set of local change operations that occur in the local folder from the completion of the last file synchronization to the current time point and the set of cloud change operations that occur in the cloud folder are obtained respectively (the specific process is the same as S202); then, the set of local change operations and the set of cloud change operations are analyzed for differences, and based on the analysis result, each target change operation to be executed in the current file synchronization is planned (the specific process is the same as S203); finally, based on the operation types of the target change operations, the execution order of the target change operations is obtained, and the target change operations are executed in sequence according to the execution order, so as to complete the current file synchronization (the specific process is the same as S204).
[0316] Through the implementation manner, when the synchronization is interrupted due to the synchronization exception, the client can quickly obtain the cloud folder directory, the local folder directory and the synchronization directory by using the cache, and the data acquisition speed can be improved compared with the data acquisition from the database, and the file synchronization efficiency is improved.
[0317] Referring to FIG. 10, it is a schematic diagram of a file synchronization process provided in an embodiment of the present application. The client includes a scanning structure, a data model, a synchronization planning model and a synchronization execution structure.
[0318] The scanning structure is configured to periodically detect the local folder, obtain the local folder directory at the current detection time, and update the local folder directory at the current detection time to the local folder directory cache in the data model; and periodically detect the cloud folder, build the cloud folder directory at the current detection time, and update the cloud folder directory at the current detection time to the cloud folder directory cache in the data model. For details, refer to the cloud folder directory and the local folder directory building process in S201.
[0319] The data model is configured to cache the cloud folder directory and the local folder directory, and the synchronization folder directory cache.
[0320] When the scanning structure detects that the cloud folder directory and the local folder directory remain stable within a certain time, and a change operation occurs in the cloud folder or the local folder, it is determined to perform the file synchronization this time, and the execution of the file synchronization this time is triggered. The triggering time is the synchronization time of the file synchronization this time.
[0321] In the local file synchronization process, the synchronization planning model is configured to obtain the local directory, the cloud directory at the synchronization time and the synchronization directory after the last file synchronization by using the data model.
[0322] The synchronization planning model includes two-step processing operations. The first step is to obtain the change operation list of the local and the cloud from the last synchronization success time to the current time, that is, based on the local directory, the cloud directory and the synchronization directory, the local change operation set occurring in the local folder from the last file synchronization completion to the synchronization time, and the cloud change operation set occurring in the cloud folder are obtained, respectively. For details, refer to S202. The second step is to plan the operation instruction list required to make the local and the cloud consistent in structure, that is, to analyze the difference between the local change operation set and the cloud change operation set, and based on the analysis result, to plan each target change operation to be executed in the file synchronization this time. For details, refer to S203. In the planning process of each target change operation, conflict detection can also be performed. For details of the conflict detection process, refer to the rule rehearsal process in the foregoing description.
[0323] The synchronous execution structure utilizes each target change operation output by the synchronous planning model, groups tasks according to the asynchronous state and the execution path, and executes each target change operation in each task group and in the task group according to the execution order between groups and the execution order within groups, so as to realize the synchronous operation on the local folder and the cloud folder. For details, refer to S204.
[0324] When all the task groups are executed successfully, the synchronous execution structure generates the synchronization folder directory of this file synchronization, and updates the synchronization folder directory cache in the data model based on the synchronization folder directory of this file synchronization. If the execution fails, the file synchronization is paused, and the synchronization task is restarted.
[0325] In some embodiments, the client presents various candidate synchronization creation modes in the operation interface in response to a synchronization disk creation operation triggered by the target object, and then obtains the target synchronization creation mode in response to a selection operation triggered by the target object on each candidate synchronization creation mode.
[0326] The candidate synchronization creation modes include, but are not limited to, a synchronization local folder and a synchronization cloud folder. The synchronization local folder is created based on an existing local file, and the synchronization cloud folder is created based on an existing cloud file.
[0327] It should be noted that the triggering manner of the operation in the embodiments of the present application is not limited, and can be various manners such as touch, click, voice, etc., but is not limited thereto.
[0328] Referring to FIG. 11, it is an operation interface schematic diagram of a synchronization disk creation provided in the embodiments of the present application. The operation interface includes a "create synchronization" button. When the target object clicks the "create synchronization" button, the "synchronization local folder" button and the "synchronization cloud folder" button are presented in the operation interface. The "synchronization local folder" button represents a synchronization local folder, and the "synchronization cloud folder" button represents a synchronization cloud folder. When the target object clicks the "synchronization local folder" button, the client takes the synchronization local folder as the target synchronization mode in response to the triggering operation of the target object on the "synchronization local folder" button. When the target object clicks the "synchronization cloud folder" button, the client takes the synchronization cloud folder as the target synchronization mode in response to the triggering operation of the target object on the "synchronization cloud folder" button. Of course, the target object can also click the button in the middle of the operation interface to start creating synchronization, or when the target object wants to synchronize the local folder, the target object can directly drag the local folder to this page to quickly create synchronization.
[0329] In some embodiments, after the target object selects the synchronization creation mode, the target object can further configure the synchronization information. Specifically, the client presents a configuration interface and obtains at least one synchronization configuration information configured by the target object in response to a configuration operation triggered by the target object in the configuration interface.
[0330] The configuration interface can be an interface for configuring the target synchronization creation mode. The synchronization configuration information includes, but is not limited to, one or more of the following: local folder path, cloud folder path, synchronization type, conflict handling mode, etc.
[0331] Taking synchronization of a local folder as an example, referring to FIG. 12, when the target object clicks the "Synchronize Local Folder" button, the client presents a configuration interface corresponding to the synchronization of the local folder in the operation interface. The configuration interface includes configuration components for configuring the local folder path, cloud folder path, synchronization type, and conflict handling mode. The target object can select the local folder path through the configuration component of the local folder path, select the cloud folder path through the configuration component of the cloud folder path, select bidirectional synchronization or backup to the cloud through the configuration component of the synchronization type, and configure the conflict handling mode through the configuration component of the conflict handling mode.
[0332] When the target object clicks the "Advanced Settings" button, the client presents the operation interface shown in FIG. 13. The operation interface includes each candidate conflict handling mode corresponding to the synchronization type selected by the target object. The candidate conflict handling modes corresponding to bidirectional synchronization include: always ask me, upload the local version to the cloud new version, use the cloud version to overwrite the local version, and keep all conflict files. The default handling mode is determined when a current synchronization conflict occurs (for example, both the cloud file and the local file are changed in the synchronization gap). When the always ask me option is selected and a conflict occurs, the target object can understand the conflict details and manually handle the conflict for a single file.
[0333] When the target object clicks the "Synchronization Mode" button, the client presents the operation interface shown in FIG. 14. The operation interface is used to configure the synchronization mode, which includes automatic synchronization and manual synchronization. Manual synchronization needs to be synchronized by clicking the synchronization button; automatic synchronization will automatically detect the folder state of the local and cloud and update in a timely manner when any change occurs.
[0334] In some embodiments, when a synchronization conflict occurs, if the target conflict processing mode is always ask the object, the client presents a notification in the operation interface to enable the target object to manually resolve the conflict, i.e., to select one of the three candidate synchronization conflict processing modes, i.e., uploading the local version to the new version in the cloud, using the version in the cloud to overwrite the local version, and retaining all the conflict files, as the synchronization conflict processing mode. The notification can be implemented in the form of a system desktop pop-up window, a pop-up window in the client, and the like, but is not limited thereto.
[0335] Referring to FIG. 15A, which is a schematic diagram of a notification provided in an embodiment of the present application. If the target object selects always ask me, a pop-up notification is presented in the operating system, and the notification information is that there is a conflict in the folder, please handle it in time, and the target object is enabled to manually resolve the conflict. When the target object clicks the pop-up window, the client can present the operation interface shown in FIG. 16. The operation interface shown in FIG. 16 includes three buttons corresponding to the three candidate synchronization conflict processing modes, i.e., “overwrite local”, “overwrite cloud”, and “retain all”, respectively. The target object selects the target synchronization conflict processing mode by selecting the component of the corresponding candidate synchronization conflict processing mode.
[0336] Referring to FIG. 15B, which is a schematic diagram of another notification provided in an embodiment of the present application. The component in the operation interface prompts that there is a conflict in the folder, please handle it in time. When the target object clicks the component, the client presents the operation window shown in FIG. 16 to enable the target object to select the target synchronization conflict processing mode.
[0337] In some embodiments, the client can also present synchronization information in response to an information viewing operation triggered by the target object. The synchronization information includes one or more of a synchronization list and a synchronization exception, wherein the synchronization list is used to view the synchronized state of each file object in the historical file synchronization, and the synchronization exception is used to view the file object that fails to synchronize in the file synchronization process.
[0338] Referring to FIG. 17, which is a schematic diagram of an operation interface for viewing synchronization information provided in an embodiment of the present application. The client can present the synchronization list and the synchronization exception in the operation interface. Since there can be multiple synchronization tasks at the same time (e.g., file synchronization for multiple local folders), the operation interface can present the synchronization list corresponding to each synchronization task, such as the synchronization list 1 corresponding to the synchronization task of the local folder sync. The synchronization list includes the file name of the file 1 that is synchronized, and the file 1 is in a synchronization success state.
[0339] Based on the same inventive concept, the embodiment of the present application provides a file synchronization device. As shown in FIG. 18, which is a structural schematic diagram of the file synchronization device 1800, the device can include:
[0340] a data acquisition unit 1801 configured to acquire, when performing file synchronization on a local folder and a cloud folder, a local directory of the local folder at a synchronization time, a cloud directory of the cloud folder at the synchronization time, and a synchronization directory in a synchronized state of the local folder and the cloud folder after last file synchronization is completed;
[0341] a directory analysis unit 1802 configured to obtain, based on the local directory, the cloud directory and the synchronization directory, a set of local change operations that occur in the local folder from the last file synchronization completion to the synchronization time, and a set of cloud change operations that occur in the cloud folder;
[0342] a difference analysis unit 1803 configured to analyze the difference between the set of local change operations and the set of cloud change operations, and based on the analysis result, plan target change operations to be performed in this file synchronization;
[0343] an operation execution unit 1804 configured to obtain an execution order of the target change operations based on the operation types of the target change operations, and execute the target change operations in the execution order to complete this file synchronization.
[0344] Optionally, the directory analysis unit 1802 is specifically configured to:
[0345] based on the directory structure of the local directory, sequentially perform the following operations on each local file object in the local directory:
[0346] compare the directory positions of each synchronization file object in the synchronization directory with the directory position of one local file object in the local file objects;
[0347] based on the comparison result, determine a reference change operation corresponding to the one local file object;
[0348] based on the reference change operation corresponding to each local file object, obtain the set of local change operations that occur in the local folder from the last file synchronization completion to the synchronization time.
[0349] Optionally, when the reference change operation corresponding to the one local file object is determined based on the comparison result, the directory analysis unit 1802 is specifically configured to:
[0350] If the comparison result represents that there is one synchronization file object with the same directory position as the one local file object, then based on the object types of the one local file object and the one synchronization file object, determine the reference change operation corresponding to the one local file object.
[0351] If the comparison result represents that there is no synchronization file object with the same directory position as the one local file object, then based on the respective file identifiers corresponding to each of the synchronization file objects, determine the reference change operation corresponding to the one local file object.
[0352] Optionally, when the local folder directory of the local folder at the synchronization time, the cloud folder directory of the cloud folder at the synchronization time, and the synchronization directory of the local folder and the cloud folder in the synchronized state after the last file synchronization are obtained, the data acquisition unit 1801 is specifically configured to:
[0353] The local folder directory of the local folder currently cached locally is taken as the local directory of the local folder at the synchronization time; wherein the local cached local folder directory is updated when the local folder changes;
[0354] The cloud folder directory of the cloud folder currently cached locally is taken as the cloud directory of the cloud folder at the synchronization time; wherein the local cached cloud folder directory is updated when the cloud folder changes;
[0355] The synchronization folder directory of the local folder and the cloud folder in the synchronized state after the last file synchronization is taken as the synchronization directory.
[0356] Optionally, the operation execution unit 1804 is further configured to:
[0357] If a synchronization exception occurs in the current file synchronization process, then after the exception is recovered, the cached local folder directory of the local folder at the current time and the cached cloud folder directory of the cloud folder at the current time are obtained.
[0358] Based on the local folder directory at the current time, the cloud folder directory at the current time, and the synchronization directory, the local folder and the cloud folder are re-synchronized in the current file synchronization.
[0359] Optionally, the data acquisition unit 1801 is configured to perform at least one of the following operations:
[0360] obtain the cloud directory based on the history operation data and the cloud folder directory after the last file synchronization is completed;
[0361] obtain the cloud directory based on the history operation data and the cloud folder directory after the last file synchronization is completed;
[0362] Optionally, when the data acquisition unit 1801 obtains the set of file objects that have changed in the cloud folder according to the set detection period, the data acquisition unit 1801 is specifically configured to:
[0363] send a detection request to the cloud server according to the set detection period, the detection request carrying the local state information of each file object in the cloud folder recorded in the client at the current time, each local state information being used to represent whether the corresponding file object has undergone the target processing operation;
[0364] receive the set of file objects that have changed returned by the cloud server, wherein the set of file objects is determined by the cloud server based on the cloud state information of each file object in the cloud folder recorded in the cloud server at the current time and the corresponding local state information.
[0365] Optionally, when the data acquisition unit 1801 updates the cloud folder directory recorded locally based on the set of file objects that have changed to obtain the cloud directory, the data acquisition unit 1801 is specifically configured to:
[0366] if the set of file objects includes at least one file, pull the at least one file from the cloud server, and update the cloud folder directory recorded locally based on the at least one file to obtain the cloud directory;
[0367] if the set of file objects includes at least one folder, pull each file under the at least one folder from the cloud server, and update the cloud folder directory recorded locally based on the each file to obtain the cloud directory.
[0368] Optionally, if the value of each cloud state information increases when the corresponding file object undergoes the target processing operation, the file object that has changed is the file object whose value of the cloud state information exceeds the value of the local state information.
[0369] Optionally, when the local change operation set and the cloud change operation set are analyzed for differences, and based on the analysis result, the target change operations to be executed in this file synchronization are planned, the difference analysis unit 1803 is specifically configured to:
[0370] Based on the set instruction generation method, obtain the local executable instructions corresponding to each local change operation in the local change operation set; and based on the instruction generation method, obtain the cloud executable instructions corresponding to each cloud change operation in the cloud change operation set;
[0371] Based on the set instruction execution method, the obtained local executable instructions and cloud executable instructions are rule drilled, and based on the drilling result, the target change operations to be executed in this file synchronization are obtained.
[0372] Optionally, the difference analysis unit 1803 is further configured to:
[0373] If there is an execution conflict between the local executable instructions and the cloud executable instructions in the rule drilling process, an operation interface containing each candidate conflict processing method is presented to the target object;
[0374] In response to the selection operation of the target object for each candidate conflict processing method, the selected target conflict processing is obtained, and the local executable instructions and the cloud executable instructions with execution conflict are processed according to the target conflict processing.
[0375] Optionally, when the execution order of the target change operation is obtained based on the operation type of each target change operation, the operation execution unit 1804 is specifically configured to:
[0376] Based on the file execution path corresponding to each target change operation, the target change operations are grouped in combination with the preset asynchronous execution information, to obtain each task group, the intra-group execution order between at least one target change operation included in each task group, and the inter-group execution order between each task group;
[0377] Based on the inter-group execution order and the intra-group execution order corresponding to each task group, the execution order of the target change operation is obtained.
[0378] Optionally, when the target change operation is executed in sequence according to the execution order, the operation execution unit 1804 is specifically configured to:
[0379] According to the inter-group execution order, the following operations are performed for each task group respectively:
[0380] sequentially execute the at least one target change operation based on an in-group execution sequence between the at least one target change operation in the task group;
[0381] updating the synchronization directory when the at least one target change operation is executed.
[0382] For the convenience of description, the above parts are divided into modules (or units) according to functions and are described respectively. Of course, the functions of the modules (or units) can be implemented in the same or multiple software or hardware in the implementation of the present application.
[0383] As to the device in the above embodiments, the specific manner in which each unit performs the request has been described in detail in the embodiments of the method, and will not be described in detail here.
[0384] Those skilled in the art can understand that each aspect of the present application can be implemented as a system, a method or a program product. Therefore, each aspect of the present application can be embodied in the form of a complete hardware, a complete software (including firmware, microcode, etc.), or a combination of hardware and software, which can be collectively referred to as "circuitry", "module" or "system".
[0385] Based on the same inventive concept, the present application also provides an electronic device. In an embodiment, the electronic device can be a server or a terminal device. Referring to FIG. 19, it is a structural schematic diagram of a possible electronic device provided in an embodiment of the present application. In FIG. 19, the electronic device 1900 includes a processor 1910 and a memory 1920.
[0386] The memory 1920 stores a computer program executable by the processor 1910, and the processor 1910 can execute the steps of the file synchronization method by executing the instructions stored in the memory 1920.
[0387] The memory 1920 can be a volatile memory, such as a random-access memory (RAM), or a non-volatile memory, such as a read-only memory (ROM), a flash memory, a hard disk drive (HDD), or a solid-state drive (SSD), or any other medium capable of storing and carrying desired program code in the form of instructions or data structures and that can be accessed by a computer, but not limited to. The memory 1920 can also be a combination of the above-mentioned memories.
[0388] The processor 1910 can include one or more central processing units (CPUs) or digital processing units, etc. The processor 1910 is configured to execute the computer program stored in the memory 1920 to implement the above-mentioned file synchronization method.
[0389] In some embodiments, the processor 1910 and the memory 1920 can be implemented on the same chip, and in some embodiments, they can also be implemented on separate chips, respectively.
[0390] The specific connection medium between the processor 1910 and the memory 1920 is not limited in the embodiments of the present application. In the embodiments of the present application, the connection between the processor 1910 and the memory 1920 is taken as an example through the bus, and the connection mode between other components is only schematically described, and is not limited. The bus can be divided into an address bus, a data bus, a control bus, etc. For the convenience of description, only one thick line is used to describe the bus in FIG. 19, and only one bus or one type of bus is not described.
[0391] Based on the same inventive concept, the embodiments of the present application provide a computer-readable storage medium including a computer program, when the computer program is run on an electronic device, the computer program is configured to enable the electronic device to perform the steps of the above-mentioned file synchronization method. In some possible implementation manners, various aspects of the file synchronization method provided by the present application can also be implemented in the form of a program product, which includes a computer program, when the program product is run on an electronic device, the computer program is configured to enable the electronic device to perform the steps in the above-mentioned file synchronization method, for example, the electronic device can perform the steps as shown in FIG. 2.
[0392] The program product of the embodiments of the present application can employ any combination of one or more readable media. The readable media can be a readable signal medium or a readable storage medium. The readable storage medium, for example, can be, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the above. More specific examples (a non-exhaustive list) of the readable storage medium include an electrical connection having one or more wires, a portable disc, a hard disk, a RAM, a ROM, an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.
[0393] The program product of the embodiments of the present application can employ a CD-ROM and include a computer program, and can be run on an electronic device. However, the program product of the present application is not limited thereto, and in the present document, the readable storage medium can be any tangible medium containing or storing a computer program that can be used by or in conjunction with a command execution system, apparatus, or device.
[0394] The readable signal medium can include a data signal carried in a baseband or as a part of a carrier wave, in which a readable computer program is borne. Such a propagated data signal can take on many forms, including but not limited to electro-magnetic signal, optical signal, or any suitable combination of the above. The readable signal medium can also be any readable medium that is not a readable storage medium and that can send, propagate, or transmit a computer program for use by or in connection with a command execution system, apparatus, or device.
[0395] In summary, the present application provides a file synchronization method, device, equipment, computer readable storage medium and computer program product. When synchronizing files for a local folder and a cloud folder, the electronic device obtains a local directory of the local folder at a synchronization time, a cloud directory of the cloud folder at the synchronization time, and a synchronization directory of the local folder and the cloud folder in a synchronized state after the last file synchronization is completed. By comparing the directories at the three different times, the electronic device can accurately locate the changes that have occurred in the local folder and the cloud folder from the completion of the last synchronization to the current synchronization time. This multi-directory comparison-based approach avoids the situation of redundant operations on unchanged files that may occur in traditional methods. For example, in traditional methods, the entire folder may be synchronized in full, regardless of whether the files therein have truly changed, which wastes a large amount of system resources and network bandwidth. The present method accurately compares the directories and only synchronizes the files that have changed, greatly improving resource utilization. Based on the directories, the local and cloud folder change operation sets are obtained, the change operation sets are analyzed for differences and target change operations are planned, and finally the target change operations are executed in order to complete synchronization. This targeted synchronization operation makes the file synchronization process more efficient, reduces unnecessary operations, and thus improves the accuracy and efficiency of file synchronization.
[0396] Further, the electronic device sequentially performs operations on each local file object in the local directory based on the directory structure of the local directory, compares the directory positions of each synchronization file object in the synchronization directory with the directory positions of the local file objects, determines reference change operations based on the comparison results, and further obtains a local change operation set. This directory position comparison-based approach can analyze the change of each file object in the local folder in detail. In a file management system, the position and state of a file are very important information. By accurately comparing the directory positions, the electronic device can accurately determine whether a file is added, deleted, moved, or modified. For example, when the directory position of a file changes, the electronic device can quickly identify it as a move operation, rather than simply considering it as an addition or deletion. This detailed analysis makes the determination of the local change operation set more accurate, provides a more reliable basis for subsequent synchronization operations, further improves the accuracy of file synchronization, reduces synchronization errors caused by misjudgment, and improves the stability of the system.
[0397] In determining the reference change operation, if the comparison result indicates that there is a synchronization file object with the same directory location as a local file object, the electronic device determines the reference change operation based on the object types of the two file objects. Different types of file objects (such as files and folders) have different properties and operation methods in the file system. For example, a folder can contain subfolders and files, and operations on a folder can affect all files inside it; while a file is a specific data carrier, and operations on a file mainly involve content modification, deletion, etc. According to the object type, the change of the file object can be more accurately determined. For a folder, the electronic device can further check the changes of the files inside it; for a file, the electronic device can directly compare the differences in its content or metadata. This targeted judgment strategy avoids misjudgment and improves the accuracy of determining the reference change operation, thereby improving the quality of file synchronization and ensuring that the synchronization operations of files and folders meet the actual needs.
[0398] Further, if the comparison result indicates that there is no synchronization file object with the same directory location as a local file object, the electronic device determines the reference change operation based on the respective file identifiers of each synchronization file object. The file identifier is a unique identifier of the file, which can be a file hash value, a file name, etc. By determining the reference change operation based on the file identifier, the change of the file object can still be accurately determined even if the directory locations are different. For example, when a file is moved to another directory, its directory location changes, but the file identifier remains unchanged, and the electronic device can identify it as a move operation through the file identifier. This method expands the scope of determining the reference change operation, ensures the integrity of the local change operation set, and helps to more comprehensively synchronize files, avoiding the problems of file loss or repeated synchronization caused by changes in directory location.
[0399] In the process of obtaining the directory, the electronic device takes the local folder directory of the local folder currently cached locally as the local directory, takes the cloud folder directory of the cloud folder currently cached locally as the cloud directory, and takes the synchronized folder directory of the local folder and the cloud folder in the last file synchronization as the synchronized directory. The cache is a high-speed data storage method that stores frequently used data in memory for quick access. Storing directory information in cache can significantly improve data access speed. In the file synchronization process, frequently obtaining directory information from the disk or network consumes a lot of time, and using cache can quickly load this information into memory, reducing the time overhead of data acquisition. At the same time, cache can also reduce the load pressure on system resources, as it reduces frequent access to the disk and network. For example, in a high-concurrency file synchronization scenario, a large number of users perform file synchronization operations at the same time, and if directory information is obtained from the disk or network every time, it will cause the system performance to decline. Using cache can effectively alleviate this pressure and improve the efficiency of file synchronization.
[0400] If a synchronization exception occurs in the current file synchronization process, the electronic device obtains the local folder directory of the local folder cached at the current time and the cloud folder directory of the cloud folder cached at the current time after the exception is recovered, and re-performs the current file synchronization on the local folder and the cloud folder based on these directories. The cache mechanism enables quick acquisition of the required directory information after the synchronization exception is recovered, avoiding the cumbersome process of acquiring data from a database or other storage methods. Database read and write operations usually require complex queries and transaction processing, which consumes a lot of time and system resources. The data in the cache can be directly accessed, greatly improving the data acquisition speed. In addition, the data in the cache is the most recently used data, which usually has high timeliness and can ensure that the latest directory information is used in the re-synchronization. This fast recovery and re-synchronization capability reduces the impact of synchronization exceptions on the entire synchronization process and improves the reliability and stability of file synchronization.
[0401] The electronic device can also obtain historical operation data of the cloud folder through the cloud server, obtain the cloud directory based on the historical operation data and the cloud folder directory after the last file synchronization is completed, or obtain a set of file objects that have changed in the cloud folder according to a set detection period, update the local recorded cloud folder directory based on the set of file objects, and obtain the cloud directory. Two ways of obtaining the cloud directory are provided, and the appropriate method can be selected according to different scenes and needs. In some cases, the historical operation data can be complete and accurate, and the latest cloud directory can be quickly constructed through this way. In other cases, the set of changed file objects obtained according to the detection period can more timely discover changes in the cloud folder and ensure the real-time performance of the cloud directory. This flexibility increases the adaptability of the system and helps to more efficiently obtain cloud directory information. For example, in a scene where the cloud folder changes frequently, the detection period method can timely capture these changes and avoid synchronization errors caused by untimely information updates. In a scene where the cloud folder changes less frequently, the historical operation data method can reduce unnecessary network requests and improve efficiency.
[0402] When obtaining the set of file objects that have changed in the cloud folder according to the set detection period, the electronic device sends a detection request to the cloud server according to the set detection period, the detection request carrying local state information of each file object in the cloud folder recorded in the electronic device at the current time, receives a set of file objects that have changed returned by the cloud server, and the set of file objects is determined by the cloud server based on cloud state information of each file object in the cloud folder recorded in the cloud server at the current time, combined with the corresponding local state information. By comparing the local and cloud state information, the set of changed file objects can be determined, and changes in the file objects in the cloud folder can be timely discovered. The state information can be the modification time, size, and hash value of the file, and by comparing these information, the electronic device can accurately determine whether the file has changed. This way provides accurate information for subsequent updating of the cloud directory, and improves the timeliness and accuracy of updating the cloud directory. For example, when the modification time of a file changes, the electronic device can quickly identify that the file has been modified and update the local recorded cloud directory in a timely manner, thereby improving the efficiency of file synchronization and ensuring that the states of the local and cloud folders are always consistent.
[0403] When the cloud folder directory recorded locally is updated based on the changed file object set, if the file object set includes at least one file, the electronic device pulls the file through the cloud server and updates the directory; if it includes at least one folder, it pulls each file under the folder and updates the directory. Different processing methods are adopted according to the different types of file object sets, which can more targetedly update the cloud directory. Files and folders have different structures and operation methods in the file system, and separate processing of them can improve the efficiency and accuracy of updating. For files, direct pulling and updating can ensure the consistency of file content; for folders, pulling all files under it and updating can ensure the integrity of the folder. This targeted processing method ensures the accuracy and integrity of the cloud directory, provides a reliable basis for file synchronization, improves the efficiency of file synchronization, and avoids file loss or synchronization errors caused by improper processing.
[0404] If the value of each cloud state information increases when the corresponding file object is subjected to the target processing operation, the changed file object is the file object whose cloud state information value exceeds the local state information value. By comparing the values of the state information, the changed file object is determined, providing a simple and effective judgment method. The increase in the value of the state information can intuitively reflect the change of the file object, and the electronic device only needs to compare the values of the local and cloud state information to quickly screen out the changed file object. This method does not need to compare the file content, greatly improving the efficiency of determining the changed file object. For example, in a large-scale file synchronization scenario, there are a large number of files, and if the content of each file is compared, a large amount of time and system resources will be consumed. Using the state information value comparison method, the changed file can be quickly located, unnecessary operations are reduced, and the efficiency of file synchronization is improved.
[0405] In the process of analyzing the differences between the local and cloud change operation sets and planning the target change operation, the electronic device obtains executable instructions corresponding to each of the local and cloud change operation sets based on the set instruction generation method, performs rule rehearsal on the executable instructions based on the set instruction execution method, and obtains the target change operation based on the rehearsal results. Through the instruction generation and rule rehearsal methods, the local and cloud change operations can be systematically analyzed and planned. Instruction generation can convert change operations into computer-executable instructions, making operations more standardized and standardized. Rule rehearsal can simulate the execution process of the instructions, identify potential problems and conflicts in advance, and make appropriate adjustments. This systematic analysis and planning ensures the rationality and effectiveness of the target change operation, improving the accuracy and efficiency of file synchronization. For example, during rule rehearsal, conflicts between local and cloud operations can be identified, and the execution order of instructions or other measures can be adjusted to resolve these conflicts, avoiding errors during actual execution and ensuring smooth file synchronization.
[0406] If there is an execution conflict between the local and cloud executable instructions during rule rehearsal, the electronic device presents an operation interface containing each candidate conflict handling method to the target object, obtains the selected target conflict handling in response to the target object's selection operation on each candidate conflict handling method, and processes the instructions with execution conflicts according to the target conflict handling. Providing multiple candidate conflict handling methods and allowing the target object to choose can meet the needs of different users. Different users may have different requirements and preferences for file synchronization, for example, some users may prefer to keep the local version, while others may prefer to use the cloud version. By providing multiple conflict handling methods, users can choose according to their needs, improving the user experience. At the same time, effectively solving the execution conflict problem ensures smooth file synchronization. During file synchronization, conflicts are inevitable, and if conflicts cannot be resolved in a timely and effective manner, file synchronization may fail or data may be inconsistent. By allowing users to choose conflict handling methods, the most appropriate solution can be chosen based on the specific situation, ensuring the accuracy and reliability of file synchronization.
[0407] When obtaining the execution sequence based on the operation types of the respective target change operations, the electronic device groups the target change operations based on the respective corresponding file execution paths and the preset asynchronous execution information, obtains the respective task groups, the intra-group execution sequence and the inter-group execution sequence, and obtains the execution sequence of the target change operations based on these sequences. Through the grouping and the determination of the execution sequence, the execution of the target change operations can be reasonably arranged. The file execution path can reflect the association and dependency relationship between operations, and grouping according to the path can place related operations together, facilitating unified management and execution. The preset asynchronous execution information can make full use of the parallel processing capability of the system, improving the execution efficiency. For example, the uploading of local files and the downloading of cloud files can be executed asynchronously, so that multiple operations can be performed at the same time, reducing the waiting time. The determination of the intra-group execution sequence and the inter-group execution sequence can ensure that the execution of the operations meets the logical and sequential requirements, avoiding conflicts and errors between operations. This reasonable arrangement improves the execution efficiency of file synchronization, reduces the synchronization time, and makes the file synchronization process more efficient and smooth.
[0408] When the target change operations are executed in sequence according to the execution sequence, the electronic device executes the target change operations in sequence according to the inter-group execution sequence for each task group based on the intra-group execution sequence, and updates the synchronization directory after the operation is executed. Executing the operations according to the inter-group and intra-group execution sequences and updating the synchronization directory in a timely manner can ensure the orderliness and consistency of the file synchronization process. The inter-group execution sequence ensures that the execution sequence of different task groups meets the logical requirements, avoiding conflicts and dependency problems between tasks; the intra-group execution sequence ensures that the operations in each task group are executed in the correct order, improving the accuracy of the operations. Timely updating the synchronization directory can ensure that the states of the local and cloud folders are always synchronized, so that the user can see the latest file information at any time. This orderliness and consistency improves the quality and efficiency of file synchronization, reduces problems caused by improper operation sequence or untimely synchronization, and provides users with more stable and reliable file synchronization services.
[0409] The technical features of the above embodiments can be combined in any manner. To make the description concise, not all possible combinations of the technical features in the above embodiments are described, but as long as the combinations of the technical features do not exist contradictions, they should be considered as the scope of the present disclosure.
[0410] The above-described embodiments are merely illustrative of several embodiments of the present application, which are described in more detail and in a specific and detailed manner, but should not be construed as limiting the scope of the patent. It should be noted that for those skilled in the art, several modifications and improvements can be made without departing from the concept of the present application, and these are all within the scope of the present application. Therefore, the scope of protection of the patent of the present application should be subject to the appended claims.
Claims
1. A file synchronization method applied to an electronic device, comprising: obtaining a local directory of a local folder at a synchronization time, a cloud directory of a cloud folder at the synchronization time, and a synchronization directory of the local folder and the cloud folder in a synchronized state after a last file synchronization, when file synchronization is performed between the local folder and the cloud folder; obtaining a local change operation set occurred in the local folder from the last file synchronization to the synchronization time, and a cloud change operation set occurred in the cloud folder from the last file synchronization to the synchronization time, based on the local directory, the cloud directory and the synchronization directory respectively; differentially analyzing the local change operation set and the cloud change operation set, and planning target change operations to be executed in this file synchronization based on an analysis result; and obtaining an execution order of the target change operations based on operation types of the target change operations respectively, and executing the target change operations in sequence according to the execution order to complete this file synchronization. 2.The method of claim 1, further comprising: based on a directory structure of the local directory, sequentially performing the following operations on each local file object in the local directory: comparing a directory position of each synchronization file object in the synchronization directory with a directory position of one local file object in the local file objects respectively; determining a reference change operation corresponding to the one local file object based on a comparison result; and obtaining the local change operation set occurred in the local folder from the last file synchronization to the synchronization time based on the reference change operation corresponding to each local file object respectively. 3.The method of claim 2, wherein the determining the reference change operation corresponding to the one local file object based on the comparison result comprises: if the comparison result represents that there is one synchronization file object having the same directory position as the one local file object, determining the reference change operation corresponding to the one local file object based on object types of the one local file object and the one synchronization file object. 4.The method of claim 3, wherein the determining the reference change operation corresponding to the one local file object based on the comparison result further comprises: if the comparison result represents that there is no synchronization file object having the same directory position as the one local file object, determining the reference change operation corresponding to the one local file object based on file identifiers corresponding to the synchronization file objects respectively. 5.The method of any one of claims 1 to 4, wherein the obtaining the local directory of the local folder at the synchronization time, the cloud directory of the cloud folder at the synchronization time, and the synchronization directory of the local folder and the cloud folder in the synchronized state after the last file synchronization comprises: taking a local folder directory of the local folder in the local current cache as the local directory of the local folder at the synchronization time, wherein the local folder directory in the local cache is updated when the local folder changes. obtaining a cloud folder directory of the cloud folder currently locally cached as the cloud directory of the cloud folder at the synchronization time point, wherein the cloud folder directory locally cached is updated when the cloud folder changes; obtaining a synchronization folder directory of the local folder and the cloud folder in a synchronized state after the last file synchronization is completed as the synchronization directory.
6. The method of claim 5, further comprising: if an exception occurs in the current file synchronization process, obtaining a local folder directory of the local folder at the current time point and a cloud folder directory of the cloud folder at the current time point cached after the exception is recovered; re-performing the current file synchronization on the local folder and the cloud folder based on the local folder directory at the current time point, the cloud folder directory at the current time point, and the synchronization directory.
7. The method of any one of claims 1 to 6, further comprising: obtaining historical operation data of the cloud folder from a cloud server, the historical operation data including operation data from the last file synchronization to the synchronization time point, and obtaining the cloud directory based on the historical operation data and the cloud folder directory after the last file synchronization is completed; obtaining a set of changed file objects in the cloud folder according to a set detection period, and updating the cloud folder directory locally recorded based on the set of changed file objects to obtain the cloud directory.
8. The method of claim 7, wherein the obtaining the set of changed file objects in the cloud folder according to the set detection period comprises: sending a detection request to the cloud server according to the set detection period, the detection request carrying local state information of each file object in the cloud folder recorded in the electronic device at the current time point, each local state information indicating whether a target processing operation is performed on the corresponding file object; receiving the set of changed file objects returned by the cloud server, wherein the set of changed file objects is determined by the cloud server based on cloud state information of each file object in the cloud folder recorded in the cloud server at the current time point and the corresponding local state information.
9. The method of claim 7 or 8, wherein the updating the cloud folder directory locally recorded based on the set of changed file objects to obtain the cloud directory comprises: if the set of changed file objects includes at least one file, pulling the at least one file from the cloud server, and updating the cloud folder directory locally recorded based on the at least one file to obtain the cloud directory.
10. The method of any one of claims 7 to 9, wherein the updating the cloud folder directory locally recorded based on the set of changed file objects to obtain the cloud directory comprises: If the file object set includes at least one folder, each file under the at least one folder is pulled through the cloud server, and based on the files, a cloud folder directory recorded locally is updated to obtain a cloud directory.
11. The method of claim 9 or 10, if a value of each cloud state information increases when a target processing operation is performed on a corresponding file object, the file object with a changed value is a file object whose value of the cloud state information exceeds a value of the local state information.
12. The method of any one of claims 1 to 11, the local change operation set and the cloud change operation set are analyzed, and based on an analysis result, each target change operation to be executed in this file synchronization is planned, including: based on a set instruction generation manner, each local change operation in the local change operation set corresponds to a local executable instruction; and based on the instruction generation manner, each cloud change operation in the cloud change operation set corresponds to a cloud executable instruction; based on a set instruction execution manner, each local executable instruction and each cloud executable instruction are rule practiced, and based on a practice result, each target change operation to be executed in this file synchronization is obtained.
13. The method of claim 12, further comprising: if there is an execution conflict between the local executable instruction and the cloud executable instruction in the rule practicing process, an operation interface including each candidate conflict processing manner is presented to a target object; in response to a selection operation of the target object on each candidate conflict processing manner, a selected target conflict processing is obtained, and the local executable instruction and the cloud executable instruction with the execution conflict are processed according to the target conflict processing.
14. The method of any one of claims 1 to 13, the execution order of each target change operation is obtained based on an operation type of each target change operation, including: based on a file execution path corresponding to each target change operation, each target change operation is grouped according to a preset asynchronous execution information, an execution order within each task group between at least one target change operation included in each task group, and an execution order between each task group are obtained; and based on the execution order between each task group and the execution order within each task group corresponding to each task group, the execution order of each target change operation is obtained.
15. The method of claim 14, the target change operations are executed in sequence according to the execution order, including: according to the execution order between each task group, the following operations are performed on each task group: based on an execution order within a task group between at least one target change operation in the task group, the at least one target change operation is executed in sequence; and when the at least one target change operation is executed, the synchronization directory is updated.
16. A file synchronization device, comprising: The data acquisition unit is configured to acquire a local directory of the local folder at a synchronization time, a cloud directory of the cloud folder at the synchronization time, and a synchronization directory of the local folder and the cloud folder in a synchronized state after a last file synchronization is completed when file synchronization is performed for the local folder and the cloud folder. The directory analysis unit is configured to obtain a local change operation set occurred in the local folder from the last file synchronization to the synchronization time and a cloud change operation set occurred in the cloud folder based on the local directory, the cloud directory, and the synchronization directory. The difference analysis unit is configured to analyze the local change operation set and the cloud change operation set, and plan target change operations to be executed in the file synchronization based on an analysis result. The operation execution unit is configured to obtain an execution sequence of the target change operations based on operation types of the target change operations, and execute the target change operations in the execution sequence to complete the file synchronization. The memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of the method in any one of claims 1-15.
17. An electronic device comprising a processor and a memory, wherein, 18. A computer readable storage medium comprising a computer program, the computer program being configured to cause an electronic device to execute the steps of the method in any one of claims 1-15 when the computer program is run on the electronic device.
19. A computer program product comprising a computer program stored in a computer readable storage medium, and a processor of an electronic device reading and executing the computer program from the computer readable storage medium, so that the electronic device executes the steps of the method in any one of claims 1-15.
Citation Information
Patent Citations
File monitoring and message pushing based real-time synchronization system
CN105740418A
File synchronization pausing for individual files
CN109313634A
File processing method and device, equipment and storage medium
CN117149727A
Transaction-based file synchronization method and synchronization system
CN117421290A
Service-based storage synchronization
US10783120B1