CN109688176B - File synchronization method, terminal, network device and storage medium - Google Patents

File synchronization method, terminal, network device and storage medium Download PDF

Info

Publication number
CN109688176B
CN109688176B CN201710972257.7A CN201710972257A CN109688176B CN 109688176 B CN109688176 B CN 109688176B CN 201710972257 A CN201710972257 A CN 201710972257A CN 109688176 B CN109688176 B CN 109688176B
Authority
CN
China
Prior art keywords
file
modification
data
target
information
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201710972257.7A
Other languages
Chinese (zh)
Other versions
CN109688176A (en
Inventor
卫超
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN201710972257.7A priority Critical patent/CN109688176B/en
Publication of CN109688176A publication Critical patent/CN109688176A/en
Application granted granted Critical
Publication of CN109688176B publication Critical patent/CN109688176B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/06Protocols specially adapted for file transfer, e.g. file transfer protocol [FTP]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1095Replication or mirroring of data, e.g. scheduling or transport for data synchronisation between network nodes

Abstract

The embodiment of the invention discloses a file synchronization method, which comprises the following steps: the method comprises the steps that a terminal detects a modification operation aiming at a first file, and modifies the first file according to the modification operation; acquiring modification characteristic information corresponding to the modification operation, wherein the modification characteristic information at least represents modification information for modifying first data corresponding to the first file and modifying the first data into second data; and sending modification characteristic information corresponding to the modification operation to the network equipment, so that the network equipment can modify a second file which is stored in the network equipment and is associated with the first file based on the modification characteristic information, and modify the first data in the second file into the second data, so as to at least complete the synchronization process of the second data obtained after modification in the first file. The embodiment of the invention also discloses a terminal, network equipment and a storage medium.

Description

File synchronization method, terminal, network device and storage medium
Technical Field
The present invention relates to information processing technologies, and in particular, to a file synchronization method, a terminal, a network device, and a storage medium.
Background
When a file is synchronized in the prior art, for example, a file sender sends a file to a file receiver to synchronize the file unless the same file exists on the file receiver, the file sender sends all data of the file, namely, the first byte to the last byte to the file receiver. However, in practical applications, in some scenarios, the bandwidth is wasted due to the full transmission mode, for example, when a student uses a network disk to backup a graduation paper in writing the graduation paper, the paper is changed at any time, but the change is not large, and at this time, if the graduation paper after being modified is completely uploaded to the network disk each time, the bandwidth is wasted, because most of the contents of the existing files on the network disk and the files to be synchronized are the same, the bandwidth is wasted due to the existing synchronization mode of completely synchronizing the graduation paper after being modified by a small amount to the network disk.
Disclosure of Invention
In order to solve the existing technical problems, embodiments of the present invention provide a file synchronization method, a terminal, a network device, and a storage medium, which can at least solve the above problems in the prior art.
The technical scheme of the embodiment of the invention is realized as follows:
a first aspect of an embodiment of the present invention provides a file synchronization method, where the method includes:
the method comprises the steps that a terminal detects a modification operation aiming at a first file, and modifies the first file according to the modification operation;
acquiring modification characteristic information corresponding to the modification operation, wherein the modification characteristic information at least represents modification information for modifying first data corresponding to the first file and modifying the first data into second data;
and sending modification characteristic information corresponding to the modification operation to the network equipment, so that the network equipment can modify a second file which is stored in the network equipment and is associated with the first file based on the modification characteristic information, and modify the first data in the second file into the second data, so as to at least complete the synchronization process of the second data obtained after modification in the first file.
A second aspect of the embodiments of the present invention provides a file synchronization method, where the method includes:
the method comprises the steps that network equipment receives modification characteristic information, wherein the modification characteristic information is obtained by modifying a first file through a terminal, and at least represents modification information which modifies first data corresponding to the first file into second data;
acquiring a second file associated with the first file for which the modified characteristic information is specific;
and modifying a second file which is stored in the second file and is associated with the first file based on the modification characteristic information, and modifying the first data in the second file into the second data so as to at least complete the synchronization process of the second data obtained after modification in the first file.
A third aspect of an embodiment of the present invention provides a terminal, including:
the first processing unit is used for detecting a modification operation aiming at a first file and modifying the first file according to the modification operation; acquiring modification characteristic information corresponding to the modification operation, wherein the modification characteristic information at least represents modification information for modifying first data corresponding to the first file and modifying the first data into second data;
a sending unit, configured to send modification characteristic information corresponding to the modification operation to the network device, so that the network device can modify a second file stored in the network device and associated with the first file based on the modification characteristic information, and modify the first data in the second file into the second data, so as to at least complete a synchronization process of the second data obtained after modification in the first file.
A fourth aspect of an embodiment of the present invention provides a network device, including:
the device comprises a receiving unit, a processing unit and a processing unit, wherein the receiving unit is used for receiving modification characteristic information, and the modification characteristic information is obtained by modifying a first file by a terminal and at least represents modification information for modifying first data corresponding to the first file into second data;
a second processing unit, configured to acquire a second file associated with the first file for which the modification characteristic information is specific; and modifying a second file which is stored in the second file and is associated with the first file based on the modification characteristic information, and modifying the first data in the second file into the second data so as to at least complete the synchronization process of the second data obtained after modification in the first file.
A fifth aspect of embodiments of the present invention provides a first computer-readable storage medium, on which a first computer program is stored, which, when being executed by a processor, implements the above-mentioned steps applied to a terminal-side method.
A sixth aspect of the embodiments of the present invention provides a second computer-readable storage medium, on which a second computer program is stored, where the second computer program is executed by a processor to implement the above-mentioned steps applied to the network device side method.
According to the file synchronization method, the terminal, the network device and the storage medium, modification characteristic information for modifying the first file is acquired through the terminal, and only the modification characteristic information aiming at the first file needs to be transmitted to the network device side when the file is synchronized, so that a second file which is stored at the network device side and is associated with the first file is correspondingly modified based on the modification characteristic information, the synchronization process of modified data is completed, and the synchronization of the files is further realized. The embodiment of the invention can realize the aim of file synchronization without sending the whole modified file to the receiver, thereby solving the problem that the file synchronization can be completed only by sending the whole file to the receiver due to the mismatching of the hash values after the file modification, saving the bandwidth, accelerating the file synchronization speed, shortening the file synchronization time and improving the user experience.
Drawings
FIG. 1 is a schematic diagram of an implementation flow of a file synchronization method according to an embodiment of the present invention;
fig. 2 is an interaction diagram of a terminal and a network device in a file synchronization method according to an embodiment of the present invention;
FIG. 3 is a diagram illustrating a first file and a second file having an association relationship according to an embodiment of the invention;
FIG. 4 is a diagram illustrating multiple modifications to a first file according to an embodiment of the invention;
FIG. 5 is a schematic diagram illustrating a flow chart of a sender implementing the method for synchronizing files according to an embodiment of the present invention in a specific application;
FIG. 6 is a schematic diagram illustrating a flow chart of a receiver implementing the file synchronization method according to an embodiment of the present invention in a specific application;
fig. 7 is a schematic structural diagram of a terminal according to an embodiment of the present invention;
fig. 8 is a schematic structural diagram of a network device according to an embodiment of the present invention.
Detailed Description
In practical application, the file synchronization process specifically includes: calculating a hash value of a file to be synchronized before file synchronization, for example, calculating by using an MD5 algorithm to obtain an MD5 value, detecting whether a target machine (i.e., a receiver machine) has a file with the same hash value or MD5 value, if so, determining that the file to be synchronized is stored in the target machine, and at this time, finishing the synchronization; otherwise, the file to be synchronized is transmitted to the target machine, and the file synchronization process is completed.
Here, after the file synchronization is completed, if the file is modified a little, since the above-mentioned file synchronization process does not consider the case of modifying the file a little, in principle, even if the file is modified by one byte, the hash value will change, so that the whole file needs to be sent to the target machine as long as the file is slightly modified. Obviously, the synchronization method is wasteful of bandwidth. Therefore, to solve the above problem, embodiments of the present invention provide a file synchronization method, a terminal, a network device, and a storage medium. So that the manner in which the features and aspects of the present invention can be understood in detail, a more particular description of the invention, briefly summarized above, may be had by reference to embodiments, some of which are illustrated in the appended drawings.
Examples
The embodiment provides a file synchronization method, and in particular, in the embodiment, all modification steps, that is, modification characteristic information described in the embodiment, are recorded during file modification, so that when a file is synchronized, if a receiver has a file before modification, the modification step only needs to be sent to the receiver, and then the receiver modifies the file before modification stored in the receiver by using the modification step to obtain the modified file.
FIG. 1 is a schematic diagram of an implementation flow of a file synchronization method according to an embodiment of the present invention; here, the method described in fig. 1 is applied to a terminal side, and the terminal may be embodied as a mobile terminal, such as a mobile phone, a tablet computer, or the like, or a non-mobile terminal, such as a desktop computer or the like. Further, the terminal described in this embodiment is a sender, and the network device is a receiver, that is, this embodiment is applied to a scenario where a sender synchronizes files with a receiver. Specifically, as shown in fig. 1, the method includes:
step 101: the method comprises the steps that a terminal detects a modification operation aiming at a first file, and modifies the first file according to the modification operation;
step 102: the terminal acquires modification characteristic information corresponding to the modification operation, wherein the modification characteristic information at least represents modification information for modifying first data corresponding to the first file and modifying the first data into second data;
in practical applications, the modification characteristic information records all relevant information corresponding to the implementation of the modification operation, for example, including but not limited to the following modification information: the modification time, the location at which the first data targeted by the modification operation is located (i.e., the modified location), the first data before modification, the first data after modification (i.e., the second data), and so on.
Step 103: and the terminal sends modification characteristic information corresponding to the modification operation to the network equipment, so that the network equipment can modify a second file which is stored in the network equipment and is associated with the first file based on the modification characteristic information, and modify the first data in the second file into the second data, so as to at least complete the synchronization process of the second data obtained after modification in the first file.
In this embodiment, the network device may be any device having a data storage function, for example, a terminal, a server, etc. having a data storage function, or a network hard disk (network disk for short), etc., where the network hard disk is an online storage service provided by an internet company, and a user may operate a file stored on the network disk as a local hard disk.
Correspondingly, after receiving the modification characteristic information, the network device acquires a second file associated with the first file for which the modification characteristic information is specific, modifies a second file stored in the network device and associated with the first file based on the modification characteristic information, and modifies the first data in the second file into the second data, so as to at least complete the synchronization process of the second data obtained after modification in the first file. Specifically, fig. 2 is an interaction diagram of a terminal and a network device in a file synchronization method according to an embodiment of the present invention, as shown in fig. 2, the terminal detects a modification operation for a first file, modifies the first file according to the modification operation, acquires modification feature information corresponding to the modification operation, and sends the modification feature information to the network device, and correspondingly, after receiving the modification feature information, the network device acquires, based on the modification feature information, a second file associated with the first file to which the modification feature information is directed, and further modifies, based on the modification feature information, the first data in the second file into the second data, so that a synchronization process of at least the modified data is implemented, that is, a synchronization process of the second data obtained after modification in the first file is implemented, in the synchronization process, only the modification characteristic information is transmitted, and not all files are transmitted, so that a foundation is laid for saving bandwidth and improving the file synchronization efficiency.
Here, in practical applications, before transmitting the modified feature information to the network device, the terminal further needs to determine whether the data size of the modified feature information is smaller than the data size of the modified first file, and if so, the modified feature information is sent to the network device, otherwise, the modified first file is directly sent to the network device. Therefore, the minimum data volume of transmission is ensured while the file synchronization is realized, and a foundation is further laid for saving bandwidth and improving the file synchronization efficiency.
In a specific application scenario, step 103 is executed after a target instruction is detected, that is, the target instruction is detected, and the terminal sends modification feature information corresponding to the modification operation to the network device based on the target instruction, so as to complete a file synchronization process; here, the target instruction may be specifically a storage instruction, that is, after the user completes modification of the first file and clicks a save operation, the terminal sends the modification feature information to the network device to implement synchronization of the modified first file, and meanwhile, since the target instruction is the storage instruction, a file synchronization process is simplified, user operation is simplified, and user experience is improved. Of course, the target instruction may also be generated based on a user operation, for example, the terminal may generate the target instruction after detecting a specific operation, and then send the modification feature information based on the target.
In a specific embodiment, before obtaining the modification feature information corresponding to the modification operation, the terminal needs to determine whether a second file exists in a network device, specifically, the terminal detects whether the second file associated with the first file is stored in the network device, and obtains the modification feature information corresponding to the modification operation when determining that the second file associated with the first file is stored in the network device; that is, the terminal may obtain the modification feature information corresponding to the modification operation only when it is determined that the second file is stored in the network device. In practical applications, the network device may detect whether a second file associated with the first file is stored in the network device; and feeding back the detection result to the terminal so that the terminal can determine whether the second file is stored in the network equipment. Further, the network device can receive the modification feature information only when determining that the network device stores a second file associated with the first file. That is to say, in this embodiment, a specific detection process of detecting whether the second file is stored in the network device may be implemented by the terminal, or may be implemented by the network device by feeding back the result to the terminal after detecting the result, which is not limited in this embodiment.
Here, the second file is the same as or different from the first file, for example, fig. 3 shows a schematic diagram of the first file and the second file having an association relationship according to the embodiment of the present invention, as shown in fig. 3, the association between the second file and the first file means that the second file is the same as the first file, as in relationship-1, the contents of the first file and the second file-1 are completely the same; or, a part of the content in the second file is the same as a part of the content in the first file, for example, in relation-2, the content-1 in the first file is the same as the content-1 in the second file-2, so that, when the part of the content in the first file that is the same as the second file is modified, the part of the content in the second file stored in the network device that is the same as the first file can be synchronously modified based on the method described in the embodiment of the present invention, so as to ensure that the part of the content in the second file stored in the network device that is originally the same as the first file is still the same as the modified first file, thereby implementing synchronous modification of the same content between different files.
Further, in another specific embodiment, the second file is the same as the first file, and at this time, the terminal may detect whether the first file is stored in the network device by using the characteristic value; specifically, the terminal calculates a feature value of the first file, where the feature values of the first files with different contents are different, for example, the feature value may be specifically a hash value. In this way, the terminal may determine whether the network device stores the same file as the first file by detecting whether the network device has the feature value that is the same as the feature value of the first file, for example, when the network device has the feature value that is the same as the feature value of the first file, it is considered that the network device stores the first file, otherwise, it is considered that the network device does not store the first file.
Of course, in practical applications, after the terminal calculates the feature value of the first file, the terminal may send the feature value of the first file to a network device, and accordingly, the network device searches whether a feature value identical to the feature value of the first file exists, so as to determine whether the first file is stored in the network device itself.
In this way, the method of this embodiment obtains the modification feature information for performing the modification operation on the first file through the terminal, and only needs to transmit the modification feature information for the first file to the network device side when performing the file synchronization, so that the second file stored at the network device side and associated with the first file is correspondingly modified based on the modification feature information to complete the synchronization process of the modification data, thereby implementing the file synchronization. The embodiment of the invention can realize the aim of file synchronization without sending the whole modified file to the receiver, thereby solving the problem that the file synchronization can be completed only by sending the whole file to the receiver due to the mismatching of the hash values after the file modification, saving the bandwidth, accelerating the file synchronization speed, shortening the file synchronization time and improving the user experience.
Example two
Based on the method described in the first embodiment, this embodiment provides a method for simplifying modification of feature information, for example, when a terminal modifies the same content of a first file multiple times, the modification of feature information does not need to record detailed information of multiple modification processes, and only needs to record the last modification process to ensure synchronization of modified content; as shown in fig. 4, the terminal has modified the first file twice, the first modification modifies the first file to be the first file-1 (e.g., modifies a in the first file to be a1), the second modification still modifies the same content, and modified to the first file-2 (e.g., modifying a1 in the first file-1 to a2), at this time, the modification characteristic information needs to record the detailed modification steps of the first file modified to the first file-1, the first file-1 to the first file-2, however, since the modified file corresponding to the intermediate modification process, i.e. the first file-1, therefore, the terminal only needs to feed back the modification step of modifying the first file into the first file-2 to the network equipment, and the synchronous modification process of the first file in the network equipment can be realized. Specifically, the terminal determines whether there is target modification information obtained by performing N modification operations on the first data (as shown in fig. 4, a in a first file) in the modification feature information, where the target modification information at least represents N second data obtained by performing N modification operations on the first data, where N is a positive integer greater than or equal to 2, and as shown in fig. 4, a detailed modification step of modifying the first file into a first file-1 and then modifying the first file-1 into a first file-2 is recorded in the target modification information; when the target modification information exists, at least simplifying the target modification information in the modification feature information to delete M second data aiming at the first data in the target modification information to obtain the target modification feature information containing the simplified target modification information, wherein M is a positive integer which is greater than or equal to 1 and less than or equal to N-1, and by taking the example of FIG. 4 as an example, the intermediate modification process in the target modification information can be deleted, namely the process from the first file to the first file-1 is deleted, only the modification step from the first file to the first file-2 is recorded, and the intermediate modification step is omitted; the simplified target modification information at least includes second data corresponding to the latest modification operation on the first data, for example, the target modification information only includes a modification process from the first file to the first file-2; and then sending the target modification characteristic information to the network equipment, so that the network equipment can modify a second file which is stored by the network equipment and is associated with the first file based on the target modification characteristic information, and directly modify the first data in the second file into second data corresponding to the latest modification operation of the first data, so as to at least complete the synchronization process of the second data obtained after modification in the first file, and in the process, the network equipment omits an intermediate modification process, so that the data volume of the synchronized data is further reduced, the bandwidth is further saved, the file synchronization speed is accelerated, and the file synchronization time is shortened.
The first embodiment and the second embodiment of the present invention are further described in detail with reference to specific application scenarios. The application scenario provides a method for quickly synchronizing files based on file modification records, and specifically, in the scenario, during the modification of a file F, a terminal records all modification steps of the file, namely N modification steps from P1, P2 to PN, for example, N modification steps such as d bytes are deleted from a kth byte, a l byte is changed from bl to bx, and N bytes are inserted into an mth byte. The N modification steps may be redundant, for example, the first byte is changed to bx and then changed to by, at this time, the modification step of changing the first byte to bx is useless, so before synchronizing the files, the terminal may simplify and combine the N modification steps to obtain M (M ≦ N) simplified steps, if the space occupied by the M steps is smaller than the volume of the modified file F-1, the M modification steps are sent to the target machine, and the target machine sequentially applies the steps to the file before modification (i.e., the file F), so that the modified file F-1 is obtained. Certainly, in the above process, the target machine stores a file before the terminal is modified, that is, F; in this way, since the modified file does not need to be completely sent again, when the size of the file to be synchronized is larger, the number of modification steps is smaller, and the more synchronization time is saved by the method of the embodiment of the present invention.
Specifically, the specific steps of the sender side, i.e. the terminal side, as shown in fig. 5 include:
step 5-1: the sender starts to modify the file F;
here, in practical applications, the sender may further calculate a hash value of the file F, and further determine whether the file F exists on the receiver by using the hash value. Here, the receiving side may be specifically a network disk side, that is, the terminal determines whether a file exists in the network disk.
Step 5-2: judging whether a file F exists in a receiver or not; if the file F exists, entering the step 5-3; otherwise, entering the step 5-4;
step 5-3: the sender records the modification process of the file F to obtain a modification step P;
step 5-4: after the sender modifies the file, obtaining a modified file F-1;
step 5-5: the sender starts to synchronize the files, if the sender detects the file F-1 saving instruction, the file is synchronized, at this time, whether the receiver has the file F-1 is judged, if yes, the synchronization is finished; otherwise, entering step 5-6;
and 5-6: judging whether the modification step P is empty; that is, whether an effective modification step exists in the modification step P or whether modification step information exists is judged, and if not, the file F is modified and the step 5-7 is entered; otherwise, entering the step 5-10;
and 5-7: the sender combines the optimized modification step P to obtain a simplified modification step P-1;
and 5-8: judging whether the simplified data volume of the modification step P-1 is smaller than the data volume of the file F-1, if so, entering a step 5-9; otherwise, entering the step 5-10;
and 5-9: and the receiver sends the simplified modification step P-1 to the receiver so that the receiver is applied to the file F before modification to obtain the modified file F-1, and the synchronization is finished.
Step 5-10: and the sender sends the modified file F-1 to the receiver, and the synchronization is finished.
Correspondingly, the specific steps of the receiving side, that is, the network device side shown in fig. 6 include:
step 6-1: the receiver starts to receive the file;
step 6-2: the receiver judges the type of the received file, namely judges whether the received file is a modification step; if yes, entering step 6-3; otherwise, the file is received in a conventional manner. The file is stored directly.
For example, the receiver receives the modification step P-1.
Step 6-3: the receiver searches the file F based on the received modification step P-1, and the file F before modification is obtained;
step 6-4: the receiver applies the modification step P-1 to the file F to obtain a modified file F-1;
step 6-5: and saving the modified file F-1, and finishing the synchronization.
The following are pseudo-codes for the sender and receiver; respectively as follows:
first, the pseudo code of the sender:
Figure BDA0001437797860000111
Figure BDA0001437797860000121
second, the pseudo code of the receiver:
Figure BDA0001437797860000122
Figure BDA0001437797860000131
therefore, the sender participates in modifying the file, records and sends the modifying step, and the receiver applies the received modifying step to the file before modification to obtain the modified file, so that the synchronization process of the modified file is realized. In the process, all modified files do not need to be sent, so that the user experience of network disk file synchronization is improved, and especially when the files to be synchronized are only slightly changed, the efficiency of file synchronization can be greatly improved.
EXAMPLE III
Based on the method described in the first embodiment, the present embodiment provides another file synchronization method in a specific application scenario; in this scenario, the second file is the same as the first file, the first file is a file synchronized to the network device by the terminal, and the network device can modify the first file based on modification characteristic information of modification operation of different terminals on the first file; that is to say, in this scenario, different users can use the synchronization function of the network disk at multiple terminals for the same file, for example, the same file exists in different terminals, and the same file is synchronized to the network disk, at this time, since different users can modify the file differently at multiple terminals, multiple files corresponding to different terminals are different, but the multiple terminals can all feed back modification feature information corresponding to themselves to the network device, so that the network device can modify the first file according to the modification feature information of different terminals. Further, in order to enable a user to know modification conditions of other users, this embodiment provides a file synchronization method for synchronizing modified files to all terminals, and specifically, the terminal determines a first file and determines whether the first file is the same as a first file currently stored by the network device; and if not, acquiring modification characteristic information corresponding to modification operation of the first file by other terminals from the network equipment, and modifying the first file corresponding to the terminal based on the modification characteristic information of the modification operation of the first file by other terminals, so as to complete the file synchronization process of the first file after the modification operation in different terminals.
Correspondingly, the network device can receive modification characteristic information sent by at least two terminals and used for modifying the first file, and modify the first file based on the modification characteristic information of the modification operation of each terminal on the first file; further, the network device detects a target terminal, where the target terminal is any one of the at least two terminals or another terminal other than the at least two terminals, and the first file is stored in the target terminal, for example, the target terminal is a terminal that is to synchronize the first file with the network device, or the target terminal is a terminal that stores the first file and is capable of modifying the first file, and correspondingly, the detected target terminal may be a terminal that detects that the target terminal is switched from a closed state to an open state; further, whether a first file in a target terminal is the same as a first file currently stored by the network equipment is judged; if not, the network device selects modification characteristic information corresponding to modification operation of the first file by other terminals except the target terminal from modification characteristic information received by the network device, and sends the modification characteristic information corresponding to modification operation of the first file by other terminals except the target terminal to the target terminal, so as to complete a file synchronization process after modification operation of the first file in different terminals.
The embodiments of the present invention are described in further detail below with specific application scenarios; in this embodiment, when the terminal uploads the file to the network disk for the first time, the network disk takes the file as a reference file and records the hash value of the file. And when the file is modified each time, the network disk stores the modification step and the hash value of the modified file. Therefore, the network disk is equivalent to store all versions of the file modified by aiming at different terminals, when the file is synchronized, as long as the hash value of the existing file of the target terminal is known, corresponding modification steps (possibly one or more history modification steps) can be sent to the target terminal, and the target terminal can obtain the latest file by applying the modification steps. For example:
the initial file is F0, the hash value of the initial file is H0, there are A, B, C three terminals, and the following events occur in sequence:
1. the terminal A, B, C gets the file from the carousel sync F0, the terminal B, C is powered off, and the terminal a remains powered on.
2. And the terminal A modifies the file F0 into a file F1, the hash value of the file F1 is H1, the modification step is P1, and the terminal A is powered off after the file is synchronized to the network disk.
3. Terminal B boots up and starts the network disk client, at which point terminal B owns file F0, and to update F0, terminal B synchronizes from the network disk and applies modification step P1 to get file F1.
4. And the terminal B modifies the file F1 to obtain a file F2, the hash value of the file F2 is H2, the modification step is P2, and the terminal B is powered off after the synchronization to the network disk.
5. And starting the terminal C and starting the network disk client, wherein the file owned by the terminal C is still the initial file F0, the modification steps P1 and P2 are obtained from the network disk synchronization, and the modification steps P1 and P2 are sequentially applied to the latest file F2.
The network disk has all modified versions of the files modified by different terminals, so that when the network disk is synchronized with each terminal, the difference between the latest version of the file and the existing file version of the terminal can be calculated by the network disk, the difference file is sent to the terminal, and therefore the terminal can obtain the latest file by combining the existing file and the difference file, and the synchronization process of the file at different terminals is realized.
Example four
This embodiment provides a terminal, as shown in fig. 7, the terminal includes:
a first processing unit 71, configured to detect a modification operation for a first file, and modify the first file according to the modification operation; acquiring modification characteristic information corresponding to the modification operation, wherein the modification characteristic information at least represents modification information for modifying first data corresponding to the first file and modifying the first data into second data;
a sending unit 72, configured to send modification characteristic information corresponding to the modification operation to the network device, so that the network device can modify a second file stored in the network device and associated with the first file based on the modification characteristic information, and modify the first data in the second file into the second data, so as to at least complete a synchronization process of the second data obtained after modification in the first file.
In an embodiment, the first processing unit 71 is further configured to determine whether there is target modification information obtained by performing N modification operations on the first data in the modification feature information, where the target modification information at least represents N second data obtained by performing N modification operations on the first data, and N is a positive integer greater than or equal to 2;
the processing module is further configured to, when the modified feature information exists, perform simplification processing on at least target modified information in the modified feature information to delete M second data in the target modified information for the first data, so as to obtain target modified feature information including the simplified target modified information, where M is a positive integer greater than or equal to 1 and less than or equal to N-1; the simplified target modification information at least comprises second data corresponding to the latest modification operation aiming at the first data;
correspondingly, the sending unit 72 is further configured to send the target modification characteristic information to the network device, so that the network device can modify a second file associated with the first file and stored in the network device based on the target modification characteristic information, and modify the first data in the second file into second data corresponding to a latest modification operation on the first data, so as to at least complete a synchronization process of the second data obtained after modification in the first file.
In another embodiment, the first processing unit 71 is further configured to detect whether a second file associated with the first file is stored in the network device; the modification feature information corresponding to the modification operation is acquired when it is determined that a second file associated with the first file is stored in the network device; wherein the second file is the same as or different from the first file.
In another embodiment, the second file is the same as the first file; correspondingly, the first processing unit 71 is further configured to calculate a feature value of the first file; whether a file with the same characteristic value as the first file exists in the network equipment is detected, and whether a second file related to the first file is stored in the network equipment is determined based on the detection result.
In another specific embodiment, the first file is the same as the second file; correspondingly, the first processing unit 71 is further configured to:
determining a first file, wherein the first file is a file synchronized to the network device by the terminal, and the network device can modify the first file based on modification characteristic information of modification operation of different terminals on the first file;
judging whether the first file is the same as a first file currently stored by the network equipment or not;
and if not, acquiring modification characteristic information corresponding to modification operation of the first file by other terminals from the network equipment, and modifying the first file corresponding to the terminal based on the modification characteristic information of the modification operation of the first file by other terminals, so as to complete the file synchronization process of the first file after the modification operation in different terminals.
Here, it should be noted that: the above description of the terminal embodiment is similar to the above description of the method embodiment for the terminal, and has similar beneficial effects to the method embodiment, and therefore, the description is omitted. For technical details that are not disclosed in the terminal embodiment of the present invention, please refer to the description of the method embodiment of the present invention for understanding, and therefore, for brevity, will not be described again.
EXAMPLE five
This embodiment provides a network device, as shown in fig. 8, where the network device includes:
a receiving unit 81, configured to receive modification feature information, where the modification feature information is obtained by a terminal performing a modification operation on a first file and at least represents that first data corresponding to the first file is modified and is modified into second data;
a second processing unit 82, configured to acquire a second file associated with the first file for which the modified feature information is specific; and modifying a second file which is stored in the second file and is associated with the first file based on the modification characteristic information, and modifying the first data in the second file into the second data so as to at least complete the synchronization process of the second data obtained after modification in the first file.
In an embodiment, the second processing unit 82 is further configured to detect whether a second file associated with the first file is stored; the network equipment is also used for receiving modification characteristic information when determining that a second file associated with the first file is stored in the network equipment;
wherein the second file is the same as or different from the first file.
In another embodiment, the second file is the same as the first file; correspondingly, the receiving unit 81 is further configured to receive modification feature information, which is sent by at least two terminals and used for performing modification operation on the first file;
correspondingly, the second processing unit 82 is further configured to:
modifying the first file based on modification characteristic information of modification operation of each terminal on the first file;
detecting a target terminal, wherein the target terminal is any one of the at least two terminals or other terminals except the at least two terminals, and the first file is stored in the target terminal;
judging whether a first file in a target terminal is the same as a first file currently stored by the network equipment or not;
if not, selecting modification characteristic information corresponding to modification operation of the first file by other terminals except the target terminal from the modification characteristic information received by the terminal, and sending the modification characteristic information corresponding to modification operation of the first file by other terminals except the target terminal to the target terminal so as to complete a file synchronization process after modification operation of the first file in different terminals.
Here, it should be noted that: the description of the embodiment of the network device is similar to the description of the embodiment of the method for the network device, and has similar beneficial effects to the embodiment of the method, and therefore, the description is omitted. For technical details that are not disclosed in the embodiment of the network device of the present invention, please refer to the description of the embodiment of the method of the present invention for understanding, and therefore, for brevity, will not be described again.
In addition, the embodiment of the present invention further provides a first computer readable storage medium, on which a first computer program is stored, wherein the first computer program, when executed by a processor, implements the above-mentioned method steps applied to the terminal side.
An embodiment of the present invention further provides a second computer-readable storage medium, on which a second computer program is stored, where the second computer program, when executed by a processor, implements the above-mentioned method steps applied to the network device side.
Here, it is noted that the method described in this embodiment may be implemented by a terminal, and may also be implemented by a client installed in the terminal; correspondingly, when the method is implemented by a client, the terminal described in this embodiment is the terminal installed with the client for implementing the method of this embodiment.
In the several embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other ways. The above-described device embodiments are merely illustrative, for example, the division of the unit is only a logical functional division, and there may be other division ways in actual implementation, such as: multiple units or components may be combined, or may be integrated into another system, or some features may be omitted, or not implemented. In addition, the coupling, direct coupling or communication connection between the components shown or discussed may be through some interfaces, and the indirect coupling or communication connection between the devices or units may be electrical, mechanical or other forms.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, that is, may be located in one place, or may be distributed on a plurality of network units; some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, all the functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may be separately regarded as one unit, or two or more units may be integrated into one unit; the integrated unit can be realized in a form of hardware, or in a form of hardware plus a software functional unit.
Those of ordinary skill in the art will understand that: all or part of the steps for implementing the method embodiments may be implemented by hardware related to program instructions, and the program may be stored in a computer readable storage medium, and when executed, the program performs the steps including the method embodiments; and the aforementioned storage medium includes: a mobile storage device, a Read Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
Alternatively, the integrated unit of the present invention may be stored in a computer-readable storage medium if it is implemented in the form of a software functional module and sold or used as a separate product. Based on such understanding, the technical solutions of the embodiments of the present invention may be essentially implemented or a part contributing to the prior art may be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the methods described in the embodiments of the present invention. And the aforementioned storage medium includes: a removable storage device, a ROM, a RAM, a magnetic or optical disk, or various other media that can store program code.
The above description is only for the specific embodiments of the present invention, but the scope of the present invention is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present invention, and all the changes or substitutions should be covered within the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the appended claims.

Claims (15)

1. A method for file synchronization, the method comprising:
the method comprises the steps that a terminal detects a modification operation aiming at a first file, and modifies the first file according to the modification operation;
acquiring modification characteristic information corresponding to the modification operation, wherein the modification characteristic information includes target modification information obtained by performing N times of modification operations on first data corresponding to the first file, the target modification information at least includes N second data obtained by performing N times of modification operations on the first data, and N is a positive integer greater than or equal to 2;
deleting M second data aiming at the first data in the target modification information to obtain target modification characteristic information containing the simplified target modification information, wherein M is a positive integer less than or equal to N-1;
when the data volume of the target modification characteristic information is smaller than the data volume of the modified first file, sending the target modification characteristic information to network equipment, so that the network equipment can modify a second file which is stored by the network equipment and is associated with the first file based on the target modification characteristic information, and modify the first data in the second file into second data corresponding to the latest modification operation of the first data, so as to at least complete the synchronization process of the second data obtained after modification in the first file;
and when the data volume of the target modification characteristic information is larger than the data volume of the modified first file, sending the modified first file to the network equipment.
2. The method according to claim 1, wherein the deleting M second data in the target modification information for the first data to obtain target modification feature information including simplified target modification information includes:
determining that target modification information obtained by performing N times of modification operations on the first data exists in the modification characteristic information;
and at least simplifying the target modification information in the modification feature information to delete the M second data in the target modification information for the first data to obtain target modification feature information including the simplified target modification information, wherein the simplified target modification information at least includes the second data corresponding to the latest modification operation for the first data.
3. The method of claim 1,
the obtaining of the modification feature information corresponding to the modification operation includes:
after determining that a second file associated with the first file is stored in the network equipment, acquiring modification characteristic information corresponding to the modification operation;
wherein the second file is the same as or different from the first file.
4. The method of claim 3, wherein the second file is the same as the first file; correspondingly, the method further comprises:
calculating to obtain a characteristic value of the first file;
whether a file with the same characteristic value as the first file exists in the network equipment is detected, and whether a second file related to the first file is stored in the network equipment is determined based on the detection result.
5. The method of claim 1, wherein the first file is the same as the second file; correspondingly, the method further comprises:
a terminal determines a first file, wherein the first file is a file synchronized to the network equipment by the terminal, and the network equipment can modify the first file based on target modification characteristic information of modification operation of different terminals on the first file;
and after the first file is determined to be different from a first file currently stored by the network equipment, acquiring target modification characteristic information corresponding to modification operation of the first file by other terminals from the network equipment, and modifying the first file corresponding to the terminal based on the target modification characteristic information of the modification operation of the first file by other terminals so as to complete a file synchronization process after the modification operation of the first file in different terminals.
6. A method for file synchronization, the method comprising:
when the data volume of the target modification characteristic information is smaller than the data volume of the modified first file, the network equipment receives the target modification characteristic information, wherein the target modification characteristic information is obtained by deleting M second data of the first file in the target modification information and contains simplified target modification information; the target modification information is modification information obtained by the terminal performing modification operation on first data corresponding to the first file for N times; the target modification information at least comprises N second data obtained by modifying the first data for N times, wherein N is a positive integer greater than or equal to 2, and M is a positive integer less than or equal to N-1;
acquiring a second file associated with the first file for which the target modification characteristic information is specific;
modifying a second file which is stored in the second file and is associated with the first file based on the target modification characteristic information, and modifying the first data in the second file into second data corresponding to the latest modification operation of the first data so as to at least complete the synchronization process of the second data obtained after modification in the first file;
and when the data volume of the target modification characteristic information is larger than the data volume of the modified first file, acquiring the modified first file.
7. The method of claim 6,
the network device receives the target modification characteristic information, and the target modification characteristic information comprises:
after determining that a second file associated with the first file is stored in the network equipment, receiving the target modification characteristic information;
wherein the second file is the same as or different from the first file.
8. The method according to claim 6 or 7, wherein the second file is the same as the first file; correspondingly, the method further comprises:
the network equipment receives target modification characteristic information which is sent by at least two terminals and used for modifying the first file, and modifies the first file based on the target modification characteristic information of the modification operation of each terminal on the first file;
detecting a target terminal, wherein the target terminal is any one of the at least two terminals or other terminals except the at least two terminals, and the first file is stored in the target terminal;
after determining that a first file in a target terminal is different from a first file currently stored by the network device, the network device selects target modification characteristic information corresponding to modification operation of the first file by other terminals except the target terminal from target modification characteristic information received by the network device, and sends the target modification characteristic information corresponding to modification operation of the first file by other terminals except the target terminal to the target terminal, so as to complete a file synchronization process after modification operation of the first file in different terminals.
9. A terminal, characterized in that the terminal comprises:
the first processing unit is used for detecting a modification operation aiming at a first file and modifying the first file according to the modification operation; acquiring modification characteristic information corresponding to the modification operation, wherein the modification characteristic information includes target modification information obtained by performing N times of modification operations on first data corresponding to the first file, the target modification information at least includes N second data obtained by performing N times of modification operations on the first data, and N is a positive integer greater than or equal to 2; deleting M second data aiming at the first data in the target modification information to obtain target modification characteristic information containing the simplified target modification information, wherein M is a positive integer less than or equal to N-1;
a sending unit, configured to send the target modification feature information to a network device when the data volume of the target modification feature information is smaller than the data volume of the modified first file, so that the network device can modify a second file, which is stored by the network device and is associated with the first file, based on the target modification feature information, and modify the first data in the second file into second data corresponding to a latest modification operation for the first data, so as to at least complete a synchronization process of the second data obtained after modification in the first file;
the sending unit is further configured to send the modified first file to the network device when the data volume of the target modification feature information is greater than the data volume of the modified first file.
10. The terminal according to claim 9, wherein the first processing unit is further configured to determine that there is target modification information obtained by performing N modification operations on the first data in the modification feature information;
and simplifying at least the target modification information in the modification feature information to delete the M second data aiming at the first data in the target modification information to obtain the target modification feature information containing the simplified target modification information, wherein the simplified target modification information at least contains the second data corresponding to the latest modification operation aiming at the first data.
11. The terminal according to claim 9, wherein the first processing unit is further configured to obtain modification feature information corresponding to the modification operation after determining that a second file associated with the first file is stored in the network device; wherein the second file is the same as or different from the first file.
12. A network device, characterized in that the network device comprises:
a receiving unit, configured to receive target modification feature information when a data amount of the target modification feature information is smaller than a data amount of a modified first file, where the target modification feature information is obtained by deleting M second data of the first file in the target modification information and includes simplified target modification information; the target modification information is modification information obtained by the terminal performing modification operation on first data corresponding to the first file for N times; the target modification information at least comprises N second data obtained by modifying the first data for N times, wherein N is a positive integer greater than or equal to 2, and M is a positive integer less than or equal to N-1;
a second processing unit, configured to acquire a second file associated with the first file for which the target modification feature information is specific; modifying a second file which is stored in the second file and is associated with the first file based on the target modification characteristic information, and modifying the first data in the second file into second data corresponding to the latest modification operation of the first data so as to at least complete the synchronization process of the second data obtained after modification in the first file;
the receiving unit is further configured to acquire the modified first file when the data volume of the target modification feature information is greater than the data volume of the modified first file.
13. The network device according to claim 12, wherein the second processing unit is further configured to receive the target modification feature information after determining that a second file associated with the first file is stored in the network device;
wherein the second file is the same as or different from the first file.
14. A first computer-readable storage medium, on which a first computer program is stored, characterized in that the first computer program, when being executed by a processor, carries out the steps of the method as set forth in claims 1 to 5.
15. A second computer-readable storage medium, on which a second computer program is stored, which, when being executed by a processor, carries out the steps of the method of claims 6 to 8.
CN201710972257.7A 2017-10-18 2017-10-18 File synchronization method, terminal, network device and storage medium Active CN109688176B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710972257.7A CN109688176B (en) 2017-10-18 2017-10-18 File synchronization method, terminal, network device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710972257.7A CN109688176B (en) 2017-10-18 2017-10-18 File synchronization method, terminal, network device and storage medium

Publications (2)

Publication Number Publication Date
CN109688176A CN109688176A (en) 2019-04-26
CN109688176B true CN109688176B (en) 2022-01-11

Family

ID=66184089

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710972257.7A Active CN109688176B (en) 2017-10-18 2017-10-18 File synchronization method, terminal, network device and storage medium

Country Status (1)

Country Link
CN (1) CN109688176B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111858518B (en) * 2020-07-09 2022-10-25 北京字节跳动网络技术有限公司 Method and device for updating reference document, electronic equipment and storage medium
CN115086345A (en) * 2022-05-13 2022-09-20 北京百度网讯科技有限公司 File synchronization method and device, electronic equipment and readable storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101855629A (en) * 2007-11-09 2010-10-06 微软公司 Collaborative authoring
CN102857570A (en) * 2012-09-13 2013-01-02 清华大学 Cloud synchronized method of files and cloud storage server
CN103902663A (en) * 2014-03-10 2014-07-02 联想(北京)有限公司 File synchronization method and device
CN104488248A (en) * 2014-04-15 2015-04-01 华为技术有限公司 File synchronization method, server and terminal
CN105827699A (en) * 2016-03-16 2016-08-03 心动网络股份有限公司 Data synchronization method

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101702732A (en) * 2009-09-23 2010-05-05 中兴通讯股份有限公司 Document synchronous method and document synchronous system
CN104753973B (en) * 2013-12-25 2016-06-08 珠海金山办公软件有限公司 A kind of document sharing browsing method and system
CN106933967B (en) * 2017-02-09 2022-12-20 宇龙计算机通信科技(深圳)有限公司 Batch modification method and device for file contents

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101855629A (en) * 2007-11-09 2010-10-06 微软公司 Collaborative authoring
CN102857570A (en) * 2012-09-13 2013-01-02 清华大学 Cloud synchronized method of files and cloud storage server
CN103902663A (en) * 2014-03-10 2014-07-02 联想(北京)有限公司 File synchronization method and device
CN104488248A (en) * 2014-04-15 2015-04-01 华为技术有限公司 File synchronization method, server and terminal
CN105827699A (en) * 2016-03-16 2016-08-03 心动网络股份有限公司 Data synchronization method

Also Published As

Publication number Publication date
CN109688176A (en) 2019-04-26

Similar Documents

Publication Publication Date Title
CN107294729B (en) Communication method and device between different nodes in block chain
US11086825B2 (en) Telemetry system for a cloud synchronization system
CN109522330B (en) Cloud platform data processing method, device, equipment and medium based on block chain
EP3075177B1 (en) Method, apparatus and device for exchanging name card
WO2019075978A1 (en) Data transmission method and apparatus, computer device, and storage medium
KR20160046649A (en) Method for synchronizing file
US9594820B2 (en) Apparatus, and associated method, for synchronizing a group of data objects
CN106713127B (en) Method and device for acquiring and processing instant chat records
WO2017097106A1 (en) Method and apparatus for transmitting file difference
CN103945259A (en) Online video playing method and device
CN109688176B (en) File synchronization method, terminal, network device and storage medium
CN103929453A (en) Processing method, device and system for data uploading
US20180302404A1 (en) Method for processing data request and system therefor, access device, and storage device
CN103905201A (en) Interaction method and device for master application and multiple slave applications
CN106293996B (en) Method of data synchronization, main equipment, alternate device and system
CN115242783B (en) Transmission method, transmission apparatus, electronic device, and medium
CN109739653A (en) Previewing file method, document handling method and device
CN114338653A (en) File breakpoint resuming method and device
CN107332679B (en) Centerless information synchronization method and device
CN106487650B (en) Message synchronization method and server
CN105610951B (en) Method for synchronizing data between devices and electronic device
CN117112508B (en) File synchronization method and device based on serial numbers, computer equipment and storage medium
KR20130024221A (en) Method of restoring file and system for the same
KR20160134909A (en) Communication apparatus, virtual file system module comprised in the communication apparatus, control method thereof, and recording medium for recording program for executing the control method, application saved in the recording medium for executing the control method being combined with hardware
CN113094311A (en) Data processing method and data processing device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant