File synchronization method and related apparatus

The method addresses redundant operations in file synchronization by analyzing and sequencing change operations, enhancing synchronization reliability and efficiency by reducing conflicts and optimizing operation execution.

US20260377373A1Pending Publication Date: 2026-11-26TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
US19/755915
Authority / Receiving Office
US · United States
Patent Type
Applications(United States)
Current Assignee / Owner
Priority Date
2024-07-25
Filing Date
2026-07-28
Publication Date
2026-11-26

AI Technical Summary

Technical Problem

Existing file synchronization methods suffer from redundant operations, leading to increased conflict events, prolonged synchronization times, and reduced efficiency due to inconsistencies in operation logs between local and remote folders.

Method used

A file synchronization method that includes obtaining local and remote directories, determining change operation sets, performing difference analysis, and sequencing operations based on their types to execute them in an ordered manner, thereby reducing redundant operations and enhancing synchronization efficiency.

Benefits of technology

This approach ensures reliable bidirectional file synchronization by minimizing conflicts and optimizing operation execution, thus improving synchronization speed and efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure US20260377373A1-D00000_ABST
    Figure US20260377373A1-D00000_ABST
Patent Text Reader

Abstract

A file synchronization method, apparatus, and computer-readable storage medium for bidirectional folder synchronization through change detection and ordered operation execution. The method obtains local and remote directories at synchronization time and a synchronization directory from the previous synchronization end state. Change operation sets are determined for both local and remote folders by comparing current directories against the synchronization directory baseline. Difference analysis identifies conflicts and determines target change operations for execution. An execution order is established based on operation types to ensure consistent synchronization. Operations are sequentially executed according to this order to complete synchronization. This approach enables reliable bidirectional file synchronization by tracking changes since the last synchronized state, resolving conflicts through analysis, and applying operations in dependency-aware order.
Need to check novelty before this filing date? Find Prior Art

Description

CROSS-REFERENCE TO RELATED APPLICATIONS

[0001] This application is a continuation application of International Application No. PCT / CN2025 / 099010 filed on Jun. 4, 2025 which claims priority to Chinese Patent Application No. 202411009416.X, filed with the China National Intellectual Property Administration on Jul. 25, 2024, the disclosures of each being incorporated by reference herein in their entireties.FIELD

[0002] The disclosure relates to the field of computer technologies, and provides a file synchronization method and a related apparatus.BACKGROUND

[0003] File synchronization refers to keeping file contents of a local folder on a client consistent with those of a remote folder on a remote server.

[0004] In the related art, the client generates a corresponding operation event set according to operation logs of the remote folder, and generates a corresponding operation event set according to operation logs of the local folder. Thereafter, the client executes operations corresponding to respective operation events on the local folder and the remote folder based on the two operation event sets to implement file synchronization.

[0005] However, redundant operations may exist in folder-related operations. Such redundant operations increase the probability of occurrence of conflict events, thereby resulting in file synchronization failure. In addition, the redundant operations prolong time consumed by file synchronization and reduce file synchronization efficiency.

[0006] For example, if the operation event set of the local folder indicates that a field in document 1 is modified first and then restored to an initial value, two modification operations need to be executed on document 1 in the remote folder during data synchronization. Nevertheless, document 1 is not actually modified. This seriously affects data synchronization efficiency.SUMMARY

[0007] Provided are a file synchronization method and apparatus, a device, a storage medium, and a program product, which can implement reliable bidirectional file synchronization through change operation detection, conflict analysis, and ordered operation execution based on directory comparison.

[0008] According to some embodiments, a file synchronization method, performed by an electronic device, includes: obtaining, for a current file synchronization between a local folder and a remote folder, a local directory of the local folder at a synchronization moment, a remote directory of the remote folder at the synchronization moment, and a synchronization directory representing the local folder and the remote folder in a synchronized state at an end of a previous file synchronization; determining, based on the local directory, the remote directory, and the synchronization directory, a local change operation set occurring in the local folder and a remote change operation set occurring in the remote folder from the end of the previous file synchronization to the synchronization moment; performing difference analysis on the local change operation set and the remote change operation set to generate an analysis result; determining, based on the analysis result, a plurality of target change operations to be executed in the current file synchronization; determining an execution order of the plurality of target change operations based on operation types of the plurality of target change operations; and sequentially executing the plurality of target change operations according to the execution order to complete the current file synchronization between the local folder and the remote folder.

[0009] According to some embodiments, a file synchronization apparatus, includes: at least one memory configured to store program code; and at least one processor configured to read the program code and operate as instructed by the program code, the program code including: obtaining code configured to cause at least one of the at least one processor to obtain, for a current file synchronization between a local folder and a remote folder, a local directory of the local folder at a synchronization moment, a remote directory of the remote folder at the synchronization moment, and a synchronization directory representing the local folder and the remote folder in a synchronized state at an end of a previous file synchronization; first determination code configured to cause at least one of the at least one processor to determine, based on the local directory, the remote directory, and the synchronization directory, a local change operation set occurring in the local folder and a remote change operation set occurring in the remote folder from the end of the previous file synchronization to the synchronization moment; analysis code configured to cause at least one of the at least one processor to perform difference analysis on the local change operation set and the remote change operation set to generate an analysis result; second determination code configured to cause at least one of the at least one processor to determine, based on the analysis result, a plurality of target change operations to be executed in the current file synchronization; third determination code configured to cause at least one of the at least one processor to determine an execution order of the plurality of target change operations based on operation types of the plurality of target change operations; and execution code configured to cause at least one of the at least one processor to sequentially execute the plurality of target change operations according to the execution order to complete the current file synchronization between the local folder and the remote folder.

[0010] According to some embodiments, a non-transitory computer-readable storage medium, storing computer code which, when executed by at least one processor, causes the at least one processor to at least: obtain, for a current file synchronization between a local folder and a remote folder, a local directory of the local folder at a synchronization moment, a remote directory of the remote folder at the synchronization moment, and a synchronization directory representing the local folder and the remote folder in a synchronized state at an end of a previous file synchronization; determine, based on the local directory, the remote directory, and the synchronization directory, a local change operation set occurring in the local folder and a remote change operation set occurring in the remote folder from the end of the previous file synchronization to the synchronization moment; perform difference analysis on the local change operation set and the remote change operation set to generate an analysis result; determine, based on the analysis result, a plurality of target change operations to be executed in the current file synchronization; determine an execution order of the plurality of target change operations based on operation types of the plurality of target change operations; and sequentially execute the plurality of target change operations according to the execution order to complete the current file synchronization between the local folder and the remote folder.BRIEF DESCRIPTION OF THE DRAWINGS

[0011] To describe technical solutions in embodiments of this application more clearly, the following briefly describes the accompanying drawings required for describing the embodiments. Apparently, the accompanying drawings in the following description show merely some embodiments of this application, and a person of ordinary skill in the art may derive other accompanying drawings from the disclosed accompanying drawings without creative.

[0012] FIG. 1 is a schematic diagram of an application scenario according to some embodiments.

[0013] FIG. 2 is a schematic flowchart of a file synchronization method according to some embodiments.

[0014] FIG. 3 is a schematic logic diagram of remote directory construction according to some embodiments.

[0015] FIG. 4 is a schematic logic diagram of constructing a remote folder directory according to some embodiments.

[0016] FIG. 5 is another schematic logic diagram of constructing a remote folder directory according to some embodiments.

[0017] FIG. 6 is a schematic diagram of a local directory and a synchronization directory according to some embodiments.

[0018] FIG. 7A is a schematic diagram of a first local file object and a synchronized file object according to some embodiments.

[0019] FIG. 7B is a schematic diagram of a second local file object and a synchronized file object according to some embodiments.

[0020] FIG. 8 is a schematic diagram of a task group according to some embodiments.

[0021] FIG. 9 is a schematic logic diagram of an execution process of a task group according to some embodiments.

[0022] FIG. 10 is a schematic diagram of a file synchronization process according to some embodiments.

[0023] FIG. 11 is a schematic diagram of an operation interface of synchronization disk creation according to some embodiments.

[0024] FIG. 12 is a schematic diagram of a configuration interface corresponding to a synchronized local folder according to some embodiments.

[0025] FIG. 13 is a schematic diagram of a configuration interface of a conflict handling manner according to some embodiments.

[0026] FIG. 14 is a schematic diagram of a configuration interface of a synchronization manner according to some embodiments.

[0027] FIG. 15A is a schematic diagram of first notification information according to some embodiments.

[0028] FIG. 15B is a schematic diagram of second notification information according to some embodiments.

[0029] FIG. 16 is a schematic diagram of an operation interface of selecting a conflict handling manner according to some embodiments.

[0030] FIG. 17 is a schematic diagram of an operation interface of viewing synchronization information according to some embodiments.

[0031] FIG. 18 is a schematic structural diagram of a file synchronization apparatus according to some embodiments.

[0032] FIG. 19 is a schematic structural diagram of an electronic device according to some embodiments.DESCRIPTION OF EMBODIMENTS

[0033] Technical solutions in embodiments of this application are clearly and completely described in the following with reference to the accompanying drawings in some embodiments. Apparently, the described embodiments are merely some rather than all of some embodiments. All other embodiments obtained by a person of ordinary skill in the art based on some embodiments without creative efforts fall within the protection scope of this application.

[0034] In some embodiments, the term “module” or “unit” refers to a computer program with a preset function or a part of the computer program and works, together with other related parts, to implement a preset target, and may be completely or partially implemented by using software, hardware (e.g., a processing circuit or a memory) or a combination thereof. Similarly, one processor (or a plurality of processors or memories) may be configured to implement one or more modules or units. In addition, each module or unit may be a part of an overall module or unit including a function of the module or unit.

[0035] When some embodiments are applied to products or technologies, relevant permissions or consents may be required to be obtained. In addition, the collection, use, and processing of relevant data may be required to comply with relevant laws, regulations and standards of corresponding countries and regions.

[0036] FIG. 1 shows a schematic diagram of an application scenario according to some embodiments. The application scenario includes a terminal device 110 and a server 120. This application does not limit quantities of the terminal device 110 and the server 120.

[0037] A client for providing cloud storage services is installed on the terminal device 110. The client may be an application, but is not limited thereto. The terminal device 110 may be a smartphone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart watch, an Internet of Things device, a smart voice interaction device, a smart household appliance, an in-vehicle terminal, or an aircraft, but is not limited thereto.

[0038] The server 120 may be a background server corresponding to the client. The server 120 may be an independent physical server, or a server cluster or a distributed system including a plurality of physical servers, or may be a cloud server that provides a cloud service, a cloud database, cloud computing, a cloud function, cloud storage, a network service, cloud communication, a middleware service, a domain name service, a security service, a content delivery network (CDN), and a cloud computing service such as big data and an artificial intelligence platform.

[0039] The terminal device 110 and the server 120 may be directly or indirectly connected through wired or wireless communication. This is not limited in this application.

[0040] A file synchronization method mentioned in this application may be applied to the client. By way of example, the client obtains, when file synchronization is performed for a local folder and a remote folder, a local directory of the local folder at a synchronization moment, a remote directory of the remote folder at the synchronization moment, and a synchronization directory of the local folder and the remote folder in a synchronized state at the end of the previous file synchronization. Next, the client obtains, based on the local directory, the remote directory, and the synchronization directory, both a local change operation set occurring in the local folder and a remote change operation set occurring in the remote folder from the end of the previous file synchronization to the synchronization moment. The client performs difference analysis on the local change operation set and the remote change operation set, and plans, based on an analysis result, to-be-executed target change operations in the current file synchronization. The client obtains an execution order of the target change operations based on respective operation types of the target change operations, and sequentially executes the target change operations according to the execution order, to complete the current file synchronization.

[0041] In this application, the collection and processing of relevant data (e.g., the local folder and the remote folder) need to be strictly in accordance with the requirements of laws and regulations when applied in practice, and the informed consent or separate consent of the personal information subject needs to be obtained. Subsequent data use and processing need to be carried out within the scope of authorization of laws and regulations and the personal information subject.

[0042] FIG. 2 shows a schematic flowchart of a file synchronization method according to some embodiments. The method is applied to a client, and procedures are as follows:

[0043] S201: Obtain, when file synchronization is performed for a local folder and a remote folder, a local directory of the local folder at a synchronization moment, a remote directory of the remote folder at the synchronization moment, and a synchronization directory of the local folder and the remote folder in a synchronized state at the end of the previous file synchronization.

[0044] A folder is a virtual container for storing and organizing files, and file types include but are not limited to documents, pictures, and videos. Folders may be nested to form a tree structure, so as to help a user construct a hierarchical file management system. One folder may include one or more of sub-folders and files, and quantities of sub-folders and files are not limited.

[0045] The local folder is a folder stored in a terminal device, and the remote folder is a folder stored in a remote server. The synchronization moment refers to a moment at which file synchronization is performed for the local folder and the remote folder. At the end of the previous file synchronization, the local folder and the remote folder converge to the same state. To be specific, the local folder and the remote folder are in a synchronized state.

[0046] When performing file synchronization for the local folder and the remote folder, synchronization may be created based on existing local files, or based on existing remote files. The manner of creating synchronization based on existing local files may be referred to as local folder synchronization, and the manner of creating synchronization based on existing remote files may be referred to as remote folder synchronization. Since the processes of local folder synchronization and remote folder synchronization are similar, only local folder synchronization is described as an example herein.

[0047] Synchronization types of file synchronization include but are not limited to two-way synchronization and remote backup. The two-way synchronization means that the local folder and the remote folder remain completely consistent in real time, and any change on one side is synchronized to the other side. The remote backup means that changes of the local folder are synchronized to the remote, while changes of remote files do not affect local file contents. The remote backup may be referred to as unidirectional synchronization. The synchronization types of file synchronization may be pre-configured by a target object.

[0048] Synchronization manners of file synchronization include but are not limited to manual synchronization or automatic synchronization. The manual synchronization means that file synchronization is performed only after the target object triggers a file synchronization operation for the local folder and the remote folder. The automatic synchronization means that folder states of the local folder and the remote folder are detected automatically, and updates are performed promptly upon any change.

[0049] In a possible situation, if the synchronization type of the current file synchronization is two-way synchronization, as some embodiments, the client may periodically perform file synchronization for the local folder and the remote folder according to a preset synchronization period. At this time, S201 to S204 describe the file synchronization process within one period. As another possible implementation, when neither the local folder nor the remote folder changes within a set duration, the client determines to perform file synchronization for the local folder and the remote folder.

[0050] In a possible situation, if the synchronization type of the current file synchronization is remote backup, the client determines to perform file synchronization for the local folder and the remote folder in response to the file synchronization operation triggered by the target object. By way of example, the file synchronization operation may be triggered by the target object clicking / tapping a synchronization button on an operation interface displayed by the client, but is not limited thereto.

[0051] In some embodiments, the client may periodically construct a local folder directory of the local folder and a remote folder directory of the remote folder according to a set detection period, and record the local folder directory and the remote folder directory at the current moment, where a data recording manner may be a caching or persisting manner. In addition, the client may record a synchronization folder directory of the local folder and the remote folder in a synchronized state at the end of each file synchronization, where a data recording manner may be a caching or persisting manner. In this way, when file synchronization is performed for the local folder and the remote folder, the recorded local folder directory at the synchronization moment and the recorded remote folder directory at the synchronization moment are obtained, and the recorded synchronization folder directory of the local folder and the remote folder in the synchronized state at the end of the previous file synchronization is obtained for subsequent processing. For convenience of description, the local folder directory at the synchronization moment is hereinafter referred to as the local directory, the remote folder directory at the synchronization moment is hereinafter referred to as the remote directory, and the synchronization folder directory of the local folder and the remote folder in the synchronized state at the end of the previous file synchronization is hereinafter referred to as the synchronization directory.

[0052] In some embodiments, within each detection period, the client updates the locally recorded local folder directory with the local folder directory constructed in the current detection period, and updates the locally recorded remote folder directory with the remote folder directory constructed in the current detection period. In this way, when file synchronization is performed for the local folder and the remote folder, the currently recorded local folder directory and remote folder directory in the client are directly taken as the local directory and the remote directory.

[0053] The creation processes of the local folder directory and the remote folder directory recorded in the client are described respectively below.

[0054] In some embodiments, the client detects whether a change occurs in the local folder, and updates the locally recorded local folder directory according to the change occurring in the local folder when the change occurs in the local folder. The change occurring in the local folder includes but is not limited to one or more of operations, including file or sub-folder addition, file or sub-folder deletion, file or sub-folder modification, and file or sub-folder movement. By way of example, the client may enable a file hook. When a change occurs in the local folder, an operating system actively invokes the file hook to notify the local folder of a type of change, so that a directory structure of the local folder is constructed in near real time.

[0055] In some embodiments, the client detects whether a change occurs in the remote folder, and updates the locally recorded remote folder directory according to the change occurring in the remote folder when the change occurs in the remote folder. The change occurring in the remote folder includes but is not limited to one or more of operations, including file or sub-folder addition, file or sub-folder deletion, file or sub-folder modification, and file or sub-folder movement.

[0056] Specifically, the remote folder directory may be constructed in, but not limited to, the following two manners:

[0057] In a first construction manner, the client obtains, by using a remote server, historical operation data of the remote folder, the historical operation data including operation data from the end of the previous file synchronization to the synchronization moment. The client obtains, based on the historical operation data, the remote folder directory of the remote folder at the synchronization moment in combination with a historical remote directory of the remote folder at the end of the previous file synchronization.

[0058] Specifically, historical operations may be sorted based on operation time corresponding to each historical operation in historical operation data, to obtain an operation order of the historical operations. Execution manners for different types of historical operations are as follows. If the historical operation is an addition operation, a new file or folder is added at a corresponding location in the historical remote directory. If the historical operation is a modification operation, relevant information of the corresponding file or folder in the historical remote directory is updated, such as file content or modification time. If the historical operation is a deletion operation, the corresponding file or folder is removed from the historical remote directory. If the historical operation is a movement operation, a location of the corresponding file or folder in the historical remote directory is updated to a new path. The foregoing operations are sequentially executed based on the operation order of the historical operations to obtain the remote directory.

[0059] The client may transmit a data obtaining request to the remote server. After receiving the data obtaining request, the remote server returns the historical operation data of the remote folder to the client. The remote server may periodically push the historical operation data of the remote folder to the client, for the client to obtain the historical operation data and perform subsequent processing.

[0060] The historical operation data may record each historical operation under the remote folder from the end of the previous file synchronization to the synchronization moment, as well as the corresponding operation time. The historical operations include but are not limited to one or more of creation, modification, deletion, renaming, movement, and access.

[0061] The client sorts the historical operations based on the operation time corresponding to each historical operation in the historical operation data to obtain an operation order of the historical operations. Then, based on the operation order of the historical operations, the client executes each historical operation for the historical remote directory of the remote folder at the end of the previous file synchronization, so as to obtain the remote folder directory of the remote folder at the synchronization moment.

[0062] Specifically, if the historical operation data records historical operations occurring in the remote folder from the end of the previous file synchronization to the synchronization moment, which are sequentially sorted according to operation time as: an addition operation (adding a file in a sub-folder), a modification operation (editing content of the file), and a movement operation (moving the file from the sub-folder to a root directory), the addition operation, the modification operation, and the movement operation are sequentially executed for the remote folder directory at the end of the previous file synchronization to obtain the remote directory.

[0063] For example, FIG. 3 shows a schematic logic diagram of remote directory construction according to some embodiments. It is assumed that the historical remote directory at the end of the previous file synchronization includes a sub-folder (a folder named game) and file 1 (1.txt), where the sub-folder contains file 2 (2.txt), and file 1 and file 2 are documents with different contents. The client obtains historical operation data of the remote folder from the remote server. In the historical operation data, historical operations occurring in the remote folder from the end of the previous file synchronization to the synchronization moment are sequentially sorted according to operation events as: an addition operation (adding file 3 in a sub-folder), a modification operation (editing content of file 3), and a movement operation (moving file 3 from the sub-folder to a root directory), where file 3 is 3.txt. Then, the client sequentially executes the addition operation, the modification operation, and the movement operation for the historical remote directory at the end of the previous file synchronization, so as to obtain a remote directory of the remote folder at the synchronization moment. The remote directory includes a sub-folder, file 1, and file 3, where the sub-folder contains file 2.

[0064] In the first construction manner, a directory structure of the remote folder may be simply and quickly constructed through the historical operation data, thereby improving file synchronization efficiency.

[0065] However, in the first construction manner, a large number of incomplete and fragmented operation logs and various timing problems may exist, resulting in numerous redundant operations that require merging processing. For example, all files in a sub-folder under the root directory of the remote folder are deleted first. Then, the sub-folder is deleted. Afterwards, a sub-folder with the same name as the aforementioned sub-folder is created under the root directory. Finally, all the previously deleted files are added into the created sub-folder. At this time, a large number of deletion and addition logs may be generated, but the actual remote folder does not change. Therefore, such redundant operations may be merged.

[0066] In some embodiments, a simpler directory structure construction manner, i.e., a second construction manner, is designed for complex merging scenarios.

[0067] In the second construction manner, the client constructs the locally recorded remote folder directory based on an incremental synchronization manner. Specifically, the client obtains, according to a set detection period, a changed file object set in the remote folder, and updates the locally recorded remote folder directory based on the changed file object set, to obtain the remote directory.

[0068] The changed file object set in the remote folder directory may be obtained in, but not limited to, the following two manners:

[0069] In the first possible implementation, the client transmits a detection request to the remote server according to the set detection period, the detection request carrying local state information, recorded in the client, of file objects in the remote folder at the current moment, and each piece of local state information being configured for representing whether a target processing operation occurs to a corresponding file object. The client receives the changed file object set returned by the remote server, the file object set being determined by the remote server based on remote state information, recorded in the remote server, of each of the file objects at the current moment, in combination with the local state information of each of the file objects.

[0070] Each of the file objects includes but is not limited to one or more of a file and a sub-folder.

[0071] The local state information and the remote state information may be represented by a sync sequence number (SSN). For each of the file objects in the remote folder, a piece of metadata may be added, where the metadata is configured for describing the SSN of the file object. The SSN of the file object may be generated by a millisecond-level server clock, but is not limited thereto. For convenience of distinction, the local state information is denoted as SSN, and the remote state information is denoted as SSN′. The SSN is metadata for describing the state of a file object. For each of the file objects in the remote folder, such metadata may be added thereto, and the SSN may be generated by the millisecond-level server clock. The local state information and the remote state information may be represented by SSNs. By comparing the SSNs of local and remote file objects, it may be determined whether a target processing operation occurs to the file objects.

[0072] In some embodiments, when initializes the remote folder directory, the client fully pulls the remote folder stored in the remote server, as well as the remote state information corresponding to each of the file objects in the remote folder. Based on the fully pulled remote folder, an initialized remote folder directory recorded locally by the client is obtained, and the pulled remote state information corresponding to each of the file objects is taken as the local state information of each of the file objects in the initialized remote folder recorded locally by the client.

[0073] As an example, the client transmits a query request for obtaining the remote folder to the remote server. After receiving the query request, the remote server returns the remote folder at the current moment to the client, and returns SSN′ of each file and each sub-folder in the remote folder at the current moment to the client. The client takes the received remote folder as the initialized remote folder directory recorded locally, and takes the received SSN′ of each file and each sub-folder in the remote folder as the SSN of each of the initialized files and sub-folders recorded locally.

[0074] FIG. 4 shows a schematic logic diagram of constructing a remote folder directory according to some embodiments. The client transmits a query request for obtaining the remote folder to the remote server. After receiving the query request, the remote server returns the current remote folder directory, as well as SSN′ of each file and each sub-folder in the current remote folder directory to the client. The remote folder directory includes sub-folder 1, sub-folder 2, and file 1 (1.txt). Sub-folder 1 contains file 2 (2.txt), and sub-folder 2 contains file 3 (1.txt) and file 4 (3.txt). In other words, the file objects included in the remote folder directory are: sub-folder 1, sub-folder 2, file 1, file 2, file 3, and file 4. Based on the received remote folder directory and SSN′ of each of the file objects, the client obtains the initialized remote folder directory recorded locally and SSN of each of the file objects.

[0075] In some embodiments, for each file in the remote folder, when a target processing operation occurs to the file, the remote server updates SSN′ of the file to indicate that the file is changed. The target processing operation for the file includes but is not limited to one or more of an addition operation and a modification operation.

[0076] In some embodiments, for each sub-folder in the remote folder, when a target processing operation occurs in the sub-folder, the remote server updates SSN′ of the sub-folder to indicate that file deletion or file movement occurs in the sub-folder. The target processing operation for the sub-folder includes but is not limited to one or more of a file deletion operation and a file movement operation.

[0077] In this way, when an addition or editing operation is performed on a file, the remote server updates SSN′ of the file to indicate that a remote file is changed. When a file deletion or movement operation occurs in a folder, the remote server updates SSN′ of the folder to indicate that files in a remote sub-folder are changed.

[0078] In some embodiments, metadata of each of the file objects may include identification information for indicating whether the file is moved or deleted. The identification information may be represented by a special file identifier (inode), but is not limited thereto. When a file object is moved or deleted, the identification information of the file object changes. Therefore, when the inode of a file object changes, the remote server may take the file object as a changed file object.

[0079] In some embodiments, when updating SSN′, the remote server may generate new SSN′ at the current moment by using a server clock, and update SSN′ based on the new SSN′.

[0080] In some embodiments, if a value of each SSN′ increases when a target processing operation occurs to a corresponding file object, the changed file object is a file object for which the value of SSN′ exceeds the value of SSN.

[0081] In some embodiments, although the state information may be used to determine whether a target processing operation is performed on a file and the state information may indicate whether the file object changes, the actual content of the file may remain unchanged even after the target processing operation is performed. Therefore, in some embodiments, for files for which SSN′ exceeds SSN, the remote server may further adopt one or more file metadata such as file size, modification time, and cyclic redundancy check (CRC64) value to determine whether substantial changes occur to the content of the file. Further, when substantial changes occur to the content of the file, the file is taken as a changed file object.

[0082] In some embodiments, if SSN′ of a sub-folder exceeds SSN and files for which SSN′ exceeds SSN exist in the sub-folder, the sub-folder may be taken as a changed file object, and files in the sub-folder are not taken as changed file objects.

[0083] In some embodiments, the file object set returned by the remote server may include content of the changed file object, or an object identifier of the changed file object. If the object identifier is returned, the client may pull the corresponding file object according to the object identifier.

[0084] For example, still referring to FIG. 4, it is assumed that operations triggered by a target object on the remote folder include: modifying and then deleting file 2 (2.txt) in sub-folder 1, and modifying file 3 (1.txt) in sub-folder 2. Since operations on files in a sub-folder affect state information of the sub-folder, the values of SSN′ of sub-folder 1, file 2, and file 3 all change. The updated SSN′ of sub-folder 1 is a timestamp generated by the server clock at a moment when file 2 is deleted. The updated SSN′ of file 2 is a timestamp generated by the server clock at a moment when file 2 is modified. The updated SSN′ of file 3 is a timestamp generated by the server clock at a moment when file 3 is modified. In a first detection period, the client transmits a detection request to the remote server, where the detection request carries SSN of sub-folder 1, sub-folder 2, file 1, file 2, file 3, and file 4 recorded locally by the client. After receiving the detection request carrying SSN, the remote server respectively compares SSN and SSN′ corresponding to sub-folder 1, sub-folder 2, file 1, file 2, file 3, and file 4. At this time, SSN′ of sub-folder 1 is greater than SSN of sub-folder 1, SSN′ of file 2 is greater than SSN of file 2, and SSN′ of file 3 is greater than SSN of file 3. File 2 is a file in sub-folder 1, and when SSN′ of a sub-folder is greater than SSN thereof and a file for which SSN′ is also greater than SSN thereof exists in the sub-folder, the sub-folder is taken as a changed sub-folder, and changes of files in the sub-folder are not considered separately. Therefore, the remote server returns sub-folder 1 serving as a changed sub-folder and file 3 serving as a changed file to the client.

[0085] In the foregoing implementation, for both files and sub-folders, if SSN′ of a file object exceeds SSN, the remote server may take the file object as a potentially changed file object. A changed file may be regarded as having incremental actions in the file, and a changed sub-folder may be regarded as having deletion actions in the sub-folder. In this way, after obtaining a changed file object set, the client may perform incremental synchronization according to the file object set, thereby improving file synchronization efficiency.

[0086] In some embodiments, after obtaining the changed file object set returned by the remote server, at least one of the following cases exists:

[0087] Case 1: The client pulls, if the file object set includes at least one file, the at least one file by using the remote server, and updates the locally recorded remote folder directory based on the at least one file, to obtain the remote directory. In other words, a changed file may be regarded as having incremental actions in the file. After the client obtains incremental files, incremental synchronization may be performed according to the file object set, thereby improving file synchronization efficiency.

[0088] Specifically, if the file object set includes at least one file, the at least one file is pulled by using the remote server. For each of the pulled files, the client checks whether the file already exists in the locally recorded remote folder directory. If the file does not exist, information of the file is added at a corresponding location. If the file exists, relevant information of the file is updated, such as file content and modification time. Based on the foregoing operations, the locally recorded remote folder directory is updated to obtain the remote directory. If the file object set includes at least one folder, files in the at least one folder are pulled by using the remote server. For each of the pulled folders and the files therein, the client checks whether the folder already exists in the locally recorded remote folder directory. If the file does not exist, information of the folder and all files therein is added at a corresponding location. If the folder exists, relevant information of the folder and the files therein is updated. Based on the foregoing operations, the locally recorded remote folder directory is updated to obtain the remote directory.

[0089] Case 2: The client pulls, if the file object set includes at least one folder, files in at least one sub-folder by using the remote server, and updates the locally recorded remote folder directory based on the files, to obtain the remote directory. In other words, a changed sub-folder is regarded as having deletion actions in the sub-folder. In this way, after obtaining the changed sub-folder, the client may directly pull files in the changed sub-folder and update the changed sub-folder, thereby improving file synchronization efficiency.

[0090] For example, still referring to FIG. 4, the client reconstructs the locally recorded remote folder directory according to file 3, re-pulls all files in sub-folder 1 from the remote server to reconstruct the locally recorded remote folder directory, and updates SSN of file 3 and sub-folder 1 recorded by the client. The updated SSN of sub-folder 1 is a timestamp generated by the server clock at the moment when file 2 is deleted, and the updated SSN of file 3 is a timestamp generated by the server clock at the moment when file 3 is modified. Similarly, incremental detection may be performed in each of the subsequent detection periods, so that a remote folder directory recorded by the client may be updated in real time according to data in the remote server.

[0091] In the second possible implementation, the client obtains remote state information of each of the file objects in the remote folder according to a set detection period. For each detection period, if it is determined based on the remote state information and local state information of each of the file objects in the current detection period that at least one changed file object exists among the file objects, the locally cached remote folder directory is updated based on the at least one changed file object.

[0092] In other words, the client may periodically obtain SSN′ of each of the file objects in the remote folder by using the remote server. Then, the client screens out changed file objects from the file objects according to SSN of each of the file objects recorded in the client and SSN′ of each of the file objects, and updates the locally recorded remote folder directory according to the changed file objects. In this way, when performing the current file synchronization, the client takes a locally currently recorded remote folder directory as the remote directory.

[0093] Since the process for the client to determine the changed file objects and the process for updating the locally recorded remote folder directory according to the changed file objects are the same as those in the first possible implementation. Details are not described again herein.

[0094] By way of example, FIG. 5 shows another schematic logic diagram of constructing a remote folder directory according to some embodiments.

[0095] First, the client transmits a query request for obtaining the remote folder to the remote server. After receiving the query request, the remote server returns the current remote folder, as well as SSN′ of each file and each sub-folder in the current remote folder to the client.

[0096] Based on the received remote folder and SSN′ of each of the file objects, the client obtains an initialized remote folder directory recorded locally and SSN of each of the file objects. A directory structure of the initialized remote folder directory is the same as the directory structure of the current remote folder in the remote server, and SSN of sub-folder 1, sub-folder 2, file 1, file 2, file 3, and file 4 recorded in the client is the same as the received SSN′.

[0097] It is assumed that operations triggered by a target object on the remote folder include: editing and then deleting file 2 in sub-folder 1, and editing file 3 in sub-folder 2. Sub-folder 1, file 2, and file 3 all undergo target processing operations, and therefore the values of SSN′ of sub-folder 1, file 2, and file 3 increase.

[0098] In a first detection period, the client transmits a detection request to the remote server. After receiving the detection request, the remote server returns SSN′ of sub-folder 1, sub-folder 2, file 1, file 2, file 3, and file 4 to the client. The client respectively compares SSN and SSN′ corresponding to sub-folder 1, sub-folder 2, file 1, file 2, and file 3. At this time, SSN′ of sub-folder 1 is greater than SSN of sub-folder 1, SSN′ of file 2 is greater than SSN of file 2, and SSN′ of file 3 is greater than SSN of file 3. Sub-folder 1, file 2, and file 3 all change. However, since file 2 is a file in sub-folder 1, sub-folder 1 is taken as the changed sub-folder, and file 3 is taken as the changed file.

[0099] Then, the client reconstructs the locally recorded remote folder directory according to file 3, re-pulls all files in sub-folder 1 from the remote server to reconstruct the locally recorded remote folder directory, and updates SSN of file 3 and sub-folder 1 recorded by the client.

[0100] Similarly, incremental file detection may be performed in each of the subsequent detection periods, so that a remote folder directory recorded by the client may be updated in real time according to data in the remote server.

[0101] Some embodiments only illustrate examples in which server clocks are adopted to generate and update SSN. In practical application, other manners may be adopted to generate and update SSN.

[0102] In some embodiments, when the locally recorded local folder directory and remote folder directory of the client remain stable within a period of time, it is considered that the current synchronization task is to be executed. At this time, the current file synchronization is triggered, and the cached local folder directory, local folder directory and synchronization directory are obtained for subsequent processing.

[0103] The local folder directory and the remote folder directory may be persisted. For example, the local folder directory and the remote folder directory are stored in a database. In this case, the client may obtain the local directory and the remote directory from the database.

[0104] S202: Obtain, based on the local directory, the remote directory, and the synchronization directory, both a local change operation set occurring in the local folder and a remote change operation set occurring in the remote folder from the end of the previous file synchronization to the synchronization moment.

[0105] In some embodiments, based on the local directory and the synchronization directory, the client obtains the local change operation set occurring in the local folder from the end of the previous file synchronization to the synchronization moment. Based on the remote directory and the synchronization directory, the client obtains the remote change operation set occurring in the remote folder from the end of the previous file synchronization to the synchronization moment. The obtaining processes of the local change operation set and the remote change operation set are similar. Only the local change operation set is described as an example below.

[0106] The local change operation set refers to a set of a series of operations occurring in the local folder from the end of the previous file synchronization to the synchronization moment, including but not limited to addition, deletion, modification, and movement operations of files or sub-folders. The remote change operation set refers to a set of a series of operations occurring in the remote folder from the end of the previous file synchronization to the synchronization moment, including but not limited to addition, deletion, modification, and movement operations of files or sub-folders.

[0107] Specifically, in some embodiments, the local change operation set is obtained in the following manner:

[0108] The client sequentially executes, based on a directory structure of the local directory, the following operations on local file objects in the local directory:

[0109] comparing respective directory locations of synchronized file objects in the synchronization directory with a directory location of one local file object among the local file objects;

[0110] determining, based on a comparison result, a reference change operation corresponding to the local file object; and

[0111] obtaining, based on the reference change operation corresponding to each of the local file objects, the local change operation set occurring in the local folder from the end of the previous file synchronization to the synchronization moment.

[0112] The reference change operation refers to an operation corresponding to a local file object determined by the client based on a comparison result of directory locations of the local file object in the local directory and a synchronized file object in the synchronization directory, and is configured for obtaining the local change operation set occurring in the local folder from the end of the previous file synchronization to the synchronization moment.

[0113] Herein, the process of comparing the local directory with the synchronization directory and outputting the local change operation set may be referred to as a Diff process.

[0114] In some embodiments, based on the directory structure of the local directory, the client traverses the local file objects under the local directory in sequence by adopting hierarchical traversal. A local file object may be a file in the local folder or a sub-folder in the local folder.

[0115] For example, FIG. 6 shows a schematic diagram of a local directory and a synchronization directory according to some embodiments. It is assumed that a root directory of the local directory contains a sub-folder “Game”, a sub-folder “Movie”, and a sub-folder “Work”. The sub-folder “Game” contains a file “Plan 1.txt”, and the sub-folder “Work” contains files “Proposal 1.doc” and “Proposal 3.doc”. A root directory of the synchronization directory contains a sub-folder “Game”, a sub-folder “Work”, and a file “Movie. txt”. The sub-folder “Game” contains a file “Plan 2.txt”, and the sub-folder “Work” contains files “Proposal 1.doc” and “Proposal 3.txt”. Based on the directory structure of the local directory, the client traverses the local file objects in the local directory in sequence by adopting hierarchical traversal. For example, the client traverses the local file objects in the local directory in the following order: sub-folder “Game”→sub-folder “Movie”→sub-folder “Work”→file “Plan 1.txt”→“Proposal 1.doc”→“Proposal 3.doc”. Upon traversing each local file object, the client compares the directory location of each synchronized file object in the synchronization directory (sub-folder “Game”, sub-folder “Work”, and files “Movie. txt”, “Plan 2.txt”, “Proposal 1.doc”, and “Proposal 3.txt”) with the directory location of the local file object respectively, and determines a reference change operation corresponding to the local file object based on a comparison result.

[0116] In some embodiments, when comparing the directory location of each of the synchronized file objects in the synchronization directory with the directory location of the local file object, the client may check whether the directory locations of the synchronized file object and the local file object are the same. The directory location is configured for representing a route from the root directory to the file object, and the directory location may be referred to as a path. For example, the directory location of the sub-folder “Game” in the local directory is: Root Directory / Game.

[0117] In some embodiments, when determining, based on a comparison result, a reference change operation corresponding to the local file object, at least the following cases exist:

[0118] Case A: Determine, if the comparison result indicates the presence of one synchronized file object having the same directory location as the local file object, the reference change operation corresponding to the local file object based on object types of the local file object and the synchronized file object.

[0119] It is assumed that X represents the local file object, and Y represents the synchronized file object with the same directory location as X.

[0120] In some embodiments, the directory locations of the local file object and the synchronized file object are both represented by file names. Since sub-folders and files may have duplicate names, X and Y may be of the same object type or different object types, and the determined reference change operation of X may vary in different cases. Next, several possible existing cases are described respectively.

[0121] Case A-1: Both X and Y are sub-folders.

[0122] If both X and Y are sub-folders, the client further obtains respective file identifiers of X and Y (if a hash value of file content is adopted as a file identifier), and compares whether the two hash values are equal. If the hash values are equal, it is determined that X and Y are the same folder, indicating that X has no change. If the hash values are unequal, it is determined that X and Y are different folders, indicating that X has changed. The file identifier is configured for uniquely identifying a file object, and the file identifier may adopt the hash value of file content, but is not limited thereto.

[0123] In a case that X and Y are different folders, the client may further determine whether a synchronized file object (denoted as srcnode) with the same file identifier as X exists in a file hash table corresponding to the synchronization directory. If the object exists, it is determined that the reference change operation of X includes an operation of deleting the synchronized file object with the same file identifier as X in the synchronization directory and an operation of updating the file identifier of sub-folder X. If the object does not exist, it is determined that the reference change operation of X is updating the file identifier of folder X.

[0124] The file hash table is a data structure for storing and retrieving file identifiers. By mapping file identifiers to array indexes, the hash table realizes fast query, insertion, and deletion operations, thereby greatly improving the efficiency of file management. A file system uses the hash table to quickly query file metadata, such as permissions, creation time, and size, without traversing the entire directory tree.

[0125] For example, with reference to FIG. 7A, in view of the local directory and the synchronization directory in FIG. 6, when the client traverses to the sub-folder “Game”, the synchronization directory contains a synchronized file object with the same directory location: the sub-folder “Game”. Therefore, the client further determines whether the file identifiers of the sub-folder “Game” under the local directory and the sub-folder “Game” under the synchronization directory are the same. Assuming that the file identifiers of the sub-folder “Game” under the local directory and the sub-folder “Game” under the synchronization directory are the same, the client determines that the sub-folder “Game” under the local directory has no change.

[0126] Case A-2: Both X and Y are files.

[0127] If both X and Y are files, the client further determines whether file identifiers of X and Y are the same.

[0128] If the file identifiers of X and Y are the same, the client may compare whether various metadata of X and Y are the same. If the various metadata of X and Y are the same, it is determined that X has no change. If there is any difference in various metadata of X and Y, it is determined that the reference change operation of X is a modification operation. The various metadata include, but are not limited to, one or more of modification time and file size.

[0129] If the file identifiers of X and Y are different, the client further detects whether X has been moved. If X has not been moved, the reference change operation of X is determined as a modification operation. If X has been moved, three file objects will occur at this time: X before movement in the synchronization directory (denoted as srcnode), X, and Y. In a case that various metadata of X and srcnode are the same and the file contents of X and Y are the same, the reference change operation of X is determined as a deletion operation or an operation of updating the file identifier of the file. In a case that various metadata of X and srcnode are the same but the file contents of X and Y are different, the reference change operation of X is determined as a movement operation or a deletion operation. In a case that various metadata of X and srcnode are different, the reference change operation of X is determined as a modification operation or a deletion operation.

[0130] For example, with reference to FIG. 7B, when the client traverses to the file “Proposal 1.doc” under the sub-folder “Work”, the synchronization directory contains a synchronized file object with the same directory location: the file “Proposal 1.doc” under the sub-folder “Work”. The file “Proposal 1.doc” under the local directory is equivalent to X, and the file “Proposal 1.doc” under the synchronization directory is equivalent to Y. At this time, the client further determines whether the file identifiers of the file “Proposal 1.doc” under the local directory and the file “Proposal 1.doc” under the synchronization directory are the same. It is assumed that the file identifiers are different, a synchronized file with the same file identifier as the file “Proposal 1.doc” under the local directory exists in the hash table corresponding to the synchronization directory, and the metadata and file content of the synchronized file are all different from those of the file “Proposal 1.doc” under the local directory. At this time, the client determines that the reference change operation corresponding to the file “Proposal 1.doc” under the local directory is a movement operation or a deletion operation.

[0131] Case A-3: One of X and Y is a file, and the other is a sub-folder.

[0132] If one of X and Y is a file and the other is a sub-folder, the client further determines whether X has been moved. If X has not been moved, the reference change operation of X is a deletion operation or an addition operation. If X has been moved, three file objects will occur at this time: X before movement in the synchronization directory (denoted as srcnode), X, and Y. In a case that X is a file, srcnode is a sub-folder, and X has the same file identifier as srcnode, the reference change operation of X is determined as a deletion operation or a movement operation. In a case that X is a file, srcnode is a sub-folder, and X has a different file identifier from srcnode, the reference change operation of X is determined as a deletion operation or an addition operation. In a case that srcnode is a file and X is a sub-folder, the reference change operation of X is determined as a deletion operation or an addition operation.

[0133] Case B: Determine, if the comparison result indicates the absence of one synchronized file object having the same directory location as the local file object, the reference change operation corresponding to the local file object based on a file identifier of each of the synchronized file objects.

[0134] Specifically, based on the respective file identifiers of the synchronized file objects, the client searches in the file hash table corresponding to the synchronization directory using the file identifier of X as a key. If no synchronized file object with the same file identifier is found, the reference change operation of X is determined as an addition operation. If a synchronized file object with the same file identifier is found (denoted as srcnode), the reference change operation corresponding to X is determined based on file types of X and srcnode.

[0135] When determining, based on file types of X and srcnode, a reference change operation corresponding to the local file object, at least the following cases exist:

[0136] Case B-1: X and srcnode have the same path and are both folders. At this time, the client determines that the reference change operation of X is a movement operation.

[0137] Case B-2: X and srcnode have the same path and are both files. In a case that various metadata of srcnode and X are the same, the client determines that the reference change operation of X is a movement operation. In a case that various metadata of srcnode and X are different, the client determines that the reference change operation of X is a modification operation.

[0138] Case B-3: X and srcnode have different paths and are both files. In a case that various metadata of srcnode and X are the same, the client determines that the reference change operation of X is a movement operation. In a case that various metadata of srcnode and X are different, the client determines that the reference change operation of X is a deletion operation or an addition operation.

[0139] In some cases, if the client identifies that a deletion operation has been performed on a target deleted file object locally, the reference change operation further includes: a deletion operation for the target deleted file object in the remote directory. Further, when the client executes the deletion operation, if the SSN of a to-be-deleted file object changes, it indicates that the content of the file object may have changed, and thus the deletion operation may not be executed.

[0140] S203: Perform difference analysis on the local change operation set and the remote change operation set, and plan, based on an analysis result, to-be-executed target change operations in the current file synchronization.

[0141] The target change operations refer to operations to be executed in the current file synchronization planned after difference analysis is performed on the local change operation set and the remote change operation set, aiming to keep the file contents of the local folder and the remote folder consistent.

[0142] Specifically, when performing S203, the following operations may be adopted but not limited thereto:

[0143] S203-1: The client obtains, based on a set instruction generation manner, respective local executable instructions corresponding to local change operations in the local change operation set, and obtains, based on the instruction generation manner, respective remote executable instructions corresponding to remote change operations in the remote change operation set.

[0144] The local executable instructions are instructions converted according to the local change operations in the local change operation set based on the set instruction generation manner, and are configured for indicating corresponding operations to be executed on the local folder.

[0145] In some embodiments, the local change operations include one or more of an addition operation, a deletion operation, a modification operation, a movement operation, and no-operation. The addition operation includes one or more of a file addition operation and a folder addition operation. The deletion operation includes one or more of a file deletion operation and a folder deletion operation. The modification operation includes one or more of a file modification operation and a folder modification operation. The movement operation includes one or more of a file movement operation and a folder movement operation.

[0146] The set instruction generation manner may be as follows: the addition operation corresponds to an addition instruction {operation: ‘add’, path:‘file object path’}; the deletion operation corresponds to a deletion instruction {operation: ‘del’, path:‘file object path’}; the modification operation corresponds to a modification instruction {operation: ‘mod’, path:‘file object path’}; the movement operation corresponds to a movement instruction {operation: ‘move’, path:‘original file object path’, newPath: ‘new file object path’}; and the no-operation corresponds to {−}.

[0147] Similarly, the remote change operations include one or more of an addition operation, a deletion operation, a modification operation, a movement operation, and no-operation. The addition operation includes one or more of a file addition operation and a folder addition operation. The deletion operation includes one or more of a file deletion operation and a folder deletion operation. The modification operation includes one or more of a file modification operation and a folder modification operation. The movement operation includes one or more of a file movement operation and a folder movement operation.

[0148] In an example where a file object to be operated is ‘A / a’, A is a sub-folder under the root directory, and a may be a file or a sub-folder in sub-folder A. The local executable instruction includes: one or more of an addition instruction {operation: ‘add’, path:‘A / a’}, a deletion instruction {operation: ‘del’, path:‘A / a’}, a modification instruction {operation: ‘mod’, path:‘A / a’}, a movement instruction {operation: ‘move’, path:‘A / a’, newPath: ‘B / a’}, and no-operation {−}, where “operation” indicates the operation type, and “path” is configured for indicating the file object to be operated.

[0149] In the set instruction generation manner, the addition operation corresponds to the addition instruction, the deletion operation corresponds to the deletion instruction, the modification operation corresponds to the modification instruction, the movement operation corresponds to the movement instruction, and the no-operation corresponds to {−}.

[0150] For example, if the addition operation is to add file a in folder A / , the client may convert the addition operation into the addition instruction {operation: ‘add’, path:‘A / a’}.

[0151] S203-2: Perform, based on the set instruction execution manner, rule-based simulation on each of the obtained local executable instructions and remote executable instructions, and obtain, based on a simulation result, the to-be-executed target change operations in the current file synchronization.

[0152] The remote executable instructions are instructions converted according to the remote change operations in the remote change operation set based on the set instruction generation manner, and are configured for indicating corresponding operations to be executed on the remote folder.

[0153] The rule-based simulation refers to a process of performing, based on the set instruction execution manner, analysis and simulation on each of the obtained local executable instructions and remote executable instructions. By means of this process, the to-be-executed target change operations in the current file synchronization may be obtained.

[0154] In some embodiments, the process is as follows: First, the local executable instructions and the remote executable instructions are sorted according to an instruction sorting rule. The sorting rule includes that the deletion instruction and the movement instruction are executed prior to the addition instruction and the modification instruction. The deletion instruction and the movement instruction are sorted according to the number of path layers, where the instruction with more layers is executed first, and the instruction with fewer layers is executed later. The addition instruction and the modification instruction are sorted according to the number of path layers, where the instruction with fewer layers is executed first, and the instruction with more layers is executed later. If all the foregoing conditions are consistent, the remote executable instructions are executed prior to the local executable instructions. Then, the sorted instructions are analyzed according to an instruction processing rule, and the to-be-executed target change operations are determined based on preset rules for combinations of local executable instructions and remote executable instructions of different types, as shown in the foregoing various cases of two-way synchronization. Based on the foregoing rule-based simulation result, the to-be-executed target change operations in the current file synchronization are obtained.

[0155] The rules of the instruction execution manner may include that: the deletion instruction and the movement instruction are executed prior to the addition instruction and the modification instruction. The deletion instruction and the movement instruction are sorted according to the number of path layers, where the instruction with more layers is executed first, and the instruction with fewer layers is executed later. The addition instruction and the modification instruction are sorted according to the number of path layers, where the instruction with fewer layers is executed first, and the instruction with more layers is executed later. If all the foregoing conditions are consistent, the remote executable instructions are executed prior to the local executable instructions.

[0156] In some embodiments, the instruction simulation process may be implemented in but not limited to the following manner:

[0157] The client sorts the local executable instructions and the remote executable instructions according to the set instruction sorting rule, and analyzes the instructions in accordance with the set instruction processing rule based on a sorting result to obtain a simulation result.

[0158] The instruction sorting rule includes at least one of the following rule 1 to rule 4:

[0159] Rule 1: The deletion instruction and the movement instruction are executed prior to the addition instruction and the modification instruction. For example, the deletion instruction {operation: ‘del’, path:‘A / a’} is executed prior to the addition instruction {operation: ‘add’, path:‘B / a’}.

[0160] Rule 2: The deletion instruction and the movement instruction are sorted according to the number of path layers, where the instruction with more layers is executed first, and the instruction with fewer layers is executed later. For example, the deletion instruction {operation: ‘del’, path:‘A / a’} is executed earlier than the deletion instruction {operation: ‘del’, path:‘A’}. For another example, the movement instruction {operation: ‘move’, path:‘A / a’} is executed earlier than the movement instruction {operation: ‘move’, path:‘A’}. The number of layers may be referred to as directory levels.

[0161] Rule 3: The addition instruction and the modification instruction are sorted according to the number of path layers, where the instruction with fewer layers is executed first, and the instruction with more layers is executed later. For example, the addition instruction {operation: ‘add’, path:‘A’} is executed earlier than the addition instruction {operation: ‘add’, path:‘A / a’}. For another example, the modification instruction {operation: ‘mod’, path:‘A’} is executed earlier than the modification instruction {operation: ‘mod’, path:‘A / a’}. The number of layers may be referred to as directory levels.

[0162] Rule 4: If all conditions 1 to 3 are consistent, the remote executable instructions are executed prior to the local executable instructions.

[0163] In some embodiments, different instruction processing rules may be set for two-way synchronization and one-way synchronization. Only two-way synchronization is taken as an example for description herein.

[0164] In the instruction processing rule for two-way synchronization, it is assumed that each of the local executable instructions includes an addition instruction {operation: ‘add’, path:‘A / a’}. The following cases exist according to the instruction types in the remote executable instructions and the file object to be operated:

[0165] Case 1: Each of the remote executable instructions includes an addition instruction {operation: ‘add’, path:‘A / a’} or a modification instruction {operation: ‘mod’, path:‘A / a’} for the file object ‘A / a’.

[0166] Case 1.1: Both ‘A / a’ in the local executable instruction and ‘A / a’ in the remote executable instruction are files.

[0167] If the files ‘A / a’ in the remote folder and the local folder are equal finally, to be specific, there is no conflict between the local executable instruction and the remote executable instruction, the to-be-executed target change operation is {operation: ‘updateTree’,‘A / a’}, where {operation: ‘updateTree’,‘A / a’} indicates updating ‘A / a’ in the synchronization directory.

[0168] If a conflict occurs between the local executable instruction and the remote executable instruction, one target conflict handling manner is selected from conflict handling manners including uploading local files to overwrite remote files, downloading remote files to overwrite local files, and local renaming and uploading, for conflict handling. The target conflict handling manner may be selected by a target object after a conflict occurs, or preset by the target object. This is not limited herein.

[0169] If the target conflict handling mode is uploading local files to overwrite remote files, the to-be-executed target change operation is {operation: ‘upload’, path:‘A / a’}, where {operation: ‘upload’, path:‘A / a’} indicates uploading the file ‘A / a’. If the target conflict handling mode is downloading remote files to overwrite local files, the to-be-executed target change operation is {operation: ‘download’, path:‘A / a’}, where {operation: ‘download’, path:‘A / a’} indicates downloading the file ‘A / a’. If the target conflict handling mode is local renaming and uploading, the to-be-executed target change operation includes: {operation: ‘moveLocal’, path:‘A / a’, newPath: ‘A / a_timestamp’}, {operation: ‘download’, path:‘A / a’}, and {operation: ‘upload’, path:‘A / a_timestamp’}, where {operation: ‘moveLocal’, path:‘A / a’, newPath: ‘A / a_timestamp’} indicates moving the file ‘A / a’ in the local folder to ‘A / a_timestamp’, {operation: ‘download’, path:‘A / a’} indicates downloading the file ‘A / a’, and {operation: ‘upload’, path:‘A / a_timestamp’} indicates uploading the file ‘A / a_timestamp’.

[0170] Case 1.2: Both ‘A / a’ in the local executable instruction and ‘A / a’ in the remote executable instruction are folders. At this time, the to-be-executed target change operation is {operation: ‘updateTree’,‘A / a’}.

[0171] Case 1.3: One of ‘A / a’ in the local executable instruction and ‘A / a’ in the remote executable instruction is a folder, and the other is a file.

[0172] If ‘A / a’ in the local executable instruction is a file, the to-be-executed target change operation includes: {operation: ‘moveLocal’, path:‘A / a’, newPath: ‘A / a_temp’}, {operation: ‘upload’, path:‘A / a_temp’}, and {operation: ‘createLocalFolder’, path:‘A / a’}, where {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 the folder ‘A / a’. A case of B / a / c→A / a / c may exist in the remote folder. At this time, {operation: ‘moveLocal’, path:‘A / a’, newPath: ‘A / a_temp’} and {operation: ‘upload’, path:‘A / a_temp’} need to be inserted to precede all target change operations in which paths start with A / a.

[0173] If ‘A / a’ in the remote executable instruction is a file, the to-be-executed target change operation includes: {operation: ‘moveRemote’, path:‘A / a’, newPath: ‘A / a_temp’}, {operation: ‘download’, path:‘A / a_temp’}, and {operation: ‘createRemoteFolder’, path:‘A / a’}, where {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 the folder ‘A / a’. Similarly, a case of B / a / c→A / a / c may exist in the local folder. At this time, {operation: ‘moveLocal’, path:‘A / a’, newPath: ‘A / a_temp’} and {operation: ‘upload’, path:‘A / a_temp’} need to be inserted to precede all target change operations in which paths start with A / a.

[0174] Case 2: Each of the remote executable instructions includes a movement instruction {operation: ‘move’, path:‘A / a’, newPath: ‘B / a’} for the file object ‘A / a’.

[0175] Case 2.1: Both ‘A / a’ in the local executable instruction and ‘A / a’ in the remote executable instruction are files. The to-be-executed target change operation includes: {operation: ‘del’, path:‘B / a’} and {operation: ‘add’, path:‘A / a’}, where {operation: ‘del’, path:‘B / a’} indicates deleting ‘B / a’, and {operation: ‘add’, path:‘A / a’} indicates adding ‘A / a’.

[0176] Case 2.2: Both ‘A / a’ in the local executable instruction and ‘A / a’ in the remote executable instruction are folders. The to-be-executed target change operation includes: {operation: ‘deleteLocalFolder’, path:‘B / a’} and {operation: ‘updateTree’,‘A / a’}, where {operation: ‘deleteLocalFolder’, path:‘B / a’} indicates deleting the local folder ‘B / a’, and {operation: ‘updateTree’,‘A / a’} indicates updating a synchronization tree according to ‘A / a’.

[0177] Case 2.3: One of ‘A / a’ in the local executable instruction and ‘A / a’ in the remote executable instruction is a folder, and the other is a file.

[0178] If ‘A / a’ in the local executable instruction is a file, the to-be-executed target change operation includes: {operation: ‘moveLocal’, path:‘A / a’, newPath: ‘A / a_temp’}, {operation: ‘upload’, path:‘A / a_temp’}, and {operation: ‘moveLocalFolder’, path:‘B / a’, newPath: ‘A / a’}, where {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’. A case of B / a / c→A / a / c may exist in the remote folder. At this time, {operation: ‘moveLocal’, path:‘A / a’, newPath: ‘A / a_temp’} and {operation: ‘upload’, path:‘A / a_temp’} need to be inserted to precede all target change operations in which paths start with A / a.

[0179] If ‘A / a’ in the remote executable instruction is a file, the remote has performed a movement operation on ‘A / a’ to ‘B / a’, while the local side regards ‘A / a’ as a file and has corresponding operations. To keep the local and remote states consistent, it is necessary to first delete ‘B / a’ (i.e., {operation: ‘del’, path:‘B / a’}), and then add ‘A / a’ (i.e., {operation: ‘add’, path:‘A / a’}. Therefore, the to-be-executed target change operation is: {operation: ‘del’, path:‘B / a’} and {operation: ‘add’, path:‘A / a’}.

[0180] Case 3: Each of the remote executable instructions includes a deletion instruction {operation: ‘del’, path:‘A / a’} for the file object ‘A / a’. At this time, due to the same name of files and folders, there may be a case that one of ‘A / a’ in the local executable instruction and ‘A / a’in the remote executable instruction is a folder, and the other is a file.

[0181] If ‘A / a’ in the local executable instruction is a file, the to-be-executed target change operation is: {operation: ‘upload’, path: ‘A / a’} (uploading ‘A / a’).

[0182] If ‘A / a’ in the remote executable instruction is a file, the to-be-executed target change operation is: {operation: ‘createRemoteFolder’, path:‘A / a’} (creating the remote sub-folder ‘A / a’).

[0183] Case 4: No operation is performed on the file object ‘A / a’ in each of the remote executable instructions.

[0184] Case 4.1:‘A / a’ in the local executable instruction is a file. At this time, the to-be-executed target change operation is {operation: ‘upload’, path:‘A / a’}. In addition, it is necessary to determine whether a folder with the same name exists in the remote folder. If the folder exists, the folder is renamed and uploaded, and the renaming and uploading operations need to be inserted to precede all path A / a operations, so as to avoid the existence of the file ‘A / a’in the original remote folder.

[0185] Case 4.2:‘A / a’ in the local executable instruction is a folder. At this time, the to-be-executed target change operation is: {operation: ‘createRemoteFolder’, path:‘A / a’} (creating the local sub-folder ‘A / a’).

[0186] In the instruction processing rule for two-way synchronization, it is assumed that each of the local executable instructions includes a deletion instruction {operation: ‘del’, path:‘A / a’}. The following cases exist according to the instruction types in the remote executable instructions and the file object to be operated:

[0187] Case 5: Each of the remote executable instructions includes a deletion instruction {operation: ‘del’, path:‘A / a’} (deleting ‘A / a’).

[0188] Case 5.1: Both ‘A / a’ in the local executable instruction and ‘A / a’ in the remote executable instruction are files. At this time, the to-be-executed target change operation is: {operation: ‘updateTree’,‘A / a’}.

[0189] Case 5.2: Both ‘A / a’ in the local executable instruction and ‘A / a’ in the remote executable instruction are folders. At this time, the to-be-executed target change operation is: {operation: ‘updateTree’,‘A / a’}.

[0190] Case 6: Each of the remote executable instructions includes a modification instruction {operation: ‘mod’, path:‘A / a’} for the file object ‘A / a’.

[0191] Case 6.1: Both ‘A / a’ in the local executable instruction and ‘A / a’ in the remote executable instruction are files.

[0192] If the file object ‘A / a’ does not exist in the local folder, the to-be-executed target change operation is: {operation: ‘download’, path:‘A / a’} (downloading ‘A / a’).

[0193] If the file object ‘A / a’ exists in the local folder, the to-be-executed target change operation includes: {operation: ‘moveRemote’, path:‘A / a’, newPath: ‘A / a_temp’} (moving ‘A / a’ in the remote folder to ‘A / a_temp’) and {operation: ‘download’, path: ‘A / a_temp’} (downloading ‘A / a_temp’).

[0194] Since folders do not support modification operations, there is no case that ‘A / a’ in the local executable instruction and ‘A / a’in the remote executable instruction are folders.

[0195] Case 7: Each of the remote executable instructions includes a movement instruction {operation: ‘move’, path:‘A / a’, newPath: ‘B / a’} for the file object ‘A / a’ (moving a in folder A to folder B).

[0196] Case 7.1: Both ‘A / a’ in the local executable instruction and ‘A / a’ in the remote executable instruction are files. At this time, the to-be-executed target change operation is: {operation: ‘deleteRemote’, path:‘B / a’} (deleting the file ‘B / a’ in the remote folder), where {operation: ‘deleteRemote’, path:‘B / a’} needs to be executed before all target change operations for folder B.

[0197] Case 7.2: Both ‘A / a’ in the local executable instruction and ‘A / a’ in the remote executable instruction are folders. At this time, the to-be-executed target change operation is: {operation: ‘deleteRemoteFolder’, path: ‘B / a’} (deleting the sub-folder ‘B / a’ in the remote folder), where {operation: ‘deleteRemoteFolder’, path: ‘B / a’} needs to be inserted to precede all target change operations for folder B.

[0198] Case 8: No operation is performed on the file object ‘A / a’ in each of the remote executable instructions.

[0199] Case 8.1:‘A / a’ in the local executable instruction is a file. At this time, the to-be-executed target change operation is: {operation: ‘deleteRemote’, path:‘A / a’} (deleting the file ‘A / a’in the remote folder).

[0200] Case 8.2:‘A / a’ in the local executable instruction is a folder. At this time, the to-be-executed target change operation is: {operation: ‘deleteRemoteFolder’, path:‘B / a’} (deleting the sub-folder ‘A / a’in the remote folder).

[0201] In the instruction processing rule for two-way synchronization, it is assumed that each of the local executable instructions includes a modification instruction {operation: ‘mod’, path:‘A / a’}. The following cases exist according to the instruction types in the remote executable instructions and the file object to be operated:

[0202] Case 9: Each of the remote executable instructions includes an addition instruction {operation: ‘add’, path:‘A / a’} (adding ‘A / a’).

[0203] Case 9.1: Both ‘A / a’ in the local executable instruction and ‘A / a’ in the remote executable instruction are files.

[0204] If the files ‘A / a’ in the remote folder and the local folder are equal finally, to be specific, there is no conflict between the local executable instruction and the remote executable instruction, the to-be-executed target change operation is {operation: ‘updateTree’,‘A / a’}.

[0205] If a conflict occurs between the local executable instruction and the remote executable instruction, one target conflict handling manner is selected from conflict handling manners including uploading local files to overwrite remote files, downloading remote files to overwrite local files, and local renaming and uploading, for conflict handling. The target conflict handling manner may be selected by a target object after a conflict occurs, or preset by the target object. This is not limited herein.

[0206] If the target conflict handling mode is uploading local files to overwrite remote files, the to-be-executed target change operation is {operation: ‘upload’, path:‘A / a’} (uploading the file ‘A / a’). If the target conflict handling mode is downloading remote files to overwrite local files, the to-be-executed target change operation is {operation: ‘download’, path:‘A / a’} (downloading the file ‘A / a’). If the target conflict handling mode is local renaming and uploading, the to-be-executed target change operation includes: {operation: ‘moveLocal’, path:‘A / a’, newPath: ‘A / a_timestamp’} (moving the file ‘A / a’ in the local folder to ‘A / a_timestamp’), {operation: ‘download’, path:‘A / a’} (downloading the file ‘A / a’), and {operation: ‘upload’, path:‘A / a_timestamp’} (uploading the file ‘A / a_timestamp’).

[0207] Case 9.2: One of ‘A / a’ in the local executable instruction and ‘A / a’ in the remote executable instruction is a folder, and the other is a file.

[0208] The to-be-executed target change operation includes: {operation: ‘moveRemote’, path:‘A / a’, newPath: ‘A / a_temp’}, {operation: ‘download’, path: ‘A / a_temp’}, and {operation: ‘createRemoteFolder’, path:‘A / a’}, where {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 the folder ‘A / a’, where {operation: ‘moveLocal’, path:‘A / a’, newPath: ‘A / a_temp’} and {operation: ‘upload’, path: ‘A / a_temp’} need to be inserted to precede all target change operations in which paths start with A / a.

[0209] Case 10: Each of the remote executable instructions includes a modification instruction {operation: ‘mod’, path:‘A / a’} (modifying ‘A / a’).

[0210] Case 10.1: Both ‘A / a’ in the local executable instruction and ‘A / a’ in the remote executable instruction are files.

[0211] If the files ‘A / a’ in the remote folder and the local folder are equal finally, to be specific, there is no conflict between the local executable instruction and the remote executable instruction, the to-be-executed target change operation is {operation: ‘updateTree’,‘A / a’}.

[0212] If a conflict occurs between the local executable instruction and the remote executable instruction, one target conflict handling manner is selected from conflict handling manners including uploading local files to overwrite remote files, downloading remote files to overwrite local files, and local renaming and uploading, for conflict handling. The target conflict handling manner may be selected by a target object after a conflict occurs, or preset by the target object. This is not limited herein.

[0213] If the target conflict handling mode is uploading local files to overwrite remote files, the to-be-executed target change operation is {operation: ‘upload’, path:‘A / a’} (uploading the file ‘A / a’). If the target conflict handling mode is downloading remote files to overwrite local files, the to-be-executed target change operation is {operation: ‘download’, path:‘A / a’} (downloading the file ‘A / a’). If the target conflict handling mode is local renaming and uploading, the to-be-executed target change operation includes: {operation: ‘moveLocal’, path:‘A / a’, newPath: ‘A / a_timestamp’} (moving the file ‘A / a’ in the local folder to ‘A / a_timestamp’), {operation: ‘download’, path:‘A / a’} (downloading the file ‘A / a’), and {operation: ‘upload’, path: ‘A / a_timestamp’} (uploading the file ‘A / a_timestamp’).

[0214] Case 11: Each of the remote executable instructions includes a deletion instruction {operation: ‘del’, path:‘A / a’} (deleting ‘A / a’).

[0215] Case 11.1: Both ‘A / a’ in the local executable instruction and ‘A / a’ in the remote executable instruction are files.

[0216] If the file ‘A / a’ does not exist in the local folder, the to-be-executed target change operation is: {operation: ‘upload’, path:‘A / a’} (uploading ‘A / a’).

[0217] If the file ‘A / a’ exists in the local folder, the to-be-executed target change operation includes: {operation: ‘moveLocal’, path:‘A / a’, newPath: ‘A / a_temp’} (moving ‘A / a’ in the local folder to ‘A / a_temp’) and {operation: ‘upload’, path:‘A / a_temp’} (uploading the file ‘A / a_temp’).

[0218] Case 12: Each of the remote executable instructions includes a movement instruction {operation: ‘move’, path:‘A / a’, newPath: ‘B / a’} for the file object ‘A / a’ (moving a in folder A to folder B).

[0219] Case 12.1: Both ‘A / a’ in the local executable instruction and ‘A / a’ in the remote executable instruction are files.

[0220] If the file ‘B / a’ does not exist in the local folder, the to-be-executed target change operation includes: {operation: ‘moveLocal’, path:‘A / a’, newPath: ‘B / a’} (moving ‘A / a’ in the local folder to ‘B / a’) and {operation: ‘upload’, path:‘A / a’} (uploading ‘A / a’).

[0221] If the file ‘B / a’ exists in the local folder, the to-be-executed target change operation includes: {operation: ‘add’, path:‘B / a’} and {operation: ‘del’, path:‘A / a’}.

[0222] Case 13: No operation is performed on the file object ‘A / a’ in each of the remote executable instructions.

[0223] Case 13.1: Both ‘A / a’ in the local executable instruction and ‘A / a’ in the remote executable instruction are files. At this time, the to-be-executed target change operation includes: {operation: ‘upload’, path:‘A / a’} (uploading the file ‘A / a’).

[0224] In the instruction processing rule for two-way synchronization, it is assumed that each of the local executable instructions includes a movement instruction {operation: ‘move’, path:‘A / a’, newPath: ‘B / a’}. The following cases exist according to the instruction types in the remote executable instructions and the file object to be operated:

[0225] Case 14: Each of the remote executable instructions includes a deletion instruction {operation: ‘del’, path:‘A / a’} (deleting ‘A / a’).

[0226] Case 14.1: Both ‘A / a’ in the local executable instruction and ‘A / a’ in the remote executable instruction are files. At this time, the to-be-executed target change operation is: {operation: ‘delLocal’, path:‘B / a’} (deleting the file ‘B / a’ in the local folder), where {operation: ‘delLocal’, path:‘B / a’} needs to be inserted to precede all target change operations for folder B.

[0227] Case 14.2: Both ‘A / a’ in the local executable instruction and ‘A / a’ in the remote executable instruction are folders. At this time, the to-be-executed target change operation includes: {operation: ‘delLocalFolder’, path:‘B / a’} (deleting the sub-folder ‘B / a’ in the local folder) and {operation: ‘updateTree’,‘A / a’}, where {operation: ‘delLocalFolder’, path:‘B / a’} needs to be executed before all target change operations for folder B.

[0228] Case 15: Each of the remote executable instructions includes a modification instruction {operation: ‘mod’, path:‘A / a’} (modifying ‘A / a’).

[0229] Case 15.1: Both ‘A / a’ in the local executable instruction and ‘A / a’ in the remote executable instruction are files.

[0230] If the file ‘B / a’ does not exist in the remote folder, the to-be-executed target change operation includes: {operation: ‘moveRemote’, path:‘A / a’, newPath: ‘B / a’} (moving ‘A / a’ in the remote folder to ‘B / a’) and {operation: ‘download’, path:‘B / a’} (downloading the file ‘B / a’).

[0231] If the file ‘B / a’ exists in the remote folder, the to-be-executed target change operation includes: {operation: ‘add’, path:‘B / a’} (adding ‘B / a’) and {operation: ‘del’, path:‘A / a’} (deleting ‘A / a’).

[0232] Case 16: Each of the remote executable instructions includes an addition instruction {operation: ‘add’, path:‘A / a’} (adding ‘A / a’).

[0233] Case 16.1: Both ‘A / a’ in the local executable instruction and ‘A / a’ in the remote executable instruction are files.

[0234] In some embodiments, if ‘A / a’ in the local folder is equal to ‘A / a’ in the remote folder, the to-be-executed target change operation includes: {operation: ‘del’, path:‘A / a’} (deleting ‘A / a’), and the ‘B / a’ node of the synchronization tree is updated. Otherwise, the to-be-executed target change operation includes: {operation: ‘del’, path:‘A / a’} (deleting ‘A / a’) and {operation: ‘add’, path:‘B / a’} (adding ‘B / a’) for the local folder.

[0235] In some embodiments, {operation: ‘del’, path:‘A / a’} (deleting ‘A / a’) or {operation: ‘add’, path:‘B / a’} (adding ‘B / a’) for the local folder may be directly taken as the to-be-executed target change operation.

[0236] Case 16.2: Both ‘A / a’ in the local executable instruction and ‘A / a’ in the remote executable instruction are folders. The to-be-executed target change operation includes: {operation: ‘deleteRemoteFolder’, path:‘B / a’} (deleting the sub-folder ‘A / a’ in the remote folder) and {operation: ‘updateTree’, path:‘A / a’} (updating the ‘A / a’ node in the synchronization folder directory).

[0237] Case 16.3: One of ‘A / a’ in the local executable instruction and ‘A / a’ in the remote executable instruction is a folder, and the other is a file.

[0238] If ‘A / a’ in the local executable instruction is a file, the to-be-executed target change operation includes: {operation: ‘del’, path:‘A / a’} (deleting ‘A / a’) and {operation: ‘add’, path:‘B / a’} (adding ‘B / a’) for the local folder.

[0239] If ‘A / a’ in the remote executable instruction is a file, the to-be-executed target change operation includes: {operation: ‘moveRemote’, path:‘B / a’, newPath: ‘B / a_temp’} (moving ‘B / a’ to ‘B / a_temp’), {operation: ‘download’, path:‘B / a_temp’} (downloading ‘B / a_temp’), and {operation: ‘moveRemoteFolder’, path:‘A / a’, newPath: ‘B / a’} (moving ‘A / a’ to ‘B / a’), where {operation: ‘moveRemote’, path:‘B / a’, newPath: ‘B / a_temp’} and {operation: ‘download’, path:‘B / a_temp’} are inserted to precede all target change operations in which paths start with B / a / .

[0240] Case 17: Each of the remote executable instructions includes a movement instruction {operation: ‘move’, path:‘A / a’, newPath: ‘C / a’} for the file object ‘A / a’ (moving a in folder A to folder C).

[0241] Case 17.1: Both ‘A / a’ in the local executable instruction and ‘A / a’ in the remote executable instruction are files.

[0242] If the file ‘C / a’ does not exist in the local folder, the to-be-executed target change operation includes: {operation: ‘moveLocal’, path:‘B / a’, newPath: ‘C / a’} (moving ‘B / a’ in the local folder to ‘C / a’), where{operation: ‘moveLocal’, path:‘B / a’, newPath: ‘C / a’} needs to be inserted to precede all target change operations for folder B.

[0243] If the file ‘B / a’ exists in the remote folder, since the remote end performs a movement operation on ‘A / a’ to ‘C / a’, the local end also has corresponding operations for ‘A / a’ and ‘B / a’ exists on the remote end, to keep the local state consistent with the remote state, it is necessary to first delete local ‘A / a’, (i.e., {operation: ‘del’, path:‘A / a’}), and then add ‘B / a’ (i.e., {operation: ‘add’, path:‘B / a’}. Therefore, the to-be-executed target change operation includes: {operation: ‘del’, path:‘A / a’} (deleting ‘A / a’) and {operation: ‘add’, path:‘B / a’} (adding ‘B / a’).

[0244] Case 17.2: Both ‘A / a’ in the local executable instruction and ‘A / a’ in the remote executable instruction are folders.

[0245] If the folder ‘C / a’ does not exist in the local folder, when the directory level of ‘C / a’ in the remote folder is higher, the to-be-executed target change operation includes: {operation: ‘moveRemoteFolder’, path: ‘C / a’, newPath: ‘B / a’}. When the directory level of ‘B / a’ in the remote folder is higher, the to-be-executed target change operation includes: {operation: ‘moveRemoteFolder’, path: ‘B / a’, newPath: ‘C / a’}, where {operation: ‘moveRemoteFolder’, path: ‘C / a’, newPath: ‘B / a’} needs to be inserted to precede all target change operations for folder C, and {operation: ‘moveRemoteFolder’, path: ‘B / a’, newPath: ‘C / a’} needs to be inserted to precede all target change operations for folder B.

[0246] If the folder ‘C / a’ exists in the local folder, the to-be-executed target change operation includes: {operation: ‘del’, path:‘A / a’} (deleting ‘A / a’) and {operation: ‘add’, path:‘B / a’} (adding ‘B / a’).

[0247] Case 18: Each of the remote executable instructions includes a movement instruction {operation: ‘move’, path:‘A / a’, newPath: ‘B / a’} (moving a in folder A to folder B) for the file object ‘A / a’.

[0248] Case 18.1: Both ‘A / a’ in the local executable instruction and ‘A / a’ in the remote executable instruction are files. At this time, the to-be-executed target change operation includes: {operation: ‘updateTree’, ‘A / a’, ‘B / a’} (updating the ‘A / a’ node and the ‘B / a’ node in the synchronization tree).

[0249] Case 18.2: Both ‘A / a’ in the local executable instruction and ‘A / a’ in the remote executable instruction are folders. At this time, the to-be-executed target change operation includes: {operation: ‘updateTree’, ‘A / a’, ‘B / a’} (updating the ‘A / a’ node and the ‘B / a’ node in the synchronization tree).

[0250] Case 19: Each of the remote executable instructions includes a movement instruction {operation: ‘move’, path:‘C / a’, newPath: ‘B / a’} (moving a in folder C to folder B) for the file object ‘C / a’.

[0251] Case 19.1: Both ‘C / a’ in the local executable instruction and ‘C / a’ in the remote executable instruction are files.

[0252] Since the remote end performs a movement operation on ‘C / a’ to ‘B / a’, to keep the local state consistent with the remote state, for the remote folder, it is necessary to first delete ‘C / a’ (i.e., {operation: ‘del’, path:‘C / a’}), and then add ‘B / a’ (i.e., {operation: ‘add’, path:‘B / a’}). For the local folder, it is also necessary to first delete ‘C / a’ (i.e., {operation: ‘del’, path:‘C / a’}), and then add ‘B / a’ (i.e., {operation: ‘add’, path:‘B / a’}). Therefore, the to-be-executed target change operation includes: {operation: ‘del’, path:‘C / a’} (deleting ‘C / a’) and {operation: ‘add’, path:‘B / a’} (adding ‘B / a’) executed for the remote folder, as well as {operation: ‘del’, path:‘C / a’} (deleting ‘C / a’) and {operation: ‘add’, path:‘B / a’} (adding ‘B / a’) executed for the local folder.

[0253] Case 19.2: Both ‘C / a’ in the local executable instruction and ‘C / a’ in the remote executable instruction are folders.

[0254] At this time, the to-be-executed target change operation includes: {operation: ‘del’, path:‘C / a’} (deleting ‘C / a’) and {operation: ‘add’, path:‘B / a’} (adding ‘B / a’) executed for the remote folder, as well as {operation: ‘del’, path:‘C / a’} (deleting ‘C / a’) and {operation: ‘add’, path:‘B / a’} (adding ‘B / a’) executed for the local folder.

[0255] Case 19.3: One of ‘C / a’ in the local executable instruction and ‘C / a’ in the remote executable instruction is a folder, and the other is a file.

[0256] If ‘C / a’ in the local executable instruction is a file, the to-be-executed target change operation includes: {operation: ‘del’, path:‘C / a’} (deleting ‘C / a’) and {operation: ‘add’, path:‘B / a’} (adding ‘B / a’) executed for the local folder.

[0257] If ‘C / a’ in the remote executable instruction is a file, the to-be-executed target change operation includes: {operation: ‘del’, path:‘C / a’} (deleting ‘C / a’) and {operation: ‘add’, path:‘B / a’} (adding ‘B / a’) executed for the remote folder. Case 20: No operation is performed on the file object ‘A / a’in each of the remote executable instructions.

[0258] Case 20.1:‘A / a’ in the local executable instruction is a file.

[0259] If the file ‘B / a’ does not exist in the remote folder, the to-be-executed target change operation includes: {operation: ‘moveRemote’, path:‘A / a’, newPath: ‘B / a’} (moving a in sub-folder A to sub-folder B in the remote folder). If ‘A / a’ exists in the local folder directory, {operation: ‘moveRemote’, path:‘A / a’, newPath: ‘B / a’} needs to be inserted to precede all target change operations for ‘A / a’.

[0260] Case 20.2:‘A / a’ in the local executable instruction is a folder. At this time, the to-be-executed target change operation includes: {operation: ‘moveRemoteFolder’, path: ‘A / a’, newPath: ‘B / a’} (moving ‘A / a’in the remote folder to ‘B / a’).

[0261] In the instruction processing rule for two-way synchronization, if no operation is performed on the file object ‘A / a’ in each of the local executable instructions, the following cases exist according to the instruction types in the remote executable instructions and the file object to be operated:

[0262] Case 21: Each of the remote executable instructions includes an addition instruction {operation: ‘add’, path:‘A / a’} (adding ‘A / a’) for the file object ‘A / a’.

[0263] Case 21.1: Both ‘A / a’ in the local executable instruction and ‘A / a’ in the remote executable instruction are files. At this time, the to-be-executed target change operation includes: {operation: ‘download’, path:‘A / a’} (downloading the file ‘A / a’). In some embodiments, since folders with the same name may exist in the local folder directory, the client may first detect whether folders with the same name exist in the local folder directory. If such folders exist, the folders are renamed and uploaded, and this operation is inserted to precede all target change operations for file objects starting with ‘A / a’.

[0264] Case 21.2: Both ‘A / a’ in the local executable instruction and ‘A / a’ in the remote executable instruction are folders. At this time, the to-be-executed target change operation includes: {operation: ‘createLocalFolder’, path:‘A / a’} (creating a local folder ‘A / a’).

[0265] Case 22: Each of the remote executable instructions includes a modification instruction {operation: ‘mod’, path:‘A / a’} (modifying ‘A / a’) for the file object ‘A / a’.

[0266] Case 22.1: Both ‘A / a’ in the local executable instruction and ‘A / a’ in the remote executable instruction are files. At this time, the to-be-executed target change operation includes: {operation: ‘download’, path:‘A / a’} (downloading the file ‘A / a’).

[0267] Case 23: Each of the remote executable instructions includes a deletion instruction {operation: ‘del’, path:‘A / a’} (deleting ‘A / a’) for the file object ‘A / a’.

[0268] Case 23.1: Both ‘A / a’ in the local executable instruction and ‘A / a’ in the remote executable instruction are files. At this time, the to-be-executed target change operation includes: {operation: ‘delLocal’, path:‘A / a’} (deleting the local file ‘A / a’).

[0269] Case 23.2: Both ‘A / a’ in the local executable instruction and ‘A / a’ in the remote executable instruction are folders. At this time, the to-be-executed target change operation includes: {operation: ‘deleteLocalFolder’, path:‘A / a’} (deleting the local folder ‘A / a’).

[0270] Case 24: Each of the remote executable instructions includes a movement instruction {operation: ‘move’, path:‘A / a’, newPath: ‘B / a’} (moving the file object a) for the file object ‘A / a’.

[0271] Case 24.1: Both ‘A / a’ in the local executable instruction and ‘A / a’ in the remote executable instruction are files.

[0272] If the file object ‘B / a’ does not exist in the local directory, the to-be-executed target change operation includes: {operation: ‘moveLocal’, path:‘A / a’, newPath: ‘B / a’} (moving the file a). If the folder ‘A / a’ exists in the remote directory, {operation: ‘moveLocal’, path:‘A / a’, newPath: ‘B / a’} needs to be inserted to precede all target change operations for file objects starting with ‘A / a’.

[0273] If the file object ‘B / a’ exists in the local directory, the to-be-executed target change operation includes: {operation: ‘del’, path:‘A / a’} (deleting ‘A / a’) and {operation: ‘add’, path:‘B / a’} (adding ‘B / a’) executed for the remote folder.

[0274] Case 24.2: Both ‘A / a’ in the local executable instruction and ‘A / a’ in the remote executable instruction are folders. At this time, the to-be-executed target change operation includes: {operation: ‘moveLocalFolder’, path:‘A / a’, newPath: ‘B / a’} (moving the folder a).

[0275] In some embodiments, an execution conflict may exist between the local executable instructions and the remote executable instructions in the rule-based simulation process. To ensure the progress of rule-based simulation, in some embodiments, the client may perform conflict handling according to a target conflict handling manner selected by a target object from candidate conflict handling manners provided by the client, so as to meet different usage requirements of different objects and further improve the use experience of file synchronization.

[0276] Specifically, the client presents, if an execution conflict exists between the local executable instructions and the remote executable instructions in the rule-based simulation process, an operation interface including candidate conflict handling manners to a target object, obtains a selected target conflict handling manner in response to a selection operation of the target object for each of the candidate conflict handling manners, and performs, according to the target conflict handling manner, conflict handling on the local executable instructions and the remote executable instructions having the execution conflict therebetween.

[0277] The candidate conflict handling manners include, but are not limited to, uploading a local version as a new remote version, overwriting the local version with the remote version, and retaining all conflicting files.

[0278] When a conflict occurs between a local executable instruction and a remote executable instruction, the client may suspend rule-based simulation, record context at the time of the conflict, and resume, after a target conflict handling manner is selected by the target object, the rule-based simulation according to the target conflict handling manner. In this way, the target change operations may be obtained upon the rule-based simulation.

[0279] S204: Obtain an execution order of the target change operations based on respective operation types of the target change operations, and sequentially execute the target change operations according to the execution order, to complete the current file synchronization.

[0280] In some embodiments, the obtaining an execution order of the target change operations based on respective operation types of the target change operations includes: grouping the target change operations based on respective file execution paths corresponding to the target change operations in combination with preset asynchronous execution information, to obtain task groups, an intra-group execution order of at least one target change operation included in each task group, and an inter-group execution order of the task groups; and obtaining the execution order of the target change operations based on the inter-group execution order and the intra-group execution order corresponding to each of the task groups.

[0281] The asynchronous execution information is preset information, for indicating an execution manner of each of the target change operations. A local file uploading operation and a remote file downloading operation may be executed asynchronously, while other execution operations (a local file movement operation, a remote file movement operation, a local file deletion operation, and a remote file deletion operation) need to be executed synchronously. The target change operations are grouped by utilizing such information according to the similarity of file execution paths and the asynchronism of operations.

[0282] One task group is a set obtained by grouping the target change operations based on respective file execution paths corresponding to the target change operations in combination with preset asynchronous execution information. Each of the task groups includes at least one target change operation, the target change operation in each of the task groups has an intra-group execution order, and the task groups have an inter-group execution order therebetween.

[0283] The intra-group execution order refers to an execution order of at least one target change operation contained in one task group, and such order is determined according to the sequential logic of operations. For example, if a task group includes an addition operation and a modification operation, the addition operation is usually executed prior to the modification operation.

[0284] The inter-group execution order refers to an execution order of the task groups, and such order is determined according to a dependency relationship between the task groups. If an execution result of task group A is a prerequisite for the execution of task group B, task group A is executed prior to task group B.

[0285] In some embodiments, the target change operations are grouped based on respective file execution paths corresponding to the target change operations in combination with preset asynchronous execution information. The grouping method includes: checking, for each of the target change operations, a prefix of a file execution path thereof. If a plurality of target change operations have file execution paths sharing the same prefix and operation types complying with asynchronous execution rules (for example, the local file uploading operation and the remote file downloading operation may be executed asynchronously, while other execution operations need to be executed synchronously), such operations are classified into one task group. For each of the task groups, the intra-group execution order is determined according to the sequential logic of operations. For example, if the task group includes an addition operation and a modification operation, the addition operation is usually executed prior to the modification operation. The inter-group execution order is determined according to a dependency relationship between the task groups. If an execution result of task group A is a prerequisite for the execution of task group B, task group A is executed prior to task group B. Task groups, an intra-group execution order of at least one target change operation included in each task group, and an inter-group execution order of the task groups are obtained based on the foregoing grouping result. The execution order of the target change operations is obtained based on the inter-group execution order and the intra-group execution order corresponding to each of the task groups.

[0286] In some embodiments, in preset asynchronous execution information, a local file uploading operation and a remote file downloading operation may be executed asynchronously, while other execution operations (a local file movement operation, a remote file movement operation, a local file deletion operation, and a remote file deletion operation) need to be executed synchronously. Grouping is performed according to the similarity of file execution paths and the asynchronism of operations. If a plurality of target change operations have file execution paths sharing the same prefix and operation types complying with asynchronous execution rules, these operations are classified into one task group. For each of the task groups, an intra-group execution order is determined according to the sequential logic of operations, and an inter-group execution order is determined according to a dependency relationship between the task groups. For example, if the task group includes an addition operation and a modification operation, the addition operation is usually executed prior to the modification operation. An inter-group execution order is determined according to a dependency relationship between the task groups. If an execution result of task group A is a prerequisite for the execution of task group B, task group A is executed prior to task group B.

[0287] By way of example, in asynchronous execution information, a local file uploading operation and a remote file downloading operation may be executed asynchronously, while other execution operations (a local file movement operation, a remote file movement operation, a local file deletion operation, and a remote file deletion operation) need to be executed synchronously. Serial or concurrent execution of the target change operations in one task group is supported. Serial or concurrent execution between the task groups is supported.

[0288] By way of example, one task group may include a task group list, an operation list, a type, and a mode. The task group list or the operation list may be null. The type may be ForGroup or ForItem. The mode may be serial or parallel.

[0289] For example, FIG. 8 shows a schematic diagram of a task group according to some embodiments. 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. Task group 0 is a root node. The intra-group execution order of task group 1 is that: operation 1→operation 2→operation 3 are executed in series. The intra-group execution order of task group 3 is that: operation 4 and operation 5 are executed in parallel. The intra-group execution order of task group 4 is that: operation 6 and operation 7 are executed in parallel. The inter-group execution order of task group 1 to task group 4 is that: task group 1 and task group 2 are executed in parallel, and in task group 2, task group 3 is executed first, followed by task group 4. A data structure of one task group includes: a task group list, an operation list, a type, and a mode. The type is ForGroup or ForItem. The mode is serial or parallel.

[0290] In some embodiments, the sequentially executing, by the client, the target change operations according to the execution order to complete the current file synchronization includes:

[0291] executing, by the client for each of the task groups according to the inter-group execution order, the following operations:

[0292] sequentially executing, based on an intra-group execution order of at least one target change operation in one task group, the at least one target change operation; and

[0293] updating the synchronization directory at the end of execution of the at least one target change operation.

[0294] For example, with reference to FIG. 9, task groups are stored in a task group queue. The client may execute task group 1 and task group 2 in parallel by using task group parallel resources according to the inter-group execution order and a maximum parallel number of the task group parallel resources. 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 task group serial resources, the client converts operation 1, operation 2, and operation 3 into corresponding instructions in sequence based on the intra-group execution order of task group 2, then executes the corresponding instructions to obtain an execution result of task group 1, and updates, after the execution result indicates that all operations are successfully completed, the synchronization folder directory. The instructions include, but are not limited to, downloading, uploading, local movement, remote movement, local addition, and local deletion. Similarly, when executing task group 3 in parallel, the client converts operation 4 and operation 5 in sequence based on the intra-group execution order of task group 3, then executes corresponding instructions to obtain an execution result of task group 3, and updates, after the execution result indicates that all operations are successfully completed, the synchronization folder directory. After all operations in task group 3 are successfully executed, the client executes task group 4.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. After task group 3 and task group 4 are successfully executed, it is determined that task group 2 is successfully executed. After task group 1 and task group 2 are successfully executed, it is determined that the execution is successful. To be specific, file synchronization is completed. In the execution process, if an execution failure occurs, the current file synchronization may be suspended, and subsequent processing may be performed according to an instruction of a target object, such as re-performing file synchronization.

[0295] In some embodiments, when each task group is completely and successfully executed, the client synchronizes operations of an execution unit to the synchronization folder directory recorded in the client, so that the synchronization folder directory always maintains consistency between the remote end and the local end at the synchronization moment. After all task groups are successfully executed, the current synchronization task is completed, and information of synchronization success or synchronization failure is outputted. If information of synchronization failure is generated, detailed information of failed execution operations may further be outputted for a user to confirm the cause of the failure. Further, a next file synchronization is triggered when a change of the remote folder or the local folder is detected next time or when the target object manually triggers the next file synchronization.

[0296] In some embodiments, the client may further execute the target change operations based on the operation types corresponding to the target change operations in combination with an instruction execution manner set for an operation type of an unsafe operation.

[0297] The unsafe operation refers to an operation with risks that may be performed on files or folders in either the remote folder or the local folder. Potential unsafe operations include one or more of the following: deleting a sub-folder containing files or sub-folders, adding a file with a non-existent parent folder path, adding an existing sub-folder, moving a file in a case that a file with the same name has existed in a path after movement, and moving a sub-folder in a case that a sub-folder with the same name has existed in a path after movement.

[0298] By way of example, when the client executes one target change operation, if the target change operation is a deletion operation, a file object to be deleted by the deletion operation is a sub-folder in the remote folder or the local folder, and the sub-folder still contains files or sub-folders, the client does not execute the deletion operation, and the deletion operation is directly regarded as successfully executed. If the target change operation is an addition operation for a sub-folder and the folder (remote folder or local folder) for executing the sub-folder addition operation already contains the sub-folder, the client does not execute the addition operation, and the addition operation is directly regarded as successfully executed. If the target change operation is an addition operation for adding a file in a target sub-folder and the folder (remote folder or local folder) for performing file addition does not contain the sub-folder, the client executes a creation operation (creating the sub-folder and adding the file in the sub-folder), and the addition operation is regarded as successfully executed. If the target change operation is a movement operation for a file and duplicate names exist in the target sub-folder (for example, moving file b in sub-folder B to sub-folder b in sub-folder B), the client first executes a renaming operation and then executes the movement operation, and the current operation is regarded as successfully executed.

[0299] In some embodiments, the client may update the locally recorded synchronization folder directory after one target change operation is successfully executed, so as to ensure real-time consistency between the remote end and the local end upon operation success.

[0300] In some embodiments, the client may store the local folder directory, the remote folder directory, and the synchronization folder directory by caching. Specifically, the client takes a locally currently cached local folder directory of the local folder as the local directory of the local folder at the synchronization moment. The locally cached local folder directory is updated when the local folder changes. The client takes a locally currently cached remote folder directory of the remote folder as the remote directory of the remote folder at the synchronization moment. The locally cached remote folder directory is updated when the remote folder changes. The client takes a locally cached synchronization folder directory of the local folder and the remote folder in the synchronized state at the end of the previous file synchronization as the synchronization directory.

[0301] A data caching mechanism can improve data access speed and system response performance, and reduce resource load pressure, thereby improving file synchronization efficiency.

[0302] Further, the client obtains, if a synchronization exception occurs in a current file synchronization process, a cached local folder directory of the local folder at a current moment and a remote folder directory of the remote folder at the current moment after exception recovery, and re-performs the current file synchronization on the local folder and the remote folder based on the local folder directory at the current moment, the remote folder directory at the current moment, and the synchronization directory.

[0303] The current file synchronization on the local folder and the remote folder is re-performed based on the local folder directory at the current moment, the remote folder directory at the current moment, and the synchronization directory according to the following operations: obtaining, based on the local directory, the remote directory, and the synchronization directory, both a local change operation set occurring in the local folder and a remote change operation set occurring in the remote folder from the end of the previous file synchronization to the current moment (refer to S202 for details); next, performing difference analysis on the local change operation set and the remote change operation set, and planning, based on an analysis result, to-be-executed target change operations in the current file synchronization (refer to S203 for details); and finally, obtaining an execution order of the target change operations based on respective operation types of the target change operations, and sequentially executing the target change operations according to the execution order, to complete the current file synchronization (refer to S204 for details).

[0304] Through the foregoing implementations, when synchronization interruption is caused by a synchronization exception, the client may quickly obtain the remote folder directory, the local folder directory, and the synchronization directory by caching. Compared with obtaining data from a database, the data obtaining speed can be increased, and the file synchronization efficiency is further improved.

[0305] FIG. 10 shows a schematic diagram of a file synchronization process according to some embodiments. The client includes: a scanning structure, a data model, a synchronization planning model, and a synchronization execution structure.

[0306] The scanning structure is configured to: periodically detect a local folder, obtain a local folder directory at a current detection moment, and update a local folder directory cache in the data model with the local folder directory at the current detection moment; and periodically detect a remote folder, construct a remote folder directory at the current detection moment, and update a remote folder directory cache in the data model with the remote folder directory at the current detection moment. Refer to the construction process of the remote folder directory and the local folder directory in S201 for details.

[0307] The data model is configured to cache the remote folder directory, the local folder directory, and a synchronization folder directory cache.

[0308] When the scanning structure detects that the remote folder directory and the local folder directory remain stable within a period of time and a change operation occurs in the remote or local folder, it is determined that the current file synchronization is performed. At this time, the execution of the current file synchronization is triggered at a moment that is defined as a synchronization moment of the current file synchronization.

[0309] In the local file synchronization process, the synchronization planning model is configured to obtain, by using the data model, a local directory and a remote directory at the synchronization moment, and a synchronization directory after the previous file synchronization.

[0310] The synchronization planning model includes two processing operations. The first operation is to obtain a change operation list of the local end and the remote end from the previous successful synchronization moment to the current moment. To be specific, based on the local directory, the remote directory, and the synchronization directory, both a local change operation set occurring in the local folder and a remote change operation set occurring in the remote folder are obtained from the end of the previous file synchronization to the synchronization moment, referring to S202 for details. The second operation is to plan an operation instruction list required to achieve structural consistency between the local end and the remote end. To be specific, difference analysis is performed on the local change operation set and the remote change operation set, and to-be-executed target change operations in the current file synchronization are planned based on an analysis result, referring to S203 for details. Conflict detection may further be performed during the planning of the target change operations. For the conflict detection process, refer to the foregoing rule-based simulation process.

[0311] The synchronization execution structure performs task grouping using the target change operations outputted by the synchronization planning model according to an asynchronous state and an execution path, and executes task groups and the target change operations in each of the task groups respectively according to an inter-group execution order and an intra-group execution order, so as to realize synchronization operations of the local folder and the remote folder, referring to S204 for details.

[0312] After all task groups are completely and successfully executed, the synchronization execution structure generates a synchronization folder directory of the current file synchronization, and updates the synchronization folder directory cache in the data model based on the synchronization folder directory of the current file synchronization. If the execution fails, the current file synchronization is suspended until a synchronization task is restarted.

[0313] In some embodiments, in response to a synchronization disk creation operation triggered by a target object, the client presents various candidate synchronization creation manners on an operation interface, and then obtains a target synchronization creation manner in response to a selection operation triggered by the target object for each of the candidate synchronization creation manners.

[0314] The candidate synchronization creation manners include, but are not limited to, synchronizing the local folder and synchronizing the remote folder. Synchronizing the local folder refers to creating synchronization based on existing local files, and synchronizing the remote folder refers to creating synchronization based on existing remote files.

[0315] In some embodiments, there is no limitation on an operation triggering manner, which may include but is not limited to touch, click / tap, and voice control.

[0316] FIG. 11 shows a schematic diagram of an operation interface of synchronization disk creation according to some embodiments. The operation interface includes a “Create Synchronization” button. When a target object clicks / taps the “Create Synchronization” button, a “Synchronize Local Folder” button and a “Synchronize Remote Folder” button are presented on the operation interface. The “Synchronize Local Folder” button represents local file synchronization, and the “Synchronize Remote Folder” button represents remote folder synchronization. When the target object clicks / taps the “Synchronize Local Folder” button, the client takes local folder synchronization as a target synchronization manner in response to a trigger operation of the target object for the “Synchronize Local Folder” button. When the target object clicks / taps the “Synchronize Remote Folder” button, the client takes remote folder synchronization as a target synchronization manner in response to a trigger operation of the target object for the “Synchronize Remote Folder” button. Also, the target object may click / tap a middle button on the operation interface to start synchronization creation, or directly drag a local folder to the page to quickly create synchronization when local folder synchronization may be needed.

[0317] In some embodiments, after the target object selects a synchronization creation manner, synchronization information configuration may be further performed. Specifically, the client presents a configuration interface, and obtains at least one piece of synchronization configuration information configured by the target object in response to a configuration operation triggered by the target object on the configuration interface.

[0318] The configuration interface may be an interface for configuration based on a target synchronization creation manner. The synchronization configuration information includes, but is not limited to, one or more of the following: a local folder path, a remote folder path, a synchronization type, and a conflict handling manner.

[0319] Taking local folder synchronization as an example, with reference to FIG. 12, after the target object clicks / taps the “Synchronize Local Folder” button, the client presents a configuration interface corresponding to local folder synchronization. The configuration interface includes configuration components for configuring the local folder path, the remote folder path, the synchronization type, and the conflict handling manner. The target object may select a local folder path through the configuration component for the local folder path, select a remote folder path through the configuration component for the remote folder path, select two-way synchronization or remote backup through the configuration component for the synchronization type, and configure a conflict handling manner through the configuration component for the conflict handling manner.

[0320] When the target object clicks / taps an “Advanced Settings” button, the client presents an operation interface shown in FIG. 13. The operation interface includes candidate conflict handling manners corresponding to synchronization types selected by the target object. Candidate conflict handling manners corresponding to two-way synchronization include: Always Ask Me, Upload a local version as a new remote version, Overwrite a local version with a remote version, and Retain all conflict files. A default handling manner when a current synchronization conflict occurs (for example, both remote files and local files are changed in a synchronization interval) is determined. When Always Ask Me is selected and a conflict occurs, the target object may view conflict details for individual files and perform manual handling.

[0321] After the target object clicks / taps “Synchronization Manner”, the client presents an operation interface shown in FIG. 14. The operation interface configures a synchronization manner. The synchronization manner includes automatic synchronization and manual synchronization. The manual synchronization is performed only after a user clicks / taps the synchronization button. The automatic synchronization means that local and remote folder states are detected automatically, and updates are performed promptly upon any change.

[0322] In some embodiments, when a synchronization conflict occurs and the target conflict handling manner is set to always asking an object, the client presents notification information on the operation interface to allow the target object to handle the conflict manually. To be specific, one candidate synchronization conflict handling manner is selected from three candidate synchronization conflict handling manners: uploading a local version as a new remote version, overwriting a local version with a remote version, and retaining all conflicting files, as a final synchronization conflict handling manner. The notification information may be implemented in forms including, but not limited to, a system desktop pop-up window and an in-client pop-up window.

[0323] FIG. 15A shows a schematic diagram of notification information according to some embodiments. If the target object selects Always Ask Me, an operating system will push a pop-up window notification. The notification information indicates that a folder conflict exists and may be required to be handled promptly, to notify the target object to handle the conflict manually. When the target object clicks / taps the pop-up window, the client may present an operation interface shown in FIG. 16. The operation interface shown in FIG. 16 includes: components corresponding to three candidate synchronization conflict handling manners: uploading a local version as a new remote version, overwriting a local version with a remote version, and retaining all conflicting files, namely three buttons: “Overwrite Local”, “Overwrite Remote”, and “Retain All”. The target object selects a target synchronization conflict handling manner by selecting the component of the corresponding candidate conflict handling manner.

[0324] FIG. 15B shows a schematic diagram of another notification information according to some embodiments. The operation interface is provided with a component prompting “Conflict in folder, please handle promptly”. When the target object clicks / taps the component, the client presents an operation window shown in FIG. 16 for the target object to select a target synchronization conflict handling manner.

[0325] In some embodiments, the client may further present synchronization information in response to an information viewing operation triggered by the target object. The synchronization information includes, but is not limited to, one or more of a synchronization list and a synchronization exception. The synchronization list is configured for viewing a synchronized state of file objects in historical file synchronization. The synchronization exception is configured for viewing file objects that fail to be synchronized in the file synchronization process.

[0326] FIG. 17 shows a schematic diagram of an operation interface of viewing synchronization information according to some embodiments. The client may present a synchronization list and a synchronization exception on the operation interface. Since a plurality of synchronization tasks may exist simultaneously (for example, file synchronization performed for a plurality of local folders), the operation interface may present respective synchronization lists corresponding to the plurality of synchronization tasks. For example, synchronization list 1 is a synchronization list of a synchronization task corresponding to a local folder sync. The synchronization list contains a file name of file 1 to be synchronized, and file 1 is in a successful synchronization state.

[0327] Based on the same inventive concept, embodiments of this application provide a file synchronization apparatus. FIG. 18 shows a schematic structural diagram of a file synchronization apparatus 1800. The apparatus may include:

[0328] a data obtaining unit 1801, configured to obtain, when file synchronization is performed for a local folder and a remote folder, a local directory of the local folder at a synchronization moment, a remote directory of the remote folder at the synchronization moment, and a synchronization directory of the local folder and the remote folder in a synchronized state at the end of the previous file synchronization;

[0329] a directory analysis unit 1802, configured to obtain, based on the local directory, the remote directory, and the synchronization directory, both a local change operation set occurring in the local folder and a remote change operation set occurring in the remote folder from the end of the previous file synchronization to the synchronization moment;

[0330] a difference analysis unit 1803, configured to perform difference analysis on the local change operation set and the remote change operation set, and plan, based on an analysis result, to-be-executed target change operations in the current file synchronization; and

[0331] an operation execution unit 1804, configured to obtain an execution order of the target change operations based on respective operation types of the target change operations, and sequentially execute the target change operations according to the execution order, to complete the current file synchronization.

[0332] In some embodiments, the directory analysis unit 1802 is configured to: sequentially execute, based on a directory structure of the local directory, the following operations on local file objects in the local directory:

[0333] comparing respective directory locations of synchronized file objects in the synchronization directory with a directory location of one local file object among the local file objects;

[0334] determining, based on a comparison result, a reference change operation corresponding to the local file object; and

[0335] obtaining, based on the reference change operation corresponding to each of the local file objects, the local change operation set occurring in the local folder from the end of the previous file synchronization to the synchronization moment.

[0336] In some embodiments, when determining, based on a comparison result, a reference change operation corresponding to the local file object, the directory analysis unit 1802 is configured to:

[0337] determine, if the comparison result indicates the presence of one synchronized file object having the same directory location as the local file object, the reference change operation corresponding to the local file object based on object types of the local file object and the synchronized file object; and

[0338] determine, if the comparison result indicates the absence of one synchronized file object having the same directory location as the local file object, the reference change operation corresponding to the local file object based on a file identifier of each of the synchronized file objects.

[0339] In some embodiments, when obtaining a local directory of the local folder at a synchronization moment, a remote directory of the remote folder at the synchronization moment, and a synchronization directory of the local folder and the remote folder in a synchronized state at the end of the previous file synchronization, the data obtaining unit 1801 is configured to:

[0340] take a locally currently cached local folder directory of the local folder as the local directory of the local folder at the synchronization moment, the locally cached local folder directory being updated when the local folder changes;

[0341] take a locally currently cached remote folder directory of the remote folder as the remote directory of the remote folder at the synchronization moment, the locally cached remote folder directory being updated when the remote folder changes; and

[0342] take a locally cached synchronization folder directory of the local folder and the remote folder in the synchronized state at the end of the previous file synchronization as the synchronization directory.

[0343] In some embodiments, the operation execution unit 1804 is further configured to:

[0344] obtain, if a synchronization exception occurs in a current file synchronization process, a cached local folder directory of the local folder at a current moment and a remote folder directory of the remote folder at the current moment after exception recovery; and

[0345] re-perform the current file synchronization on the local folder and the remote folder based on the local folder directory at the current moment, the remote folder directory at the current moment, and the synchronization directory.

[0346] In some embodiments, the data obtaining unit 1801 is configured to execute at least one of the following operations:

[0347] obtaining, by using a remote server, historical operation data of the remote folder, the historical operation data including operation data from the end of the previous file synchronization to the synchronization moment, and obtaining, based on the historical operation data, the remote directory in combination with the remote folder directory at the end of the previous file synchronization; or

[0348] obtaining, according to a set detection period, a changed file object set in the remote folder, and updating the locally recorded remote folder directory based on the changed file object set, to obtain the remote directory.

[0349] In some embodiments, when obtaining, according to a set detection period, a changed file object set in the remote folder, the data obtaining unit 1801 is configured to:

[0350] transmit a detection request to the remote server according to the set detection period, the detection request carrying local state information, recorded in a client, of file objects in the remote folder at the current moment, and each piece of local state information being configured for representing whether a target processing operation occurs to a corresponding file object; and

[0351] receive the changed file object set returned by the remote server, the file object set being determined by the remote server based on remote state information, recorded in the remote server, of each of the file objects in the remote folder at the current moment, in combination with the corresponding local state information.

[0352] In some embodiments, when updating the locally recorded remote folder directory based on the changed file object set, to obtain the remote directory, the data obtaining unit 1801 is configured to:

[0353] pull, if the file object set includes at least one file, the at least one file by using the remote server, and update the locally recorded remote folder directory based on the at least one file, to obtain the remote directory; and

[0354] pull, if the file object set includes at least one folder, files in the at least one folder by using the remote server, and update the locally recorded remote folder directory based on the files, to obtain the remote directory.

[0355] In some embodiments, if a value of each piece of remote state information increases when the target processing operation occurs to a corresponding file object, the changed file object is a file object for which the value of the remote state information exceeds a value of the local state information.

[0356] In some embodiments, when performing difference analysis on the local change operation set and the remote change operation set, and planning, based on an analysis result, to-be-executed target change operations in the current file synchronization, the difference analysis unit 1803 is configured to:

[0357] obtain, based on a set instruction generation manner, respective local executable instructions corresponding to local change operations in the local change operation set; obtain, based on the instruction generation manner, respective remote executable instructions corresponding to remote change operations in the remote change operation set; and

[0358] perform, based on the set instruction execution manner, rule-based simulation on each of the obtained local executable instructions and remote executable instructions, and obtain, based on a simulation result, the to-be-executed target change operations in the current file synchronization.

[0359] In some embodiments, the difference analysis unit 1803 is further configured to:

[0360] present, if an execution conflict exists between the local executable instructions and the remote executable instructions in the rule-based simulation process, an operation interface including candidate conflict handling manners to a target object; and

[0361] obtain a selected target conflict handling manner in response to a selection operation of the target object for each of the candidate conflict handling manners, and perform, according to the target conflict handling manner, conflict handling on the local executable instructions and the remote executable instructions having the execution conflict therebetween.

[0362] In some embodiments, when obtaining an execution order of the target change operations based on respective operation types of the target change operations, the operation execution unit 1804 is configured to:

[0363] group the target change operations based on respective file execution paths corresponding to the target change operations in combination with preset asynchronous execution information, to obtain task groups, an intra-group execution order of at least one target change operation included in each task group, and an inter-group execution order of the task groups; and

[0364] obtain the execution order of the target change operations based on the inter-group execution order and the intra-group execution order corresponding to each of the task groups.

[0365] In some embodiments, when sequentially executing the target change operations according to the execution order, the operation execution unit 1804 is configured to:

[0366] execute, for each of the task groups according to the inter-group execution order, the following operations:

[0367] sequentially executing, based on an intra-group execution order of at least one target change operation in one task group, the at least one target change operation; and

[0368] updating the synchronization directory at the end of execution of the at least one target change operation.

[0369] For ease of description, the foregoing parts fall into modules (or units) based on functions for separate description. Certainly, when this application is implemented, functions of the modules (or units) may be implemented in one or more pieces of software or hardware.

[0370] Specific request execution manners of the units in the apparatus in the foregoing embodiment have been described in detail in the embodiment about the method, and details are not described herein.

[0371] A person skilled in the art may understand that the aspects of this application may be implemented as systems, methods, or program products. Thus, various aspects of this application may be implemented in the following forms, i.e. full hardware implementations, full software implementations (including firmware, microcodes, etc.), or hardware and software combined implementations, which can be collectively referred to as a “circuit”, a “module”, or a “system” herein.

[0372] Based on the same inventive concept, embodiments of this application further provide an electronic device. In an embodiment, the electronic device may be a server, or may be a terminal device. FIG. 19 shows a possible schematic structural diagram of an electronic device according to some embodiments. In FIG. 19, an electronic device 1900 includes a processor 1910 and a memory 1920.

[0373] The memory 1920 stores a computer program that may be executed by the processor 1910. The processor 1910 may perform operations of the foregoing file synchronization method by executing instructions stored in the memory 1920.

[0374] The memory 1920 may be a volatile memory such as a random-access memory (RAM). The memory 1920 may be 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). The memory 1920 is any other medium that can be configured to carry or store expected program code in a form of an instruction or a data structure and that can be accessed by a computer, but is not limited thereto. The memory 1920 may be a combination of the foregoing memories.

[0375] The processor 1910 may include one or more central processing units (CPUs) or be a digital processing unit, or the like. The processor 1910 is configured to implement the foregoing file synchronization method when executing the computer program stored in the memory 1920.

[0376] In some embodiments, the processor 1910 and the memory 1920 may be implemented on the same chip. In some embodiments, the processor and the memory may be implemented separately on independent chips.

[0377] A connection medium between the processor 1910 and the memory 1920 is not limited in some embodiments. In some embodiments, an example in which the processor 1910 is connected to the memory 1920 by a bus is used, and the bus is described with a thick line in FIG. 19. Connection manners between other components are only for schematic illustration and are not used for a limitation. The bus may include an address bus, a data bus, a control bus, or the like. For ease of description, the bus is only described by a thick line in FIG. 19, but only a bus or a type of bus is not described.

[0378] Based on the same inventive concept, embodiments of this application provide a computer-readable storage medium, including a computer program, and when the computer program is executed on an electronic device, the computer program is configured for causing the electronic device to perform operations of the foregoing file synchronization method. In some possible implementations, the aspects of the file synchronization method provided in this application may be implemented in the form of a program product, including a computer program. When the program product is executed on the electronic device, the computer program is configured to cause the electronic device to perform operations in the foregoing file synchronization method. For example, the electronic device may perform the operations shown in FIG. 2.

[0379] The program product may use one or any combination of more of readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example but not limited to, an electric, magnetic, optical, electromagnetic, infrared, or semi-conductive system, apparatus, or device, or any combination thereof. More examples (a non-exhaustive list) of the readable storage medium include an electrical connection having one or more wires, a portable disk, a hard disk, a RAM, a ROM, an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof.

[0380] The program product according to implementations of this application may use a CD-ROM and include a computer program, and may be executed on an electronic device. However, the program product of this application is not limited thereto. Herein, the readable storage medium may be any tangible medium containing or storing a computer program, and the computer program may be used by or in combination with a command execution system, apparatus, or device.

[0381] The readable signal medium may include a data signal being in a baseband or transmitted as a part of a carrier, which carries the readable computer program. The data signal propagated in such a way may be in a plurality of forms, including but not limited to, an electromagnetic signal, an optical signal, or any appropriate combination thereof. The readable signal medium may be any readable medium other than the readable storage medium. The readable medium may transmit, propagate, or transfer a computer program used by or in combination with a command execution system, apparatus, or device.

[0382] In summary, this application provides a file synchronization method and apparatus, a device, a computer-readable storage medium, and a computer program product. An electronic device obtains, when file synchronization is performed for a local folder and a remote folder, a local directory of the local folder at a synchronization moment, a remote directory of the remote folder at the synchronization moment, and a synchronization directory of the local folder and the remote folder in a synchronized state at the end of the previous file synchronization. By comparing the directories at the three different moments, the electronic device can accurately locate changes occurring in the local folder and the remote folder from the end of the previous synchronization to the current synchronization moment. Such a manner based on multi-directory comparison avoids redundant operations on unchanged files that may occur in conventional methods. For example, conventional methods may perform full synchronization on an entire folder regardless of whether files therein are actually changed. This wastes substantial system resources and network bandwidth. In contrast, by accurately comparing directories, the method disclosed herein only performs synchronization operations on changed files, thereby greatly improving resource utilization. Change operation sets of the local and remote folders are obtained based on the directories respectively, difference analysis is performed on the change operation sets, target change operations are planned, and the target change operations are finally executed in an execution order to complete synchronization. Such targeted synchronization operations make the file synchronization process more efficient, and reduce unnecessary operations, thereby improving the accuracy and efficiency of file synchronization.

[0383] Further, based on a directory structure of the local directory, the electronic device sequentially operates local file objects in the local directory, compares directory locations of synchronized file objects in the synchronization directory with directory locations of the local file objects, determines a reference change operation based on a comparison result, and further obtains a local change operation set. Such a manner based on directory location comparison can meticulously analyze the change condition of each file object in the local folder. In a file management system, the location and state of a file are critical information. By accurately comparing the directory locations, the electronic device may accurately determine whether a file is added, deleted, moved, or modified. For example, when the directory location of a file changes, the electronic device may quickly identify the change as a movement operation, instead of simply regarding the change as an addition or deletion operation. Such meticulous analysis enables more accurate determination of the local change operation set, provides a more reliable basis for subsequent synchronization operations, further improves the precision of file synchronization, reduces synchronization errors caused by misjudgment, and enhances system stability.

[0384] When determining the reference change operation, if the comparison result indicates the presence of one synchronized file object having the same directory location as one local file object, the electronic device determines the reference change operation based on object types of the two file objects. Different types of file objects (e.g., files and folders) have different attributes and operation manners in a file system. For example, a folder may contain sub-folders and files, and operations on the folder may affect all internal files. A file is a data carrier, and operations on the file mainly involve content modification, deletion, and the like. Differentiated processing according to object types can more accurately determine the change condition of file objects. For a folder, the electronic device may further check changes of internal files. For a file, the electronic device may directly compare differences in content or metadata. Such a targeted determining strategy avoids misjudgment, and improves the accuracy of reference change operation determination, thereby promoting the quality of file synchronization, and ensuring that synchronization operations of files and folders meet actual demands.

[0385] Further, if the comparison result indicates the absence of one synchronized file object having the same directory location as one local file object, the electronic device determines the reference change operation based on a file identifier of each of the synchronized file objects. The file identifier is a unique identifier of a file, and may be a hash value, a file name, or the like of the file. Determining the reference change operation through the file identifier can accurately identify the change condition of file objects even when directory locations are different. For example, when a file is moved to another directory, a directory location thereof changes while a file identifier remains unchanged, and the electronic device may identify the change as a movement operation through the file identifier. Such a method expands the scope of reference change operation determination, guarantees the integrity of the local change operation set, facilitates comprehensive file synchronization, and prevents file loss or repeated synchronization caused by directory location changes.

[0386] When obtaining directories, the electronic device takes a locally currently cached local folder directory of the local folder as the local directory, takes a locally currently cached remote folder directory of the remote folder as the remote directory, and takes a locally cached synchronization folder directory of the local folder and the remote folder in the synchronized state at the end of the previous file synchronization as the synchronization directory. Caching is a high-speed data storage manner, which stores frequently used data in an internal memory for quick access. Storing directory information by caching can significantly increase data access speed. During file synchronization, frequent obtaining of directory information from a disk or a network consumes substantial time, while such information may be quickly loaded into the internal memory by caching, thereby reducing time overheads for data obtaining. Meanwhile, caching also reduces the load pressure on system resources by decreasing frequent access to the disk and the network. For example, in a high-concurrency file synchronization scenario where a large quantity of users execute file synchronization operations simultaneously, obtaining directory information from the disk or the network each time will degrade system performance. Caching can effectively relieve such pressure and improve file synchronization efficiency.

[0387] If a synchronization exception occurs in a current file synchronization process, the electronic device obtains a cached local folder directory of the local folder at a current moment and a remote folder directory of the remote folder at the current moment after exception recovery, and re-performs the current file synchronization on the local folder and the remote folder based on these directories. The caching mechanism enables quick obtaining of required directory information after synchronization exception recovery, and avoids cumbersome data obtaining processes from other storage manners such as a database. Database read and write operations usually involve complex query and transaction processing. This consumes substantial time and system resources. Cached data may be directly accessed, to greatly improve data obtaining speed. In addition, the cached data is recently used data with high timeliness. This ensures that the latest directory information is adopted for re-synchronization. Such capability of quick recovery and re-synchronization reduces the impact of the synchronization exception on the overall synchronization process, and improves the reliability and stability of file synchronization.

[0388] The electronic device may obtain, by using a remote server, historical operation data of the remote folder, obtain, based on the historical operation data, the remote directory in combination with the remote folder directory at the end of the previous file synchronization, obtain, according to a set detection period, a changed file object set in the remote folder, and update the locally recorded remote folder directory based on the file object set, to obtain the remote directory. Two manners for obtaining the remote directory are provided to select a proper method according to different scenarios and demands. In some cases, the historical operation data may be complete and accurate, and the latest remote directory may be quickly constructed in this manner. In other cases, obtaining the changed file object set according to the detection period can discover changes of the remote folder promptly and ensure the real-time performance of the remote directory. Such flexibility enhances system adaptability and facilitates efficient obtaining of remote directory information. For example, in a scenario where the remote folder changes frequently, the detection period manner may capture such changes promptly and prevent synchronization errors caused by delayed information update. In a scenario where the remote folder changes infrequently, the historical operation data manner can reduce unnecessary network requests and improve efficiency.

[0389] When obtaining the changed file object set in the remote folder according to the set detection period, the electronic device transmits a detection request to the remote server according to the set detection period, where the detection request carries local state information, recorded in the electronic device, of file objects in the remote folder at the current moment. The electronic device receives the changed file object set returned by the remote server, where the file object set is determined by the remote server based on remote state information, recorded in the remote server, of each of the file objects in the remote folder at the current moment, in combination with the corresponding local state information. Changes of file objects in the remote folder can be discovered promptly by comparing the local state information with the remote state information to determine the changed file object set. The state information may include modification time, a size, a hash value, and the like of a file. By comparing such information, the electronic device may accurately determine whether the file has changed. Such a manner provides accurate information for subsequent remote directory update, and improves the timeliness and accuracy of remote directory update. For example, when the modification time of a file changes, the electronic device may quickly identify that the file is modified, and update the locally recorded remote directory promptly, so as to promote file synchronization efficiency and ensure that the states of the local and remote folders are always consistent.

[0390] When updating the locally recorded remote folder directory based on the changed file object set, to obtain the remote directory, if the file object set includes at least one file, the electronic device pulls the file by using the remote server and updates the directory. If at least one folder is included, the electronic device pulls all files in the folder and updates the directory. Adopting different processing manners according to different types of file object sets can update the remote directory in a targeted manner. Files and folders have different structures and operation manners in the file system, and separate processing of files and folders can improve update efficiency and accuracy. For files, direct pulling and updating can guarantee file content consistency. For folders, pulling all internal files and updating can ensure folder integrity. Such targeted processing ensures the accuracy and integrity of the remote directory, provides a reliable foundation for file synchronization, improves file synchronization efficiency, and prevents file loss or synchronization errors caused by improper processing.

[0391] If a value of each piece of remote state information increases when the target processing operation occurs to a corresponding file object, the changed file object is a file object for which the value of the remote state information exceeds a value of the local state information. Comparing values of state information to determine changed file objects provides a simple and effective determining method. The increase in the value of state information can directly reflect changes of a file object. The electronic device may quickly screen out the changed file object only by comparing the values of the local state information and the remote state information. Such a method avoids complex comparison of file content and greatly improves the efficiency of determining the changed file object. For example, in a large-scale file synchronization scenario with a large number of files, comparing the content of each file consumes substantial time and system resources. The method of comparing state information values can quickly locate changed files, reduce unnecessary operations, and further improve file synchronization efficiency.

[0392] When performing difference analysis on the local change operation set and the remote change operation set and planning target change operations, the electronic device obtains executable instructions corresponding to the local and remote change operations based on a set instruction generation manner, performs rule-based simulation on the executable instructions based on the set instruction execution manner, and obtains the target change operations based on a simulation result. Local and remote change operations can be systematically analyzed and planned through instruction generation and rule-based simulation. The instruction generation can convert change operations into computer-executable instructions to standardize operations. The rule-based simulation can simulate an instruction execution process, discover potential problems and conflicts in advance, and make corresponding adjustments. Such systematic analysis and planning ensure the propriety and effectiveness of the target change operations, and improve the accuracy and efficiency of file synchronization. For example, in the rule-based simulation process, conflicts between local and remote instructions may be discovered, and such conflicts can be handled by adjusting an instruction execution order or adopting other measures, so as to avoid errors during actual execution and ensure smooth file synchronization.

[0393] If an execution conflict exists between the local executable instructions and the remote executable instructions in the rule-based simulation process, the electronic device presents an operation interface including candidate conflict handling manners to a target object, obtains a selected target conflict handling manner in response to a selection operation of the target object for each of the candidate conflict handling manners, and performs, according to the target conflict handling manner, handling on the instructions having the execution conflict therebetween. A plurality of candidate conflict handling manners are provided for selection by the target object, so as to meet demands of different users. Different users may have different requirements and preferences for file synchronization. For example, some users tend to retain local versions, while other users prefer to use remote versions. Providing a plurality of conflict handling manners allows users to make selections according to own demands, thereby improving user experience. Meanwhile, execution conflicts are effectively handled to guarantee smooth file synchronization. Conflicts are inevitable during file synchronization, and failure to handle conflicts promptly may lead to file synchronization failure or data inconsistency. Allowing users to select conflict handling manners can adopt the most appropriate solution for situations, and ensure the accuracy and reliability of file synchronization.

[0394] When obtaining an execution order based on respective operation types of the target change operations, the electronic device groups the target change operations based on respective file execution paths corresponding to the target change operations in combination with preset asynchronous execution information, to obtain task groups, an intra-group execution order, and an inter-group execution order, and obtain the execution order of the target change operations based on these orders. The execution of the target change operations can be properly arranged through grouping and by determining the execution order. The file execution path may reflect correlation and dependency between operations. Grouping operations by path can concentrate related operations for unified management and execution. The preset asynchronous execution information may fully utilize system parallel processing capability and improve execution efficiency. For example, a local file uploading operation and a remote file downloading operation may be executed asynchronously. In this way, a plurality of operations may be executed simultaneously, thereby shortening waiting time. The determination of the intra-group execution order and the inter-group execution order ensures that operations are executed in a logical order and prevents conflicts and errors between operations. Such proper arrangement promotes the execution efficiency of file synchronization, shortens synchronization time, and makes the file synchronization process more efficient and smooth.

[0395] When sequentially executing the target change operations according to the execution order, the electronic device sequentially executes, for each task group according to the inter-group execution order, the target change operations based on the intra-group execution order, and updates the synchronization directory at the end of operation execution. Executing operations according to the inter-group and intra-group execution orders and updating the synchronization directory promptly can guarantee the orderliness and consistency of the file synchronization process. The inter-group execution order ensures that the execution order of different task groups meets logical requirements and avoids task conflicts and dependency problems. The intra-group execution order ensures that operations in each task group are executed in a correct order and improves operation accuracy. Timely synchronization directory update ensures that the states of the local and remote folders remain synchronized at all times, so that users can view the latest file information in real time. Such orderliness and consistency improve the quality and efficiency of file synchronization, reduce problems caused by improper operation order or delayed synchronization, and provide users with a more stable and reliable file synchronization service.

[0396] The technical features of the foregoing embodiments may be combined in any manner. For the sake of brevity, not all possible combinations of the technical features in the foregoing embodiments have been described. However, any combination of these technical features is to be considered within the scope of this specification, provided that no contradiction arises.

[0397] The foregoing embodiments describe merely several implementations of this application and the descriptions are and detailed, but they are not to be understood as a limitation to the patent scope of the disclosure. For those of ordinary skill in the art, several transformations and improvements may further be made without departing from the idea of this application. These transformations and improvements fall within the scope of protection of this application. Therefore, the protection scope of the patent of this application is subject to the appended claims.

Claims

1. A file synchronization method, performed by an electronic device, the method comprising:obtaining, for a current file synchronization between a local folder and a remote folder, a local directory of the local folder at a synchronization moment, a remote directory of the remote folder at the synchronization moment, and a synchronization directory representing the local folder and the remote folder in a synchronized state at an end of a previous file synchronization;determining, based on the local directory, the remote directory, and the synchronization directory, a local change operation set occurring in the local folder and a remote change operation set occurring in the remote folder from the end of the previous file synchronization to the synchronization moment;performing difference analysis on the local change operation set and the remote change operation set to generate an analysis result;determining, based on the analysis result, a plurality of target change operations to be executed in the current file synchronization;determining an execution order of the plurality of target change operations based on operation types of the plurality of target change operations; andsequentially executing the plurality of target change operations according to the execution order to complete the current file synchronization between the local folder and the remote folder.

2. The method according to claim 1, wherein the determining the local change operation set comprises:performing, based on a directory structure of the local directory, the following operations sequentially on each local file object of a plurality of local file objects in the local directory:comparing a directory location of the local file object with respective directory locations of a plurality of synchronized file objects in the synchronization directory;determining, based on a comparison result, a reference change operation corresponding to the local file object; anddetermining the local change operation set based on the reference change operation corresponding to each local file object of the plurality of local file objects.

3. The method according to claim 2, wherein the determining the reference change operation comprises:determining, based on the comparison result indicating that a synchronized file object of the plurality of synchronized file objects has a same directory location as the local file object, the reference change operation corresponding to the local file object based on respective object types of the local file object and the synchronized file object.

4. The method according to claim 3, wherein the determining the reference change operation further comprises:determining, based on the comparison result indicating that no synchronized file object of the plurality of synchronized file objects has a same directory location as the local file object, the reference change operation corresponding to the local file object based on respective file identifiers of the plurality of synchronized file objects.

5. The method according to claim 1, wherein the obtaining comprises:taking a locally cached local folder directory of the local folder as the local directory at the synchronization moment, wherein the locally cached local folder directory is updated based on a change to the local folder;taking a locally cached remote folder directory of the remote folder as the remote directory at the synchronization moment, wherein the locally cached remote folder directory is updated based on a change to the remote folder; andtaking a locally cached synchronization folder directory of the local folder and the remote folder in the synchronized state at the end of the previous file synchronization as the synchronization directory.

6. The method according to claim 5, further comprising:obtaining, based on a synchronization exception occurring during the current file synchronization, the locally cached local folder directory at a current moment and the locally cached remote folder directory at the current moment after recovery from the synchronization exception; andre-performing the current file synchronization based on the locally cached local folder directory at the current moment, the locally cached remote folder directory at the current moment, and the synchronization directory.

7. The method according to claim 5, wherein the obtaining the remote directory comprises at least one of:obtaining historical operation data of the remote folder via a remote server, the historical operation data comprising operation data from the end of the previous file synchronization to the synchronization moment, and obtaining the remote directory based on the historical operation data in combination with a historical remote folder directory at the end of the previous file synchronization; orobtaining a changed file object set in the remote folder according to a set detection period, and updating the locally cached remote folder directory based on the changed file object set, to obtain the remote directory.

8. The method according to claim 7, wherein the obtaining the changed file object set comprises:transmitting a detection request to the remote server according to the set detection period, wherein the detection request carries local state information, recorded in the electronic device, of file objects in the remote folder at a current moment, and wherein each piece of the local state information is configured to represent whether a target processing operation has occurred to a corresponding file object of the file objects; andreceiving the changed file object set from the remote server, wherein the changed file object set is determined by the remote server based on a comparison between remote state information, recorded in the remote server, of the file objects at the current moment and the local state information.

9. The method according to claim 7, wherein the updating the locally cached remote folder directory comprises:pulling, based on the changed file object set comprising at least one file, the at least one file via the remote server, and updating the locally cached remote folder directory based on the at least one file, to obtain the remote directory.

10. The method according to claim 7, wherein the updating the locally cached remote folder directory comprises:pulling, based on the changed file object set comprising at least one folder, files in the at least one folder via the remote server, and updating the locally cached remote folder directory based on the files, to obtain the remote directory.

11. A file synchronization apparatus, comprising:at least one memory configured to store program code; andat least one processor configured to read the program code and operate as instructed by the program code, the program code comprising:obtaining code configured to cause at least one of the at least one processor to obtain, for a current file synchronization between a local folder and a remote folder, a local directory of the local folder at a synchronization moment, a remote directory of the remote folder at the synchronization moment, and a synchronization directory representing the local folder and the remote folder in a synchronized state at an end of a previous file synchronization;first determination code configured to cause at least one of the at least one processor to determine, based on the local directory, the remote directory, and the synchronization directory, a local change operation set occurring in the local folder and a remote change operation set occurring in the remote folder from the end of the previous file synchronization to the synchronization moment;analysis code configured to cause at least one of the at least one processor to perform difference analysis on the local change operation set and the remote change operation set to generate an analysis result;second determination code configured to cause at least one of the at least one processor to determine, based on the analysis result, a plurality of target change operations to be executed in the current file synchronization;order code configured to cause at least one of the at least one processor to determine an execution order of the plurality of target change operations based on operation types of the plurality of target change operations; andexecution code configured to cause at least one of the at least one processor to sequentially execute the plurality of target change operations according to the execution order to complete the current file synchronization between the local folder and the remote folder.

12. The apparatus according to claim 11, wherein the first determination code is further configured to cause at least one of the at least one processor to:perform, based on a directory structure of the local directory, the following operations sequentially on each local file object of a plurality of local file objects in the local directory:compare a directory location of the local file object with respective directory locations of a plurality of synchronized file objects in the synchronization directory;determine, based on a comparison result, a reference change operation corresponding to the local file object; anddetermine the local change operation set based on the reference change operation corresponding to each local file object of the plurality of local file objects.

13. The apparatus according to claim 12, wherein the first determination code is further configured to cause at least one of the at least one processor to:determine, based on the comparison result indicating that a synchronized file object of the plurality of synchronized file objects has a same directory location as the local file object, the reference change operation corresponding to the local file object based on respective object types of the local file object and the synchronized file object.

14. The apparatus according to claim 13, wherein the first determination code is further configured to cause at least one of the at least one processor to:determine, based on the comparison result indicating that no synchronized file object of the plurality of synchronized file objects has a same directory location as the local file object, the reference change operation corresponding to the local file object based on respective file identifiers of the plurality of synchronized file objects.

15. The apparatus according to claim 11, wherein the obtaining code is further configured to cause at least one of the at least one processor to:take a locally cached local folder directory of the local folder as the local directory at the synchronization moment, wherein the locally cached local folder directory is updated based on a change to the local folder;take a locally cached remote folder directory of the remote folder as the remote directory at the synchronization moment, wherein the locally cached remote folder directory is updated based on a change to the remote folder; andtake a locally cached synchronization folder directory of the local folder and the remote folder in the synchronized state at the end of the previous file synchronization as the synchronization directory.

16. The apparatus according to claim 15, wherein the program code further comprises:recovery code configured to cause at least one of the at least one processor to obtain, based on a synchronization exception occurring during the current file synchronization, the locally cached local folder directory at a current moment and the locally cached remote folder directory at the current moment after recovery from the synchronization exception; andre-synchronization code configured to cause at least one of the at least one processor to re-perform the current file synchronization based on the locally cached local folder directory at the current moment, the locally cached remote folder directory at the current moment, and the synchronization directory.

17. The apparatus according to claim 15, wherein the obtaining code is further configured to cause at least one of the at least one processor to perform at least one of:obtain historical operation data of the remote folder via a remote server, the historical operation data comprising operation data from the end of the previous file synchronization to the synchronization moment, and obtain the remote directory based on the historical operation data in combination with a historical remote folder directory at the end of the previous file synchronization; orobtain a changed file object set in the remote folder according to a set detection period, and update the locally cached remote folder directory based on the changed file object set, to obtain the remote directory.

18. The apparatus according to claim 17, wherein the obtaining code is further configured to cause at least one of the at least one processor to:transmit a detection request to the remote server according to the set detection period, wherein the detection request carries local state information, recorded in the electronic device, of file objects in the remote folder at a current moment, and wherein each piece of the local state information is configured to represent whether a target processing operation has occurred to a corresponding file object of the file objects; andreceive the changed file object set from the remote server, wherein the changed file object set is determined by the remote server based on a comparison between remote state information, recorded in the remote server, of the file objects at the current moment and the local state information.

19. The apparatus according to claim 17, wherein the obtaining code is further configured to cause at least one of the at least one processor to:pull, based on the changed file object set comprising at least one file, the at least one file via the remote server, and update the locally cached remote folder directory based on the at least one file, to obtain the remote directory.

20. A non-transitory computer-readable storage medium, storing computer code which, when executed by at least one processor, causes the at least one processor to at least:obtain, for a current file synchronization between a local folder and a remote folder, a local directory of the local folder at a synchronization moment, a remote directory of the remote folder at the synchronization moment, and a synchronization directory representing the local folder and the remote folder in a synchronized state at an end of a previous file synchronization;determine, based on the local directory, the remote directory, and the synchronization directory, a local change operation set occurring in the local folder and a remote change operation set occurring in the remote folder from the end of the previous file synchronization to the synchronization moment;perform difference analysis on the local change operation set and the remote change operation set to generate an analysis result;determine, based on the analysis result, a plurality of target change operations to be executed in the current file synchronization;determine an execution order of the plurality of target change operations based on operation types of the plurality of target change operations; andsequentially execute the plurality of target change operations according to the execution order to complete the current file synchronization between the local folder and the remote folder.