A file updating method, device, terminal device and storage medium

By dividing the file into blocks and calculating the differences, only the differences are transmitted and updated, thus solving the problem of high system performance consumption caused by large file updates and improving the user experience.

CN118467474BActive Publication Date: 2026-07-10ZHUHAI KINGSOFT ONLINE GAME TECH CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
ZHUHAI KINGSOFT ONLINE GAME TECH CO LTD
Filing Date
2024-05-17
Publication Date
2026-07-10

AI Technical Summary

Technical Problem

During file updates, especially with large files or in high-concurrency environments, existing technologies may consume a lot of system resources, leading to decreased system performance and a poor user experience.

Method used

By dividing the file into blocks, calculating the differences between the files, and only transmitting and updating the differences, the file location and difference information are determined using hash values, and file update information is generated.

Benefits of technology

It improves the efficiency of file updates, reduces the negative impact on system performance, and enhances the user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118467474B_ABST
    Figure CN118467474B_ABST
Patent Text Reader

Abstract

This application proposes a method, apparatus, terminal device, and storage medium for file updating. The method includes obtaining a file update request; obtaining a file to be updated based on the file update request; searching for the file to be updated in file update information to obtain target difference information of the file to be updated, and then updating the file based on the target difference information. The method for generating file update information includes obtaining a target file and multiple first block files, wherein the target file is obtained based on the file window corresponding to the first file and the target window position, the first block files are obtained by dividing a second file into blocks, and the second file is the modified version of the first file; obtaining initial difference information between the first file and the second file based on the target file and the multiple first block files; and storing the first file, the second file, and the initial difference information to obtain file update information. This method can improve the efficiency of file updating.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a method, apparatus, terminal device, and storage medium for updating files. Background Technology

[0002] With the development of internet technology, the update frequency of various applications or installation packages is constantly accelerating. When users install or update them, the related technologies usually involve the transfer or replacement of the entire file. When the file is a large file or the file update environment is in a high-concurrency environment, the update process may affect the system performance. The update operation may consume a lot of system resources, resulting in a slow or unstable system response, which affects the user's file update experience. Summary of the Invention

[0003] This application aims to address at least one of the technical problems existing in the prior art. To this end, this application proposes a method, apparatus, terminal device, and storage medium for file updating, which can improve the efficiency of file updating, reduce the negative impact on system performance during the file updating process, and thus further improve the user experience.

[0004] In a first aspect, embodiments of this application provide a method for updating files, applied to a server, the method comprising:

[0005] Obtain the file update request sent by the client;

[0006] Obtain the corresponding file to be updated based on the file update request;

[0007] Based on the file to be updated, search the file update information to obtain the target difference information corresponding to the file to be updated;

[0008] The target difference information is sent to the client so that the client can update the file based on the target difference information;

[0009] The method for generating the file update information includes:

[0010] Obtain a target file and multiple first block files. The target file is obtained based on the file window and target window position corresponding to the first file. The first block files are obtained by dividing a second file into blocks. The second file is the modified version of the first file.

[0011] Initial difference information between the first file and the second file is obtained based on the target file and multiple first block files;

[0012] The first file, the second file, and the initial difference information are stored to obtain the file update information.

[0013] In some optional embodiments, obtaining the initial difference information between the first file and the second file based on the target file and a plurality of first block files includes:

[0014] Perform a first hash process on each of the multiple first block files to obtain a first hash value and a second hash value corresponding to each first block file;

[0015] The target file is subjected to a second hash process to obtain the third and fourth hash values ​​corresponding to the target file;

[0016] The target location of the target file in the second file is determined based on the first hash value, the second hash value, the third hash value, and the fourth hash value;

[0017] The initial difference information between the first file and the second file is obtained based on the target location and the target window location.

[0018] In some optional embodiments, determining the target location of the target file in the second file based on the first hash value, the second hash value, the third hash value, and the fourth hash value includes:

[0019] Establish a mapping relationship between the first block file, the first hash value, and the second hash value to obtain the block index data;

[0020] The third hash value and the fourth hash value are searched in the block index data to obtain the search result corresponding to the target file;

[0021] The target location of the target file in the second file is determined based on the search results.

[0022] In some optional embodiments, the step of searching the third hash value and the fourth hash value in the block index data to obtain the search result corresponding to the target file includes:

[0023] The third hash value is searched in the block index data to obtain the first result;

[0024] If the first result indicates that the first hash value and the third hash value are equal in the block index data, the fourth hash value and the second hash value are compared to obtain a comparison result;

[0025] If the comparison result shows that the fourth hash value and the second hash value are equal, the search result is determined to be a successful search.

[0026] If the first result is that the first hash value and the third hash value do not exist in the block index data, or if the comparison result is that the fourth hash value and the second hash value are not equal, then the search result is determined to be a search failure.

[0027] In some optional embodiments, determining the target location of the target file in the second file based on the search result includes:

[0028] If the search result indicates a successful search, the file identifier of the first block file corresponding to the second hash value is obtained;

[0029] The target location of the target file in the second file is determined based on the file identifier;

[0030] The target window position is moved according to a preset step size to obtain the moved target window position, and the target file is updated according to the moved target window position and the file window to obtain the updated target file;

[0031] Calculate the fifth and sixth hash values ​​corresponding to the updated target file, and find the target position of the updated target file in the second file based on the fifth and sixth hash values, until the target window position is the same as the preset position.

[0032] In some optional embodiments, the target file is obtained based on the file window corresponding to the first file and the target window position, including:

[0033] Determine the segment length, and divide the first file into multiple sub-files according to the segment length, wherein any two adjacent sub-files have overlapping beginning and end portions;

[0034] The sub-window position corresponding to the sub-file is determined based on the segment length, wherein the target window position includes multiple sub-window positions;

[0035] The window file corresponding to the sub-file is determined based on the sub-window position and the file window, wherein the target file includes multiple window files.

[0036] In some optional embodiments, calculating the third hash value and the fifth hash value includes:

[0037] The content corresponding to the target file is converted into an integer value, and the integer values ​​corresponding to the target file are summed to obtain a first value;

[0038] Set a second value, and sequentially execute the following steps: obtain the index position of the integer value in the target file, add the integer value between the initial position and the index position in the target file to obtain a first addition result, add the first addition result and the second value to obtain a second addition result, and update the second value with the second addition result. The third hash value includes the first value and the second value.

[0039] Subtract the third value corresponding to the initial position of the target file from the first value, and add the fourth value corresponding to the updated end position of the target file to obtain the fifth value;

[0040] The product of the index length corresponding to the target file and the third value is obtained to get the product result. The first value is then subtracted from the product result and summed with the fifth value to obtain a sixth value. The fifth hash value includes both the fifth and sixth values.

[0041] In some optional embodiments, the target location includes the file identifier, and obtaining the initial difference information between the first file and the second file based on the target location and the target window position corresponding to the target file includes:

[0042] Obtain any two file identifiers and determine them as a first identifier and a second identifier, and calculate the difference between the first identifier and the second identifier;

[0043] If the difference is equal to the preset value, the first identifier and the second identifier are stored according to their numerical values ​​to obtain an identifier combination, and a first set is determined based on all the identifier combinations.

[0044] Two identifier combinations are randomly obtained from the first set. If any two identifier combinations have the same identifier, the two identifier combinations are merged to obtain a merge result. The two identifier combinations are removed from the first set, and the merge result is updated to the first set until no two identifier combinations in the first set have the same identifier.

[0045] Obtain any of the identifier combinations in the first set, and obtain the first window position corresponding to the identifier combination from the target window position;

[0046] The first difference information is determined based on the first set and the first window position;

[0047] If the difference is not equal to the preset value, the first identifier and the second identifier are stored to obtain a second set;

[0048] Obtain the second window position corresponding to each identifier in the second set from the target window position;

[0049] The second difference information is determined based on the second set and the second window position;

[0050] The initial difference information is determined based on the first difference information and the second difference information.

[0051] In some optional embodiments, the method further includes:

[0052] Obtain the first attribute information corresponding to the first file and the second attribute information corresponding to the second file;

[0053] Perform attribute hashing on the first attribute value to obtain a first attribute hash value, and perform attribute hashing on the second attribute value to obtain a second attribute hash value;

[0054] Determine the target mapping table, and determine the first attribute hash value as the first key value corresponding to the target mapping table and the second attribute hash value as the second key value corresponding to the target mapping table;

[0055] The first mapping value corresponding to the first key value is determined based on the target file and the third hash value and the fourth hash value corresponding to the target file;

[0056] The second mapping value corresponding to the second key value is determined based on the first block file and the first hash value and the second hash value corresponding to the first block file.

[0057] Secondly, embodiments of this application provide a file updating apparatus, applied to a server, comprising:

[0058] The request acquisition module is configured to acquire file update requests sent by the client.

[0059] The data parsing module is configured to obtain the corresponding file to be updated based on the file update request;

[0060] The data search module is configured to search for the file to be updated in the file update information to obtain the target difference information corresponding to the file to be updated. The method for generating the file update information includes: acquiring a target file and multiple first block files, wherein the target file is obtained based on the file window and target window position corresponding to the first file, the first block files are obtained by dividing a second file into blocks, and the second file is the modified version of the first file; obtaining initial difference information between the first file and the second file based on the target file and the multiple first block files; and storing the first file, the second file, and the initial difference information to obtain the file update information.

[0061] The data sending module is configured to send the target difference information to the client so that the client can update the file based on the target difference information.

[0062] In some optional embodiments, the data lookup module is further configured to:

[0063] The first processing module is configured to perform a first hash process on each of the multiple first block files to obtain a first hash value and a second hash value corresponding to each first block file;

[0064] The second processing module is configured to perform a second hash processing on the target file to obtain a third hash value and a fourth hash value corresponding to the target file.

[0065] The data comparison module is configured to determine the target location of the target file in the second file based on the first hash value, the second hash value, the third hash value, and the fourth hash value;

[0066] The difference calculation module is configured to obtain the initial difference information between the first file and the second file based on the target location and the target window location.

[0067] In some optional embodiments, the data comparison module is further configured to:

[0068] The index building module is configured to establish a mapping relationship between the first block file, the first hash value, and the second hash value to obtain block index data;

[0069] The index lookup module is configured to search for the third hash value and the fourth hash value in the block index data to obtain the search result corresponding to the target file;

[0070] The location determination module is configured to determine the target location of the target file in the second file based on the search result.

[0071] In some optional embodiments, the index lookup module is further configured to:

[0072] The first search module is configured to search for the third hash value in the block index data to obtain a first result;

[0073] The first comparison module is configured to compare the fourth hash value and the second hash value to obtain a comparison result if the first result indicates that the first hash value and the third hash value are equal in the block index data.

[0074] The second comparison module is configured to determine that the search result is successful if the comparison result is that the fourth hash value and the second hash value are equal.

[0075] The third comparison module is configured to determine that the search result is a search failure if the first result is that the first hash value and the third hash value do not exist in the block index data, or if the comparison result is that the fourth hash value and the second hash value are not equal.

[0076] In some optional embodiments, the location determination module is further configured to:

[0077] The first search and analysis module is configured to obtain the file identifier of the first block file corresponding to the second hash value if the search result indicates that the search is successful.

[0078] The first determining module is configured to determine the target location of the target file in the second file based on the file identifier;

[0079] The first search and analysis module is configured to move the target window position according to a preset step size to obtain the moved target window position, and update the target file according to the moved target window position and the file window to obtain the updated target file;

[0080] The second determining module is configured to calculate the fifth hash value and the sixth hash value corresponding to the updated target file, and find the target position of the updated target file in the second file according to the fifth hash value and the sixth hash value, until the target window position is the same as the preset position.

[0081] In some optional embodiments, the data lookup module is further configured to:

[0082] The data segmentation module is configured to determine the segment length and segment the first file into multiple sub-files according to the segment length, wherein any two adjacent sub-files have overlapping beginning and end portions.

[0083] The window position determination module is configured to determine the position of the sub-window corresponding to the sub-file based on the segment length, wherein the target window position includes multiple sub-window positions;

[0084] The file determination module is configured to determine the window file corresponding to the sub-file based on the sub-window position and the file window, wherein the target file includes multiple window files.

[0085] In some optional embodiments, the file updating apparatus is further configured to:

[0086] The data conversion module is configured to convert the content corresponding to the target file into an integer value, and sum the integer values ​​corresponding to the target file to obtain a first value;

[0087] The first data processing module is configured to set a second value, and sequentially execute the following steps: obtain the index position of the integer value in the target file, add the integer value between the initial position and the index position in the target file to obtain a first addition result, add the first addition result and the second value to obtain a second addition result, and update the second addition result to the second value. The third hash value includes the first value and the second value.

[0088] The second data processing module is configured to subtract the third value corresponding to the initial position of the target file from the first value, and add the fourth value corresponding to the updated end position of the target file to obtain the fifth value;

[0089] The third data processing module is configured to obtain the product between the index length corresponding to the target file and the third value, and then subtract the product from the first value and sum it with the fifth value to obtain a sixth value. The fifth hash value includes both the fifth and sixth values.

[0090] In some optional embodiments, the difference calculation module is further configured to:

[0091] The difference calculation module is configured to obtain any two file identifiers as a first identifier and a second identifier, and calculate the difference between the first identifier and the second identifier;

[0092] The first set module is configured to, if the difference is equal to a preset value, store the first identifier and the second identifier according to their numerical values ​​to obtain an identifier combination, and determine the first set according to all the identifier combinations;

[0093] The data fusion module is configured to obtain any two of the identifier combinations from the first set, and if any two of the identifier combinations have the same identifier, merge the two identifier combinations to obtain a fusion result, remove any two of the identifier combinations from the first set, and update the fusion result to the first set, until no two of the identifier combinations in the first set have the same identifier.

[0094] The first window position acquisition module is configured to obtain any of the identifier combinations in the first set, and obtain the first window position corresponding to the identifier combination from the target window position;

[0095] The first difference determination module is configured to determine first difference information based on the first set and the first window position;

[0096] The second set module is configured to store the first identifier and the second identifier to obtain a second set if the difference is not equal to the preset value;

[0097] The second window position acquisition module is configured to obtain the second window position corresponding to each identifier in the second set from the target window position;

[0098] The second difference determination module is configured to determine second difference information based on the second set and the second window position;

[0099] The initial difference determination module is configured to determine the initial difference information based on the first difference information and the second difference information.

[0100] In some optional embodiments, the file updating apparatus is further configured to:

[0101] The attribute acquisition module is configured to obtain the first attribute information corresponding to the first file and the second attribute information corresponding to the second file;

[0102] The attribute processing module is configured to perform attribute hashing on the first attribute value to obtain a first attribute hash value and to perform attribute hashing on the second attribute value to obtain a second attribute hash value;

[0103] The key value determination module is configured to determine the target mapping table, determine the first attribute hash value as the first key value corresponding to the target mapping table, and determine the second attribute hash value as the second key value corresponding to the target mapping table;

[0104] The first mapping determination module is configured to determine the first mapping value corresponding to the first key value based on the target file and the third hash value and the fourth hash value corresponding to the target file;

[0105] The second mapping determination module is configured to determine the second mapping value corresponding to the second key value based on the first block file and the first hash value and the second hash value corresponding to the first block file.

[0106] Thirdly, embodiments of this application provide a method for updating files, applied to a client, the method comprising:

[0107] Identify the file to be updated, and determine the file update request based on the file to be updated;

[0108] Send the file update request to the server so that the server can find the corresponding file to be updated in the file update information according to the file update request and obtain the target difference information corresponding to the file to be updated;

[0109] Receive the target difference information sent by the server, and update the file to be updated according to the target difference information;

[0110] The method for generating the file update information in the server includes:

[0111] The server obtains a target file and multiple first block files. The target file is obtained based on the file window corresponding to the first file and the target window position. The first block files are obtained by dividing a second file into blocks. The second file is the modified version of the first file.

[0112] The server obtains initial difference information between the first file and the second file based on the target file and multiple first block files;

[0113] The server stores the first file, the second file, and the initial difference information to obtain the file update information.

[0114] In some optional embodiments, updating the file to be updated based on the target difference information includes:

[0115] The target download content corresponding to the file to be updated is determined based on the target difference information.

[0116] Based on the target download content, the file is downloaded from the server to obtain the download result corresponding to the target download content;

[0117] The file to be updated is updated based on the download results.

[0118] Fourthly, embodiments of this application provide a file updating apparatus, applied to a client, comprising:

[0119] The data request module is configured to determine the file to be updated and, based on the file to be updated, determine a file update request;

[0120] The result acquisition module is configured to send the file update request to the server, so that the server obtains the corresponding file to be updated based on the file update request and searches in the file update information to obtain the target difference information corresponding to the file to be updated; wherein, the method for generating the file update information in the server includes: the server obtains a target file and multiple first block files, the target file is obtained according to the file window and target window position corresponding to the first file, the first block files are obtained by dividing a second file into blocks, and the second file is the file after the first file has changed; the server obtains the initial difference information between the first file and the second file based on the target file and the multiple first block files; the server stores the first file, the second file and the initial difference information to obtain the file update information;

[0121] The data update module is configured to receive the target difference information sent by the server and update the file to be updated according to the target difference information.

[0122] In some optional embodiments, the result acquisition module is further configured to:

[0123] The content determination module is configured to determine the target download content corresponding to the file to be updated based on the target difference information.

[0124] The content download module is configured to download files from the server based on the target download content and obtain the download result corresponding to the target download content;

[0125] The file update module is configured to update the file to be updated based on the download results.

[0126] Fifthly, embodiments of this application provide a terminal device, including at least one control processor and a memory for communicatively connecting to the at least one control processor; the memory stores instructions executable by the at least one control processor, which, when executed by the at least one control processor, enable the at least one control processor to perform the file update method as described in the first aspect and the file update method as described in the third aspect.

[0127] In a sixth aspect, embodiments of this application provide a computer-readable storage medium storing computer-executable instructions for performing the file update method as described in the first aspect and the file update method as described in the third aspect.

[0128] The file update method according to the embodiments of this application has at least the following beneficial effects: A file update request is received from a client and sent to a server; the server then parses the file update request to obtain the file to be updated corresponding to the client; the server searches the file update information based on the file to be updated to obtain the target difference information corresponding to the file to be updated; the server then encapsulates the target difference information and sends it to the client so that the client can update the file based on the target difference information; wherein, the method for generating file update information includes: obtaining a target file and multiple first block files, wherein the target file is obtained based on the file window corresponding to the first file and the target window position; the first block files are obtained by dividing a second file into blocks; the second file is the file after the first file has changed; initial difference information between the first file and the second file is obtained based on the target file and the multiple first block files; and the first file, the second file, and the initial difference information are stored to obtain file update information. Therefore, in this application, after the server receives a file update request, parses it to obtain the file to be updated corresponding to the client, and then searches for the file update information based on the file to be updated, it can obtain the target difference information corresponding to the file to be updated. Upon receiving the target difference information, the client can determine the missing information content based on the target difference information and download only the missing information content. Furthermore, this application pre-calculates the initial difference information of the first and second files before and after the change on the server, and records the reusable information before the change in the initial difference information to form the file update information. Thus, the client can quickly find the target difference information corresponding to the file to be updated in the file update information, and download only the changed information, merging it with the locally existing information to generate the target update file corresponding to the file to be updated. This saves download traffic and download time throughout the entire process, and also solves the problem in related technologies where the transmission or replacement of the entire file usually involves the potential impact on system performance during the update process, and the update operation may consume a lot of system resources, resulting in slow or unstable system response and affecting the user's file update experience. Attached Figure Description

[0129] Figure 1 A flowchart illustrating a file update method provided in an embodiment of the present invention;

[0130] Figure 2 A flowchart illustrating a method for generating file update information according to an embodiment of the present invention;

[0131] Figure 3 A flowchart illustrating step S62 of a method for generating file update information provided in an embodiment of the present invention;

[0132] Figure 4A schematic diagram of the module structure of a file updating device provided in an embodiment of the present invention;

[0133] Figure 5 A flowchart illustrating another file update method provided in an embodiment of the present invention;

[0134] Figure 6 A schematic diagram of the module structure of another file updating device provided in an embodiment of the present invention;

[0135] Figure 7 This is a schematic block diagram of a terminal device provided in an embodiment of the present invention. Detailed Implementation

[0136] The embodiments of this application are described in detail below. Examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain this application, and should not be construed as limiting this application.

[0137] In the description of this application, it should be understood that the orientation descriptions, such as up, down, front, back, left, right, etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are only for the convenience of describing this application and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on this application.

[0138] In the description of this application, "several" means one or more, "more than" means two or more, "greater than," "less than," and "exceeding" are understood to exclude the stated number, while "above," "below," and "within" are understood to include the stated number. The use of "first" and "second" in the description is merely for distinguishing technical features and should not be construed as indicating or implying relative importance, or implicitly indicating the number of indicated technical features, or implicitly indicating the order of the indicated technical features.

[0139] In the description of this application, unless otherwise expressly defined, terms such as "setup," "installation," and "connection" should be interpreted broadly, and those skilled in the art can reasonably determine the specific meaning of the above terms in this application in conjunction with the specific content of the technical solution.

[0140] To ensure clarity and conciseness in the description of the following embodiments, a brief introduction to the related technologies is given first:

[0141] With the development of internet technology, the update frequency of various applications or installation packages is constantly accelerating. When users install or update them, the related technologies usually involve the transfer or replacement of the entire file. When the file is a large file or the file update environment is in a high-concurrency environment, the update process may affect the system performance. Moreover, the update operation may consume a lot of system resources, resulting in a slow or unstable system response, which affects the user's file update experience.

[0142] As can be seen from the above description of the existing technology, the existing technology usually involves the transfer or replacement of the entire file, which may affect the performance of the system during the file update process. Moreover, the update operation may consume a lot of system resources, resulting in slow system response or instability, which affects the user's experience of file update.

[0143] In view of the problems in the prior art, file updates may affect system performance and consume a lot of system resources, resulting in slow or unstable system response and affecting the user's file update experience. This application provides a method, apparatus, terminal device and storage medium for file updates.

[0144] This application provides a method, apparatus, terminal device, and storage medium for updating files, which will be described in detail in the following embodiments.

[0145] Reference Figure 1 , Figure 1 This is a flowchart illustrating a file update method provided in an embodiment of this application. The file update method includes, but is not limited to, the following steps:

[0146] Step S11: Obtain the file update request sent by the client.

[0147] For example, the client constructs an HTTP request, including a request method, request headers, and a request body. The request body includes the name or related information of the file to be updated, thus generating a file update request. The client then uses network programming or an HTTP library to send the constructed HTTP request to the server. The server then receives the file update request sent by the client.

[0148] It should be noted that the file update request sent by the client to the server can be an HTTP request or a other wireless communication request. This application does not impose specific restrictions, and users can choose according to their actual needs.

[0149] Step S12: Obtain the corresponding file to be updated according to the file update request.

[0150] For example, after receiving a file update request, the server parses the file update request to obtain the file to be updated contained in the file update request. The file to be updated contains the name information of the existing file on the client and the name information or version information of the file that needs to be updated.

[0151] Step S13: Search the file update information according to the file to be updated to obtain the target difference information corresponding to the file to be updated.

[0152] For example, the file update information represents a mapping table or index structure based on the file name or file attribute and the initial difference information corresponding to that file name or file attribute. The file to be updated is then searched within the file update information. If the file to be updated matches a file name or file attribute in the file update information, the initial difference information corresponding to that file name or file attribute is determined as the target difference information for that file to be updated.

[0153] For example, file update information can be obtained before the server receives the file update request, or it can be added after the file update request is received.

[0154] Among them, such as Figure 2 As shown, the method for generating the file update information includes steps S61 to S63:

[0155] Step S61: Obtain the target file and multiple first block files. The target file is obtained based on the file window and target window position corresponding to the first file. The first block files are obtained by dividing the second file into blocks. The second file is the file after the first file has been modified.

[0156] For example, after obtaining the first file, if the developer or user modifies or improves the first file to obtain the second file, the server will divide the first file into blocks to obtain multiple first block files.

[0157] For example, the server physically divides the modified second file into blocks of fixed block length, resulting in multiple first block files. For instance, if the fixed block length is 4, then when the length of the second file is 20, dividing the second file into blocks of fixed block length 4 will result in 5 first block files.

[0158] It should be noted that this application does not impose restrictions on the segmentation method of the second file or the fixed block length; users can choose according to their actual needs.

[0159] For example, in order to determine which part of the content in the first file exists in the second file, thereby providing support for the optimization of subsequent file updates, this application performs sliding window processing on the first file. The file window corresponding to the first file is determined according to the fixed block length determined when the second file is processed into blocks. That is, the size of the file window is set to be the same as the fixed block length, thereby providing support for the subsequent comparison and analysis of the target file corresponding to the file window and the first block file.

[0160] For example, when performing sliding window processing on the first file, it is necessary to determine the target window position corresponding to the file window at the same time as determining the file window, that is, the position information of the file window in the first file. It can be the start position, end position or middle position of the file window. This application does not impose any restrictions on the specifics, and users can choose according to their actual needs.

[0161] For example, if the target window position corresponding to the file window is the starting position, then when the length of the first file is 10, the file window size is 4. Therefore, the target window position can be 0, 1, 2, 3, 4, 5, or 6. That is, when the target window position is 6, the target file obtained from the file window is the content corresponding to positions 6-9 in the first file. In other words, at this point, all the content in the first file has been analyzed in relation to the second file. Therefore, the target window position is any position from the beginning to the end of the first file minus the file window size.

[0162] Step S62: Obtain initial difference information between the first file and the second file based on the target file and multiple first block files.

[0163] For example, code needs to be written to read the contents of a target file and multiple first-part files, and then use a file comparison algorithm (e.g., line-based comparison or content-based comparison) to compare the target file and the first-part files, identify the differences between them, and thus obtain initial difference information between the first and second files. This initial difference information includes the location and content of the differences between the first and second files.

[0164] Step S63: Store the first file, the second file, and the initial difference information to obtain the file update information.

[0165] For example, the file name or file attributes corresponding to the first file and the file name or file attributes corresponding to the second file are obtained. Then, the file name or file attributes corresponding to the first file and the file name or file attributes corresponding to the second file are merged to determine the key of the mapping table. Then, the initial difference information is determined as the value corresponding to the key, and then the file update information is obtained.

[0166] In addition, after obtaining the file name or file attributes corresponding to the first file and the file name or file attributes corresponding to the second file, the file name or file attributes corresponding to the first file and the file name or file attributes corresponding to the second file can be merged, and the merged result can be determined as the storage name corresponding to the initial difference information, thereby obtaining the file update information.

[0167] In some implementations, such as Figure 3 As shown, step S62 includes sub-steps S621 to S624.

[0168] Sub-step S621: Perform a first hash process on each of the multiple first block files to obtain a first hash value and a second hash value corresponding to each first block file.

[0169] For example, the first hashing process involves performing a weak hash on each first block of the file to obtain a first hash value, and then performing a strong hash on each block to obtain a second hash value. A weak hash typically refers to a hash function that lacks high security or collision resistance, such as CRC32 (Cyclic Redundancy Check) or MD5 (Message Digest Algorithm 5). The first hash value obtained from a weak hash may collide, meaning two different first block files may have the same first hash value. A strong hash refers to a hash function with high security and collision resistance. Such hash functions are commonly used in cryptography for scenarios requiring high security, such as data integrity verification and password storage. Typical strong hash functions include SHA-256 (Secure Hash Algorithm 256-bit) and SHA-3. The second hash value obtained from a strong hash is less likely to collide, meaning two different first block files are unlikely to have the same second hash value.

[0170] For example, users can choose appropriate hash function libraries and algorithms according to their needs, such as using the SHA-256 algorithm in the `hashlib` library to perform strong hash calculation to obtain the second hash value corresponding to the first block file, and using the CRC32 algorithm to perform weak hash calculation to obtain the first hash value corresponding to the first block file.

[0171] It should be noted that this application does not impose specific restrictions on the methods for obtaining the first hash value and the second hash value, and users can choose according to their actual needs.

[0172] Sub-step S622: Perform a second hash process on the target file to obtain the third hash value and the fourth hash value corresponding to the target file.

[0173] For example, the second hashing process involves performing a weak hashing process on the target file to obtain a third hash value and a strong hashing process to obtain a fourth hash value. Alternatively, the second hashing process can involve first performing a weak hashing process on the target file to obtain a third hash value, and then determining whether a strong hashing process is needed to obtain a fourth hash value based on actual usage requirements.

[0174] For example, when the second hashing process involves first performing a weak hashing process on the target file to obtain a third hash value, and then determining whether a strong hashing process is needed to obtain a fourth hash value based on actual usage requirements, a virtual value can be set for the fourth hash value after obtaining the third hash value. Furthermore, when using the fourth hash value, the virtual value can be used to determine the actual fourth hash value corresponding to the target file that needs to be calculated.

[0175] For example, the virtual value corresponding to the fourth hash value can be None. Then, when using the fourth hash value, if the fourth hash value is None, the actual fourth hash value corresponding to the target file is calculated.

[0176] For example, the method for obtaining the third hash value is the same as the method for obtaining the first hash value, and the method for obtaining the fourth hash value is the same as the method for obtaining the second hash value. Please refer to the above for details, which will not be repeated here.

[0177] Sub-step S623: Determine the target location of the target file in the second file based on the first hash value, the second hash value, the third hash value, and the fourth hash value.

[0178] For example, it is determined whether the first hash value and the third hash value are equal. If the first hash value and the third hash value are equal, then it is determined whether the second hash value and the fourth hash value are equal. If the second hash value and the fourth hash value are equal, then the block position of the first block file corresponding to the third hash value and the fourth hash value in the second file is determined as the target position. The block position is the sequential value of the first block file after being processed into blocks in the second file.

[0179] For example, when the first hash value and the third hash value are not equal, or the second hash value and the fourth hash value are not equal, the target window position is moved to update the target file, and then the updated target file is reprocessed with the first hash to obtain the updated first hash value and the second hash value, until the target position of the target file in the second file is determined.

[0180] In some optional embodiments, determining the target location of the target file in the second file based on the first hash value, the second hash value, the third hash value, and the fourth hash value includes: establishing a mapping relationship between the first block file and the first hash value and the second hash value to obtain block index data; searching for the third hash value and the fourth hash value in the block index data to obtain the search result corresponding to the target file; and determining the target location of the target file in the second file based on the search result.

[0181] For example, a first hash value is used as the key and a first block file is used as the value to obtain first index data, and a second hash value is used as the key and a first block file is used as the value to obtain second index data, thereby determining block index data based on the first index data and the second index data.

[0182] In addition, it should be noted that the first hash value corresponding to the first block file may be the same. Therefore, when there are multiple first block files with the same first hash value, all of the multiple first block files corresponding to the first hash value will be used as the value corresponding to the first hash value as the key.

[0183] For example, if the first hash value corresponding to the first block file 1 is 'a', and the first hash value corresponding to the first block file 2 is also 'a', then when the first hash value 'a' is used as the key, both the first block file 1 and the first block file 2 are its corresponding values.

[0184] For example, the third hash value is used as the key to search in the first index data of the block index data to obtain a first search result, and the fourth hash value is used as the key to search in the second index data of the block index data to obtain a second search result. The intersection of the first and second search results is then calculated. If the intersection is not empty, the block position corresponding to the first block file corresponding to the intersection result is determined as the target position of the target file in the second file. If the intersection is empty, it indicates that the target file does not exist in the second file.

[0185] Specifically, mapping the first file block to its corresponding first and second hash values ​​effectively associates file blocks with their hash values. This mapping facilitates rapid location of file blocks during subsequent searches. Using the third and fourth hash values ​​to search within the block index data allows for quick location of the file block index corresponding to the target file. This process is similar to performing an index lookup in a database, enabling efficient target location within large amounts of data. Therefore, by establishing a mapping relationship, the target location can be quickly located within large amounts of data, improving retrieval efficiency.

[0186] In some implementations, the step of searching the third hash value and the fourth hash value in the block index data to obtain the search result corresponding to the target file includes: searching the third hash value in the block index data to obtain a first result; if the first result indicates that the first hash value and the third hash value exist in the block index data and are equal, comparing the fourth hash value and the second hash value to obtain a comparison result; if the comparison result indicates that the fourth hash value and the second hash value are equal, determining that the search result is a successful search; if the first result indicates that the first hash value and the third hash value do not exist in the block index data or the comparison result indicates that the fourth hash value and the second hash value are not equal, determining that the search result is a failed search.

[0187] For example, when creating block index data, the first hash value can be used as the key, and the first block file and the second hash value can be used as the value to establish a mapping relationship to obtain the block index data.

[0188] In addition, it should be noted that the first hash value corresponding to the first block file may be the same. Therefore, when there are multiple first block files with the same first hash value, the second hash values ​​corresponding to the multiple first block files and the multiple first block files respectively are all used as the values ​​corresponding to the first hash value as the key.

[0189] For example, if the first hash value of the first block file 1 is a and the second hash value is b1, and the first hash value of the first block file 2 is a and the second hash value is b2, then when the first hash value a is used as the key, the first block file 1 and the second hash value b1 corresponding to the first block file 1, and the first block file 2 and the second hash value b2 corresponding to the first block file 2 are all its corresponding values.

[0190] For example, the third hash value is searched in the block index data to obtain a first result. If the first result indicates that the first hash value and the third hash value are equal in the block index data, that is, a first hash value equal to the third hash value is found in the block index data, the fourth hash value is then compared with the second hash value to obtain a comparison result. If the comparison result shows that the fourth hash value and the second hash value are equal, the search result is determined to be successful; if the first result indicates that the first hash value and the third hash value are not equal in the block index data, or if the comparison result shows that the fourth hash value and the second hash value are not equal, the search result is determined to be unsuccessful.

[0191] It should be noted that when comparing the fourth hash value and the second hash value, if the fourth hash value is a virtual value when the target file is processed by the second hash, it is necessary to obtain the real fourth hash value corresponding to the target file before comparing the fourth hash value and the second hash value.

[0192] Specifically, searching for the third hash value in the block index data speeds up the search process. Checking the match between the first and third hash values ​​in the first result, and comparing the fourth and second hash values, ensures the consistency between the searched data block and the target data block, thereby ensuring data integrity and correctness. Furthermore, through multiple comparisons and judgments, the accuracy and reliability of the search are improved, avoiding misjudgments or incorrect matches. Moreover, this complex verification and comparison process helps optimize data management, improves control and management capabilities over stored data, and enhances the reliability and security of the search results.

[0193] In some implementations, determining the target position of the target file in the second file based on the search result includes: if the search result indicates a successful search, obtaining the file identifier of the first block file corresponding to the second hash value; determining the target position of the target file in the second file based on the file identifier; moving the target window position according to a preset step size to obtain the moved target window position, and updating the target file based on the moved target window position and the file window to obtain the updated target file; calculating the fifth hash value and the sixth hash value corresponding to the updated target file, and searching for the target position of the updated target file in the second file based on the fifth hash value and the sixth hash value, until the target window position is the same as the preset position.

[0194] For example, after searching the third and fourth hash values ​​in the block index data to obtain the search results corresponding to the target file, if the search result is successful, it indicates that the target file has found the corresponding content in the second file, and then the file identifier of the first block file corresponding to the second hash value is obtained. The file identifier can indicate the position of the first block file in the second file. For example, the file identifier can be the block number corresponding to the first block file after the second file is processed into blocks.

[0195] For example, after obtaining the file identifier corresponding to the first block file, the file identifier is determined as the target location of the target file in the second file.

[0196] For example, if the search result is "search failed", it means that the target file was not found in the second file, that is, the target file does not exist in the second file.

[0197] For example, regardless of whether the search result is successful or unsuccessful, the target window position is moved according to a preset step size to obtain the new target window position. The preset step size can be the smallest unit corresponding to the first file. Then, the corresponding content in the first file is determined based on the new target window position and the file window, and the content is updated to the target file to obtain the updated target file.

[0198] For example, the fifth hash value and the sixth hash value corresponding to the updated target file are calculated, and then the search is continued in the block index data based on the fifth hash value and the sixth hash value to find the target position of the updated target file in the second file, until the target window position is the same as the preset position, which is the position corresponding to the end position of the first file minus the size of the file window.

[0199] For example, the target window position is moved according to a preset step size to obtain the moved target window position. Then, based on the moved target window position and the file window, all file contents in the first file can be compared with the contents in the second file, thereby finding all target positions of the contents in the first file in the second file, providing support for subsequent downloads and updates.

[0200] Specifically, by determining the target location, the position of the target file in the second file can be accurately located, and the corresponding move and update operations can ensure the accuracy and completeness of the analysis of the first file.

[0201] In some implementations, obtaining the target file based on the file window corresponding to the first file and the target window position includes: determining a segment length; dividing the first file into multiple sub-files based on the segment length, wherein any two adjacent sub-files have overlapping beginning and end portions; determining the sub-window position corresponding to the sub-file based on the segment length, wherein the target window position includes multiple sub-window positions; and determining the window file corresponding to the sub-file based on the sub-window position and the file window, wherein the target file includes multiple window files.

[0202] For example, the first file is segmented. First, the segment length is determined, which indicates the length of the sub-files after segmenting the first file. When the segment length is less than the total length of the first file, the number of sub-files corresponding to the first file is at least two; when the segment length is equal to the total length of the first file, the number of sub-files corresponding to the first file is one, that is, the first file has not been segmented.

[0203] For example, after segmenting the first file, if the data corresponding to the target file may span two adjacent sub-files, then when segmenting the first file, there is an overlap between the beginning and end parts of the two adjacent sub-files. The overlap includes at least the content of the file window corresponding to the target file.

[0204] For example, if subfile 1 and subfile 2 are adjacent to each other on the left and right, then the content of the file window at the end of subfile 1 is the same as the content of the file window at the beginning of subfile 2.

[0205] For example, after obtaining multiple sub-files, the position of the sub-window corresponding to each sub-file is determined according to the segment length, wherein the target window position includes multiple sub-window positions.

[0206] For example, if the first file is 350M in size and the segment length is 100M, then the first file can be divided into 4 sub-files. The first sub-file has a range of 0 to 100M + the size of the file window, the second sub-file has a range of 100M + the size of the file window to 200M + the size of the file window, the third sub-file has a range of 200M + the size of the file window to 300M + the size of the file window, and the fourth sub-file has a range of 300M + the size of the file window to 350M.

[0207] For example, after determining the data range corresponding to each sub-file based on the segment length, the starting position of the sub-file is determined as the initial position of the sub-window corresponding to that sub-file.

[0208] For example, the window file corresponding to the sub-file is determined based on the sub-window position and the file window, wherein the target file includes multiple window files. That is, after segmenting the first file to obtain multiple sub-files, the server uses multi-threading to perform sliding window processing operations on multiple sub-files in parallel, thereby obtaining the window file corresponding to each sub-file.

[0209] For example, the server segments the first file before the change into segments of a fixed length, such as 100M, and then allocates one sub-file to each computing thread for multi-threaded concurrent searching. Since a file window may span two adjacent sub-files when the data is segmented, it is necessary to reserve a space the size of a file window after the end of each sub-file to ensure that the data corresponding to each file window in the first file is searched.

[0210] For example, if the segment length is 100M, and the starting position of the sub-file of each thread, sectionoffset, remains unchanged, then the ending position is sectionoffset + 100M + the size of the file window, or the ending position is the file size of the first file.

[0211] It should be noted that the steps for searching the window file corresponding to each sub-file after segmenting the first file to obtain multiple sub-files are the same as the steps for searching directly without segmenting the first file.

[0212] Specifically, this application segments the first file to allow for parallel processing of multiple search tasks, thereby improving search efficiency. The server can employ multi-threaded concurrent searching after segmenting the first file, thus accelerating the computation process. Furthermore, this application considers that since a file window may span exactly two adjacent sub-files, when segmenting sub-files, the end position of each sub-file will be larger than the beginning position of the next sub-file by the size of one file window, ensuring that critical file windows can also be analyzed, thereby guaranteeing the integrity of the parallel processing effect.

[0213] In some implementations, calculating the third hash value and the fifth hash value includes: converting the content corresponding to the target file into an integer value, and summing the integer values ​​corresponding to the target file to obtain a first value; setting a second value, sequentially obtaining the index position of the integer value in the target file, adding the integer values ​​between the initial position and the index position in the target file to obtain a first summing result, adding the first summing result and the second value to obtain a second summing result, and updating the second value with the second summing result, wherein the third hash value includes the first value and the second value; subtracting the third value corresponding to the initial position of the target file from the first value, and adding the updated fourth value corresponding to the end position of the target file to obtain a fifth value; obtaining the product between the index length of the target file and the third value to obtain a product result, and summing the first value minus the product result with the fifth value to obtain a sixth value. The fifth hash value includes the fifth value and the sixth value.

[0214] For example, the contents of the target file are converted into integers, and these integers are summed to obtain a first value. A second value is set, and the index positions in the target file are traversed sequentially, with the integers between the initial position and the index position added to obtain a first sum. Then, the first sum is added to the second value to update the second value.

[0215] For example, if the initial value of the second value is set to 0, and the file window size is 4, then the index positions corresponding to the target file include 0, 1, 2, and 3. The process iterates through index positions 0, 1, 2, and 3 sequentially. First, it iterates through index position 0, which is also the initial position of the target file. The integers between index positions 0 and 0 are added together, resulting in the integer at index position 0 in the target file. This first addition is then added to the second value 0, and the result is updated to the second value. Therefore, the second value is now the value corresponding to index position 0 in the target file. Next, it iterates through index position 1, which is also the initial position of the target file. The integers between index positions 0 and 1 are added together, resulting in the first addition. This first addition is then added to the second value obtained in the previous iteration, and the result is updated to the second value. In the second value, the system iterates through index position 2. Since the initial position of the target file is also index position 0, the integers between index position 0 and index position 2 are added together. This results in the first addition: the integer at index position 0, index position 1, and index position 2 in the target file are added together. This first addition is then added to the second value obtained from the previous iteration and updated to the second value. Finally, the system iterates through index position 3. Since the initial position of the target file is also index position 0, the system iterates through index position 3. This results in the first addition: the integer at index position 0, index position 1, index position 2, and index position 3 in the target file are added together. This first addition is then added to the second value obtained from the previous iteration and updated to the second value. Thus, the first and second values ​​are used to determine the third hash value.

[0216] For example, the first value is subtracted from the third value corresponding to the initial position of the target file, that is, the first value is subtracted from the third value corresponding to the index position of the target file being 0, and then the fourth value corresponding to the end position of the updated target file is added, that is, the fourth value corresponding to the maximum index position of the updated target file is added, thereby obtaining the fifth value.

[0217] For example, the size of the file window is determined to be the index length corresponding to the target file. Then, the index length and the third value are multiplied to obtain the product result. The first value is then subtracted from the product result and summed with the fifth value to obtain the sixth value. Thus, the updated fifth hash value corresponding to the target file includes the fifth value and the sixth value.

[0218] For example, the calculation method of the third hash value can be understood as the method of performing a hash calculation on the target file for the first time, and the calculation method of the fifth hash value can be understood as the method of performing a hash calculation on the updated target file based on the calculation result of the previous target file.

[0219] Specifically, this application designs a file rolling weak hash algorithm with extremely low computational cost. After moving a preset step size, the target file only needs to be added twice, subtracted twice, and multiplied once to obtain the weak hash value of the target file, thereby reducing the computational cost and improving the time for calculating the initial difference information between the first file and the second file, thus improving computational efficiency.

[0220] Sub-step S624: Obtain the initial difference information between the first file and the second file based on the target location and the target window location.

[0221] For example, the target position is the block number of the first block file corresponding to the target file in the first file in the second file. The target window position is the position information of the window starting of the target file in the first file. Based on the target position and the target window position, it can be known which part of the content in the first file still exists in the second file. The target window positions corresponding to the part in the second file that does not exist in the first file and the part in the second file that does exist in the first file are jointly determined as the initial difference information between the first file and the second file.

[0222] For example, after the second file is processed into blocks, it becomes 10 first block files, namely first block file 1, first block file 2, ..., first block file 10. The target positions are block number 2, block number 4, block number 6, and block number 8. It can be seen that the first block files corresponding to block numbers 1, 3, 5, 7, 9, and 10 in the second file do not exist in the first file. Therefore, the target window positions corresponding to block numbers 1, 3, 5, 7, 9, and 10 in the second file, and block numbers 2, 4, 6, and 8 in the first file are determined as the initial difference information between the first and second files. Subsequently, the client can obtain the updated file based on the initial difference information.

[0223] In some implementations, the target location includes the file identifier. Obtaining the initial difference information between the first file and the second file based on the target location and the target window position corresponding to the target file includes: obtaining any two file identifiers as a first identifier and a second identifier, and calculating the difference between the first identifier and the second identifier; if the difference is equal to a preset value, storing the first identifier and the second identifier according to their numerical values ​​to obtain identifier combinations, and determining a first set based on all identifier combinations; arbitrarily obtaining two identifier combinations from the first set; if any two identifier combinations contain the same identifier, merging the two identifier combinations to obtain a merge result, and then... The process involves removing combinations from the first set and updating the merged results in the first set until no two identifier combinations in the first set have the same identifier; obtaining any identifier combination in the first set and obtaining the first window position corresponding to the identifier combination from the target window position; determining first difference information based on the first set and the first window position; if the difference is not equal to the preset value, storing the first identifier and the second identifier to obtain a second set; obtaining the second window position corresponding to each identifier in the second set from the target window position; determining second difference information based on the second set and the second window position; and determining the initial difference information based on the first difference information and the second difference information.

[0224] For example, the target location includes a file identifier, which can indicate the position of the first block file in the second file. For instance, the file identifier can be the block number corresponding to the first block file after the second file has been processed into blocks.

[0225] For example, after searching all target files corresponding to the first file, multiple target locations may be obtained. Then, two file identifiers are arbitrarily selected as the first identifier and the second identifier, and the difference between the first identifier and the second identifier is calculated. For example, if both the first identifier and the second identifier are block numbers, the difference is obtained by subtracting the two block numbers.

[0226] For example, when the difference and the preset value are equal, the preset value can be 1 and -1, and then the first identifier and the second identifier are stored in ascending order of numerical value to obtain the identifier combination.

[0227] For example, if the block number of the first identifier is 8 and the block number of the second identifier is 9, then the identifier combination is (block number 8, block number 9); if the block number of the first identifier is 9 and the block number of the second identifier is 8, then the identifier combination is also (block number 8, block number 9).

[0228] For example, any two file identifiers are combined to obtain multiple identifier combinations, which are then combined to form a first set. Any two identifier combinations are randomly selected from the first set. If any two identifier combinations contain the same identifier, the two identifier combinations are merged to obtain a merged result. The two identifier combinations are then removed from the first set, and the merged result is updated in the first set, until no two identifier combinations in the first set contain the same identifier.

[0229] For example, if the first set includes the identifier combinations (block number 8, block number 9), (block number 7, block number 8), (block number 6, block number 7), and (block number 1, block number 2), then after obtaining the identifier combinations (block number 8, block number 9) and (block number 7, block number 8), it is found that the two identifier combinations have the same block number 8. Therefore, the two identifier combinations are merged to obtain the merged result (block number 7, block number 9). Then, the identifier combinations (block number 8, block number 9) and (block number 7, block number 8) are removed from the first set, and the merged result (block number 7, block number 9) is added to the first set, resulting in the first set being (block number 6, block number 7), (block number 1, block number 2), and (block number 7, block number 9). Continue obtaining two identifier combinations (block number 6, block number 7) and (block number 1, block number 2). If no identical identifier exists, continue obtaining two identifier combinations (block number 1, block number 2) and (block number 7, block number 9). If no identical identifier exists, continue obtaining two identifier combinations (block number 6, block number 7) and (block number 7, block number 9). If there is a block number 7 with the same identifier, merge the two identifier combinations to obtain the merged result (block number 6, block number 9). Then, remove the identifier combinations (block number 6, block number 7) and (block number 7, block number 9) from the first set, and add the merged result (block number 6, block number 9) to the first set, resulting in the first set consisting of (block number 6, block number 9) and (block number 1, block number 2).

[0230] For example, any combination of identifiers in the first set is obtained, and the window position corresponding to the first file identifier in the identifier combination is obtained from the target window position and determined as the first window position corresponding to the identifier combination.

[0231] For example, if the first set consists of (block number 6, block number 9) and (block number 1, block number 2), then the target window position corresponding to block number 6 is determined as the first window position corresponding to the identifier combination (block number 6, block number 9), and the target window position corresponding to block number 1 is determined as the first window position corresponding to the identifier combination (block number 1, block number 2). This reduces the amount of data stored in the target window positions, thus reducing the storage burden on the server.

[0232] For example, the first difference information is determined based on the first set and the position of the first window.

[0233] For example, if the first set is (block number 6, block number 9) and (block number 1, block number 2), and the first window position corresponding to the identifier combination (block number 1, block number 2) is the target window position corresponding to block number 6, and the first window position corresponding to the identifier combination (block number 1, block number 2) is the target window position corresponding to block number 1, then it can be seen that the data between block numbers 6 and 9 in the second file all exist in the first file. The position of the data in the first file can also be determined based on the target window position corresponding to block number 6. Similarly, it can be seen that the data between block numbers 1 and 2 in the second file all exist in the first file. The position of the data in the first file can also be determined based on the target window position corresponding to block number 1. Therefore, the first difference information can be obtained based on the above information.

[0234] For example, if the difference is not equal to the preset value, the first identifier and the second identifier are stored to obtain a second set; the second window position corresponding to each identifier in the second set is obtained from the target window position; and the second difference information is determined based on the second set and the second window position.

[0235] For example, if the first identifier and the second identifier are not equal to a preset value, then the first identifier and the second identifier are directly stored to obtain a second set. Furthermore, considering that the difference between the first identifier and the second identifier may not be equal to the preset value, but there may be a situation where the difference between the first identifier and the third identifier is equal to the preset value, or the difference between the second identifier and the third identifier is equal to the preset value, after obtaining the second set, identifiers already present in the first set are removed to obtain an updated second set. Then, the second window position corresponding to each identifier in the second set is obtained from the target window position; thereby, second difference information is determined based on the second set and the second window position.

[0236] For example, the first difference information is the difference information obtained from the content of the target file corresponding to the file identifier that exists continuously in the first file, and the second difference information is the difference information obtained from the content of the target file corresponding to the file identifier that exists alone in the first file. Then, the first difference information and the second difference information are merged to obtain the initial difference information.

[0237] Specifically, the file identifiers calculated by the server may be several adjacent blocks. Storing each block separately requires a lot of storage space. Therefore, adjacent blocks can be merged according to their block numbers, which can greatly reduce the space usage.

[0238] In some embodiments, the method further includes: obtaining first attribute information corresponding to the first file and second attribute information corresponding to the second file; performing attribute hashing on the first attribute value to obtain a first attribute hash value and performing attribute hashing on the second attribute value to obtain a second attribute hash value; determining a target mapping table, determining the first attribute hash value as a first key value corresponding to the target mapping table and determining the second attribute hash value as a second key value corresponding to the target mapping table; determining a first mapping value corresponding to the first key value based on the target file and the third and fourth hash values ​​corresponding to the target file; and determining a second mapping value corresponding to the second key value based on the first block file and the first and second hash values ​​corresponding to the first block file.

[0239] For example, after performing a first hash process on multiple first block files to obtain a first hash value and a second hash value corresponding to each first block file, and performing a second hash process on the target file to obtain a third hash value and a fourth hash value corresponding to the target file, in order to reduce redundant calculations, this application also stores the first hash processing results and the second hash processing results. Then, if it is still necessary to perform a first hash process on multiple first block files of the first file or a second hash process on the target file in the future, it can be directly obtained from the stored results, thereby achieving the purpose of reducing duplication.

[0240] For example, first attribute information corresponding to the first file and second attribute information corresponding to the second file are obtained. The first attribute information includes the file relative path, file length, and file modification time corresponding to the first file, and the second attribute information includes the file relative path, file length, and file modification time corresponding to the second file.

[0241] For example, attribute hashing is performed on the first attribute value to obtain a first attribute hash value, and attribute hashing is performed on the second attribute value to obtain a second attribute hash value. Then, a target mapping table is determined, with the first attribute hash value designated as the first key value and the second attribute hash value designated as the second key value. This allows all target files, along with the third and fourth hash values ​​corresponding to each target file, to be designated as the first mapping values ​​corresponding to the first key values. Furthermore, all first block files, along with the first and second hash values ​​corresponding to each first block file, are designated as the second mapping values ​​corresponding to the second key values. The hash results corresponding to the first and second files are stored in the target mapping table. Therefore, when the hash processing result corresponding to the first file or the second file is needed, it can be preferentially searched in the target mapping table, thereby reducing the computational load.

[0242] Specifically, by using the first attribute value to perform attribute hashing to obtain the first attribute hash value and the second attribute value to perform attribute hashing to obtain the second attribute hash value, the key of the target mapping table can be used to avoid the problem of the value corresponding to the key being overwritten due to duplicate first or second files, thus ensuring the uniqueness of the key and providing support for obtaining accurate hashing results.

[0243] Step S14: Send the target difference information to the client so that the client can update the file based on the target difference information.

[0244] For example, after obtaining the target difference information, the target difference information is encapsulated to obtain the encapsulation result, and then the encapsulation result is sent to the client, so that after receiving the encapsulation result, the client can parse the encapsulation result to obtain the target difference information, and then update the file according to the target difference information.

[0245] Corresponding to the above method embodiments, this application also provides an embodiment of a document updating apparatus 200. Figure 4 A schematic diagram of a document update apparatus 200 according to an embodiment of this application is shown. Figure 4 As shown, the file update device 200 includes: a request acquisition module 201, a data parsing module 202, a data search module 203, and a data sending module 204. The request acquisition module 201 is configured to acquire a file update request sent by a client; the data parsing module 202 is configured to acquire the corresponding file to be updated based on the file update request; the data search module 203 is configured to search in file update information based on the file to be updated to obtain target difference information corresponding to the file to be updated. The method for generating the file update information includes: acquiring a target file and multiple first block files, wherein the target file is obtained based on the file window and target window position corresponding to the first file, the first block files are obtained by dividing a second file into blocks, and the second file is the file after the first file has changed; obtaining initial difference information between the first file and the second file based on the target file and the multiple first block files; storing the first file, the second file, and the initial difference information to obtain the file update information; and the data sending module 204 is configured to send the target difference information to the client, so that the client updates the file based on the target difference information.

[0246] In some optional embodiments, the data lookup module is further configured to:

[0247] The first processing module is configured to perform a first hash process on each of the multiple first block files to obtain a first hash value and a second hash value corresponding to each first block file;

[0248] The second processing module is configured to perform a second hash processing on the target file to obtain a third hash value and a fourth hash value corresponding to the target file.

[0249] The data comparison module is configured to determine the target location of the target file in the second file based on the first hash value, the second hash value, the third hash value, and the fourth hash value;

[0250] The difference calculation module is configured to obtain the initial difference information between the first file and the second file based on the target location and the target window location.

[0251] In some optional embodiments, the data comparison module is further configured to:

[0252] The index building module is configured to establish a mapping relationship between the first block file, the first hash value, and the second hash value to obtain block index data;

[0253] The index lookup module is configured to search for the third hash value and the fourth hash value in the block index data to obtain the search result corresponding to the target file;

[0254] The location determination module is configured to determine the target location of the target file in the second file based on the search result.

[0255] In some optional embodiments, the index lookup module is further configured to:

[0256] The first search module is configured to search for the third hash value in the block index data to obtain a first result;

[0257] The first comparison module is configured to compare the fourth hash value and the second hash value to obtain a comparison result if the first result indicates that the first hash value and the third hash value are equal in the block index data.

[0258] The second comparison module is configured to determine that the search result is successful if the comparison result is that the fourth hash value and the second hash value are equal.

[0259] The third comparison module is configured to determine that the search result is a search failure if the first result is that the first hash value and the third hash value do not exist in the block index data, or if the comparison result is that the fourth hash value and the second hash value are not equal.

[0260] In some optional embodiments, the location determination module is further configured to:

[0261] The first search and analysis module is configured to obtain the file identifier of the first block file corresponding to the second hash value if the search result indicates that the search is successful.

[0262] The first determining module is configured to determine the target location of the target file in the second file based on the file identifier;

[0263] The first search and analysis module is configured to move the target window position according to a preset step size to obtain the moved target window position, and update the target file according to the moved target window position and the file window to obtain the updated target file;

[0264] The second determining module is configured to calculate the fifth hash value and the sixth hash value corresponding to the updated target file, and find the target position of the updated target file in the second file according to the fifth hash value and the sixth hash value, until the target window position is the same as the preset position.

[0265] In some optional embodiments, the data lookup module is further configured to:

[0266] The data segmentation module is configured to determine the segment length and segment the first file into multiple sub-files according to the segment length, wherein any two adjacent sub-files have overlapping beginning and end portions.

[0267] The window position determination module is configured to determine the position of the sub-window corresponding to the sub-file based on the segment length, wherein the target window position includes multiple sub-window positions;

[0268] The file determination module is configured to determine the window file corresponding to the sub-file based on the sub-window position and the file window, wherein the target file includes multiple window files.

[0269] In some optional embodiments, the file updating apparatus is further configured to:

[0270] The data conversion module is configured to convert the content corresponding to the target file into an integer value, and sum the integer values ​​corresponding to the target file to obtain a first value;

[0271] The first data processing module is configured to set a second value, and sequentially execute the following steps: obtain the index position of the integer value in the target file, add the integer value between the initial position and the index position in the target file to obtain a first addition result, add the first addition result and the second value to obtain a second addition result, and update the second addition result to the second value. The third hash value includes the first value and the second value.

[0272] The second data processing module is configured to subtract the third value corresponding to the initial position of the target file from the first value, and add the fourth value corresponding to the updated end position of the target file to obtain the fifth value;

[0273] The third data processing module is configured to obtain the product between the index length corresponding to the target file and the third value, and then subtract the product from the first value and sum it with the fifth value to obtain a sixth value. The fifth hash value includes both the fifth and sixth values.

[0274] In some optional embodiments, the difference calculation module is further configured to:

[0275] The difference calculation module is configured to obtain any two file identifiers as a first identifier and a second identifier, and calculate the difference between the first identifier and the second identifier;

[0276] The first set module is configured to, if the difference is equal to a preset value, store the first identifier and the second identifier according to their numerical values ​​to obtain an identifier combination, and determine the first set according to all the identifier combinations;

[0277] The data fusion module is configured to obtain any two of the identifier combinations from the first set, and if any two of the identifier combinations have the same identifier, merge the two identifier combinations to obtain a fusion result, remove any two of the identifier combinations from the first set, and update the fusion result to the first set, until no two of the identifier combinations in the first set have the same identifier.

[0278] The first window position acquisition module is configured to obtain any of the identifier combinations in the first set, and obtain the first window position corresponding to the identifier combination from the target window position;

[0279] The first difference determination module is configured to determine first difference information based on the first set and the first window position;

[0280] The second set module is configured to store the first identifier and the second identifier to obtain a second set if the difference is not equal to the preset value;

[0281] The second window position acquisition module is configured to obtain the second window position corresponding to each identifier in the second set from the target window position;

[0282] The second difference determination module is configured to determine second difference information based on the second set and the second window position;

[0283] The initial difference determination module is configured to determine the initial difference information based on the first difference information and the second difference information.

[0284] In some optional embodiments, the file updating apparatus is further configured to:

[0285] The attribute acquisition module is configured to obtain the first attribute information corresponding to the first file and the second attribute information corresponding to the second file;

[0286] The attribute processing module is configured to perform attribute hashing on the first attribute value to obtain a first attribute hash value and to perform attribute hashing on the second attribute value to obtain a second attribute hash value;

[0287] The key value determination module is configured to determine the target mapping table, determine the first attribute hash value as the first key value corresponding to the target mapping table, and determine the second attribute hash value as the second key value corresponding to the target mapping table;

[0288] The first mapping determination module is configured to determine the first mapping value corresponding to the first key value based on the target file and the third hash value and the fourth hash value corresponding to the target file;

[0289] The second mapping determination module is configured to determine the second mapping value corresponding to the second key value based on the first block file and the first hash value and the second hash value corresponding to the first block file.

[0290] The above is an illustrative scheme of a file updating apparatus according to this embodiment. It should be noted that the technical solution of the file updating apparatus and the technical solution of the file updating method described above belong to the same concept. For details not described in detail in the technical solution of the file updating apparatus, please refer to the description of the technical solution of the file updating method described above.

[0291] Please refer to Figure 5 , Figure 5 This is an interactive schematic diagram of a file update method provided in an embodiment of the present invention. The file update method applied to the client includes steps S41 to S43.

[0292] Step S41: Determine the file to be updated and determine the file update request based on the file to be updated.

[0293] For example, the user confirms the file to be updated on the client. The file to be updated includes the name information of an existing file on the client and the name information or version information of the file to be updated. The client then constructs an HTTP request, which includes information such as the request method, request headers, and request body. The request body includes the name information or related information of the file to be updated, thereby generating a file update request.

[0294] Step S42: Send the file update request to the server, so that the server obtains the corresponding file to be updated according to the file update request and searches in the file update information to obtain the target difference information corresponding to the file to be updated; wherein, the method for generating the file update information in the server includes: the server obtains a target file and multiple first block files, the target file is obtained according to the file window and target window position corresponding to the first file, the first block files are obtained by dividing a second file into blocks, and the second file is the file after the first file has changed; the server obtains the initial difference information between the first file and the second file according to the target file and the multiple first block files; the server stores the first file, the second file and the initial difference information to obtain the file update information.

[0295] For example, the client then sends a file update request to the server, so that the server can find the corresponding file to be updated in the file update information based on the file update request and obtain the target difference information corresponding to the file to be updated.

[0296] It should be noted that the server obtains the corresponding file to be updated based on the file update request, searches for it in the file update information, obtains the target difference information corresponding to the file to be updated, and the method for generating the file update information in the server has been explained above, and will not be repeated here.

[0297] Step S43: Receive the target difference information sent by the server, and update the file to be updated according to the target difference information.

[0298] For example, the client receives the encapsulation result sent by the server, then parses the encapsulation result to obtain the target difference information, and then updates the file to be updated according to the target difference information.

[0299] In some implementations, updating the file to be updated based on the target difference information includes: determining the target download content corresponding to the file to be updated based on the target difference information; downloading the file from the server based on the target download content to obtain the download result corresponding to the target download content; and updating the file to be updated based on the download result.

[0300] For example, the target download content corresponding to the file to be updated is determined by the target difference information. The target download content can be the content of the file to be updated that needs to be downloaded incrementally, thereby reducing network transmission volume and improving download efficiency. Based on the determined target download content, the download is performed from the server to obtain the download result, thus downloading only the content missing from the client.

[0301] For example, the downloaded result and the content already existing on the client are merged using the target difference information to obtain the complete update file corresponding to the file to be updated. Then, the complete update file is used to perform the corresponding update operation on the file to be updated, thereby achieving the update effect of the file to be updated.

[0302] Specifically, this step involves downloading target content that does not exist in the client, obtaining the download result corresponding to the target content, and then merging the downloaded result with the content already existing in the client to obtain the complete update file corresponding to the file to be updated. This reduces unnecessary network traffic and bandwidth consumption, avoids downloading the entire file, and saves time and server resources.

[0303] Corresponding to the above method embodiments, this application also provides an embodiment of a document updating apparatus 500. Figure 6 A schematic diagram of a document updating apparatus 500 according to an embodiment of this application is shown. Figure 6As shown, the file update apparatus 500 includes: a data request module 501, configured to determine a file to be updated and determine a file update request based on the file to be updated; a result acquisition module 502, configured to send the file update request to a server, so that the server obtains the corresponding file to be updated according to the file update request and searches in the file update information to obtain the target difference information corresponding to the file to be updated; wherein, the method for generating the file update information in the server includes: the server obtaining a target file and a plurality of first block files, the target file being obtained according to the file window and target window position corresponding to the first file, the first block files being obtained by dividing a second file into blocks, and the second file being the file after the first file has changed; the server obtaining initial difference information between the first file and the second file based on the target file and the plurality of first block files; the server storing the first file, the second file, and the initial difference information to obtain the file update information; and a data update module 503, configured to receive the target difference information sent by the server and update the file to be updated according to the target difference information.

[0304] In some optional embodiments, the result acquisition module is further configured to:

[0305] The content determination module is configured to determine the target download content corresponding to the file to be updated based on the target difference information.

[0306] The content download module is configured to download files from the server based on the target download content and obtain the download result corresponding to the target download content;

[0307] The file update module is configured to update the file to be updated based on the download results.

[0308] like Figure 7 As shown, Figure 7 A structural block diagram of a terminal device 700 according to an embodiment of this application is shown. The components of the terminal device 700 include, but are not limited to, a memory 710 and a processor 720. The processor 720 is connected to the memory 710 via a bus 730, and a database 750 is used to store data.

[0309] Terminal device 700 also includes access device 740, which enables terminal device 700 to communicate via one or more networks 760. Examples of these networks include Public Switched Telephone Network (PSTN), Local Area Network (LAN), Wide Area Network (WAN), Personal Area Network (PAN), or combinations of communication networks such as the Internet. Access device 740 may include one or more of any type of wired or wireless network interface (e.g., Network Interface Card (NIC)), such as IEEE 802.11 Wireless Local Area Network (WLAN) interface, Wi-MAX interface, Ethernet interface, Universal Serial Bus (USB) interface, cellular network interface, Bluetooth interface, Near Field Communication (NFC) interface, and so on.

[0310] In one embodiment of this application, the aforementioned components of the terminal device 700 and Figure 7 Other components, not shown, can also be connected to each other, for example, via a bus. It should be understood that... Figure 7 The illustrated electronic device block diagram is for illustrative purposes only and is not intended to limit the scope of this application. Those skilled in the art can add or replace other components as needed.

[0311] Terminal device 700 can be any type of stationary or mobile electronic device, including mobile computers or mobile electronic devices (e.g., tablet computers, personal digital assistants, laptop computers, notebook computers, netbooks, etc.), mobile phones (e.g., smartphones), wearable electronic devices (e.g., smartwatches, smart glasses, etc.) or other types of mobile devices, or stationary electronic devices such as desktop computers or PCs. Terminal device 700 can also be a mobile or stationary server.

[0312] The processor 720 is used to execute computer-executable instructions for object processing methods.

[0313] The above is an illustrative scheme of a computing device according to this embodiment. It should be noted that the technical solution of this computing device and the technical solution of the object processing method described above belong to the same concept. For details not described in detail in the technical solution of the computing device, please refer to the description of the technical solution of the object processing method described above.

[0314] This application also provides a storage medium, which is a computer-readable storage medium, storing a computer program that, when executed by a processor, implements the above-described file update method and file update information generation method.

[0315] Memory, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs and non-transitory computer-executable programs. Furthermore, memory may include high-speed random access memory, and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some embodiments, memory may optionally include memory remotely located relative to the processor, and these remote memories can be connected to the processor via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof. The device embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separate, and may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.

[0316] It will be understood by those skilled in the art that all or some of the steps and systems in the methods disclosed above can be implemented as software, firmware, hardware, and suitable combinations thereof. Some or all of the physical components can be implemented as software executed by a processor, such as a central processing unit, digital signal processor, or microprocessor, or as hardware, or as an integrated circuit, such as an application-specific integrated circuit. Such software can be distributed on a computer-readable medium, which can include computer storage media (or non-transitory media) and communication media (or transient media). As is known to those skilled in the art, the term computer storage media includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, program modules, or other data). Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technologies, CD-ROM, digital versatile disc (DVD) or other optical disc storage, magnetic cartridges, magnetic tape, disk storage or other magnetic storage devices, or any other medium that can be used to store desired information and is accessible to a computer. Furthermore, as is known to those skilled in the art, communication media typically include computer-readable instructions, data structures, program modules, or other data in modulated data signals such as carrier waves or other transmission mechanisms, and may include any information transmission medium.

[0317] The above provides a detailed description of the preferred embodiments of this application. However, this application is not limited to the above-described embodiments. Those skilled in the art can make various equivalent modifications or substitutions without departing from the spirit of this application. All such equivalent modifications or substitutions are included within the scope defined by the claims of this application.

Claims

1. A method for updating a file, characterized in that, Applied to a server, the method includes: Obtain the file update request sent by the client; Obtain the corresponding file to be updated based on the file update request; Based on the file to be updated, search the file update information to obtain the target difference information corresponding to the file to be updated; The target difference information is sent to the client so that the client can update the file based on the target difference information; The method for generating the file update information includes: Obtain a target file and multiple first block files. The target file is obtained based on the file window and target window position corresponding to the first file. The first block files are obtained by dividing a second file into blocks. The second file is the modified version of the first file. Initial difference information between the first file and the second file is obtained based on the target file and multiple first block files; The first file, the second file, and the initial difference information are stored to obtain the file update information; The step of obtaining initial difference information between the first file and the second file based on the target file and multiple first block files includes: Perform a first hash process on each of the multiple first block files to obtain a first hash value and a second hash value corresponding to each first block file; The target file is subjected to a second hash process to obtain the third and fourth hash values ​​corresponding to the target file; The target location of the target file in the second file is determined based on the first hash value, the second hash value, the third hash value, and the fourth hash value; The initial difference information between the first file and the second file is obtained based on the target location and the target window location.

2. The method according to claim 1, characterized in that, Determining the target location of the target file in the second file based on the first hash value, the second hash value, the third hash value, and the fourth hash value includes: Establish a mapping relationship between the first block file, the first hash value, and the second hash value to obtain the block index data; The third hash value and the fourth hash value are searched in the block index data to obtain the search result corresponding to the target file; The target location of the target file in the second file is determined based on the search results.

3. The method according to claim 2, characterized in that, The step of searching the third hash value and the fourth hash value in the block index data to obtain the search result corresponding to the target file includes: The third hash value is searched in the block index data to obtain the first result; If the first result indicates that the first hash value and the third hash value are equal in the block index data, the fourth hash value and the second hash value are compared to obtain a comparison result; If the comparison result shows that the fourth hash value and the second hash value are equal, the search result is determined to be a successful search. If the first result is that the first hash value and the third hash value do not exist in the block index data, or if the comparison result is that the fourth hash value and the second hash value are not equal, then the search result is determined to be a search failure.

4. The method according to claim 3, characterized in that, Determining the target location of the target file in the second file based on the search result includes: If the search result indicates a successful search, the file identifier of the first block file corresponding to the second hash value is obtained; The target location of the target file in the second file is determined based on the file identifier; The target window position is moved according to a preset step size to obtain the moved target window position, and the target file is updated according to the moved target window position and the file window to obtain the updated target file; Calculate the fifth and sixth hash values ​​corresponding to the updated target file, and find the target position of the updated target file in the second file based on the fifth and sixth hash values, until the target window position is the same as the preset position.

5. The method according to claim 1, characterized in that, The target file is obtained based on the file window corresponding to the first file and the target window position, including: Determine the segment length, and divide the first file into multiple sub-files according to the segment length, wherein any two adjacent sub-files have overlapping beginning and end portions; The sub-window position corresponding to the sub-file is determined based on the segment length, wherein the target window position includes multiple sub-window positions; The window file corresponding to the sub-file is determined based on the sub-window position and the file window, wherein the target file includes multiple window files.

6. The method according to claim 4, characterized in that, Calculating the third hash value and the fifth hash value includes: The content corresponding to the target file is converted into an integer value, and the integer values ​​corresponding to the target file are summed to obtain a first value; Set a second value, and sequentially execute the following steps: obtain the index position of the integer value in the target file, add the integer value between the initial position and the index position in the target file to obtain a first addition result, add the first addition result and the second value to obtain a second addition result, and update the second value with the second addition result. The third hash value includes the first value and the second value. Subtract the third value corresponding to the initial position of the target file from the first value, and add the fourth value corresponding to the updated end position of the target file to obtain the fifth value; The product between the index length corresponding to the target file and the third value is obtained to obtain the product result. The first value is subtracted from the product result and then summed with the fifth value to obtain the sixth value. The fifth hash value includes the fifth value and the sixth value.

7. The method according to claim 4, characterized in that, The target location includes the file identifier, and obtaining the initial difference information between the first file and the second file based on the target location and the target window position corresponding to the target file includes: Obtain any two file identifiers and designate them as a first identifier and a second identifier, and calculate the difference between the first identifier and the second identifier; If the difference is equal to the preset value, the first identifier and the second identifier are stored according to their numerical values ​​to obtain an identifier combination, and a first set is determined based on all the identifier combinations. Two identifier combinations are randomly obtained from the first set. If any two identifier combinations have the same identifier, the two identifier combinations are merged to obtain a merge result. The two identifier combinations are removed from the first set, and the merge result is updated to the first set until no two identifier combinations in the first set have the same identifier. Obtain any combination of identifiers in the first set, and obtain the first window position corresponding to the combination of identifiers from the target window position; The first difference information is determined based on the first set and the first window position; If the difference is not equal to the preset value, the first identifier and the second identifier are stored to obtain a second set; Obtain the second window position corresponding to each identifier in the second set from the target window position; The second difference information is determined based on the second set and the second window position; The initial difference information is determined based on the first difference information and the second difference information.

8. The method according to any one of claims 1-7, characterized in that, The method further includes: Obtain the first attribute information corresponding to the first file and the second attribute information corresponding to the second file; The first attribute information is hashed to obtain a first attribute hash value, and the second attribute information is hashed to obtain a second attribute hash value. Determine the target mapping table, and determine the first attribute hash value as the first key value corresponding to the target mapping table and the second attribute hash value as the second key value corresponding to the target mapping table; The first mapping value corresponding to the first key value is determined based on the target file and the third hash value and the fourth hash value corresponding to the target file; The second mapping value corresponding to the second key value is determined based on the first block file and the first hash value and the second hash value corresponding to the first block file.

9. A file updating apparatus, characterized in that, Applied to servers, including: The request acquisition module is configured to acquire file update requests sent by the client. The data parsing module is configured to obtain the corresponding file to be updated based on the file update request; The data search module is configured to search for the file to be updated in the file update information to obtain the target difference information corresponding to the file to be updated. The method for generating the file update information includes: acquiring a target file and multiple first block files, wherein the target file is obtained based on the file window and target window position corresponding to the first file, the first block files are obtained by dividing a second file into blocks, and the second file is the modified version of the first file; obtaining initial difference information between the first file and the second file based on the target file and the multiple first block files; and storing the first file, the second file, and the initial difference information to obtain the file update information. The data sending module is configured to send the target difference information to the client, so that the client can update the file based on the target difference information; The step of obtaining initial difference information between the first file and the second file based on the target file and multiple first block files includes: performing a first hash process on each of the multiple first block files to obtain a first hash value and a second hash value corresponding to each first block file; performing a second hash process on the target file to obtain a third hash value and a fourth hash value corresponding to the target file; determining the target position of the target file in the second file based on the first hash value, the second hash value, the third hash value, and the fourth hash value; and obtaining the initial difference information between the first file and the second file based on the target position and the target window position.

10. A method for updating a file, characterized in that, Applied to a client, the method includes: Identify the file to be updated, and determine the file update request based on the file to be updated; Send the file update request to the server so that the server can find the corresponding file to be updated in the file update information according to the file update request and obtain the target difference information corresponding to the file to be updated; Receive the target difference information sent by the server, and update the file to be updated according to the target difference information; The method for generating the file update information in the server includes: The server obtains a target file and multiple first block files. The target file is obtained based on the file window corresponding to the first file and the target window position. The first block files are obtained by dividing a second file into blocks. The second file is the modified version of the first file. The server obtains initial difference information between the first file and the second file based on the target file and multiple first block files; The server stores the first file, the second file, and the initial difference information to obtain the file update information; The initial difference information between the first file and the second file is obtained based on the target file and multiple first block files, including: Perform a first hash process on each of the multiple first block files to obtain a first hash value and a second hash value corresponding to each first block file; The target file is subjected to a second hash process to obtain the third and fourth hash values ​​corresponding to the target file; The target location of the target file in the second file is determined based on the first hash value, the second hash value, the third hash value, and the fourth hash value; The initial difference information between the first file and the second file is obtained based on the target location and the target window location.

11. The method according to claim 10, characterized in that, The step of updating the file to be updated based on the target difference information includes: The target download content corresponding to the file to be updated is determined based on the target difference information. Based on the target download content, the file is downloaded from the server to obtain the download result corresponding to the target download content; The file to be updated is updated based on the download results.

12. A file updating apparatus, characterized in that, Applied to the client side, including: The data request module is configured to determine the file to be updated and, based on the file to be updated, determine a file update request; The result acquisition module is configured to send the file update request to the server, so that the server obtains the corresponding file to be updated based on the file update request and searches in the file update information to obtain the target difference information corresponding to the file to be updated; wherein, the method for generating the file update information in the server includes: the server obtains a target file and multiple first block files, the target file is obtained according to the file window and target window position corresponding to the first file, the first block files are obtained by dividing a second file into blocks, and the second file is the file after the first file has changed; the server obtains the initial difference information between the first file and the second file based on the target file and the multiple first block files; the server stores the first file, the second file and the initial difference information to obtain the file update information; The data update module is configured to receive the target difference information sent by the server and update the file to be updated according to the target difference information; The initial difference information between the first file and the second file is obtained based on the target file and multiple first block files, including: Perform a first hash process on each of the multiple first block files to obtain a first hash value and a second hash value corresponding to each first block file; The target file is subjected to a second hash process to obtain the third and fourth hash values ​​corresponding to the target file; The target location of the target file in the second file is determined based on the first hash value, the second hash value, the third hash value, and the fourth hash value; The initial difference information between the first file and the second file is obtained based on the target location and the target window location.

13. A terminal device, characterized in that, The terminal device includes at least one control processor and a memory for communicatively connecting to the at least one control processor; the memory stores instructions executable by the at least one control processor, which, when executed by the at least one control processor, enable the at least one control processor to perform a file update method as described in any one of claims 1 to 8 and a file update method as described in any one of claims 10 to 11.

14. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions for causing a computer to perform the steps of the method for updating a file as claimed in any one of claims 1 to 8 and the steps of the method for updating a file as claimed in any one of claims 10 to 11.