Incremental package generation method, device, equipment and storage medium
By hashing the file information and matching the version differential package, the problem of low generation efficiency of existing incremental packages is solved, and efficient incremental package generation and distribution is achieved.
Patent Information
- Application Number
- CN202111550923.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-17
- Publication Date
- 2024-12-03
- Estimated Expiration
- 2041-12-17
AI Technical Summary
The existing incremental package generation method is inefficient, requiring the version number of the user equipment to be consistent with the release version number. Direct comparison of different historical version packages leads to high CDN traffic costs and low generation efficiency.
By performing the first string splicing processing and hash calculation of the file information of the project to be published, the hash value is obtained, and then the second string splicing processing and hash calculation is performed, and uploading it to the server for version difference Package matching processing, if the difference package is matched, it will be used directly, otherwise an incremental package will be generated.
Improves the efficiency of incremental packet generation, reduces CDN traffic costs, and dynamically matches the distribution of incremental packets of any version of files.
Smart Images

Figure CN114185588B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing technology, and in particular to an incremental packet generation method, device, electronic device and computer-readable storage medium. Background Art
[0002] Generally speaking, after a period of use, software (such as application software or operating system) will gradually reveal some vulnerabilities and defects. These vulnerabilities and defects cannot meet the requirements of the growing software industry. Therefore, software developers must regularly or irregularly repair and correct the vulnerabilities and defects of the software itself, generally by generating incremental packages to repair and correct the software.
[0003] Existing incremental package generation methods usually build incremental packages based on the version number to be released and the project content. This method requires that the version number on the user device receiving the incremental package must be consistent with the version number to be released. At the same time, directly comparing different historical version packages to generate incremental packages will result in more CDN traffic costs, making the incremental package generation efficiency low. Summary of the invention
[0004] The present invention provides an incremental packet generation method, device and computer-readable storage medium, the main purpose of which is to improve the efficiency of incremental packet generation.
[0005] To achieve the above object, the present invention provides a method for generating an incremental package, comprising:
[0006] Acquire file information of the project to be published, perform first string concatenation processing and first hash calculation on the file information, and obtain a first string sequence and a hash value corresponding to the first string sequence;
[0007] Aggregate the hash value corresponding to the first string sequence and the file information to obtain a summary array, perform a second string concatenation process and a second hash calculation on the summary array to obtain a second string sequence and a hash value corresponding to the second string sequence;
[0008] Uploading the hash value corresponding to the second string sequence to a preset server for version difference package matching processing to obtain a matching result;
[0009] If the matching result is that a difference package is matched, the matched difference package is used as an incremental package;
[0010] If the matching result is that no difference package is matched, an incremental generation process is performed on the summary array to obtain an incremental package.
[0011] Optionally, performing a first string concatenation process and a first hash calculation on the file information to obtain a first string sequence and a hash value corresponding to the first string sequence includes:
[0012] Extracting multiple relative path information of preset functions in the file information, and looping through the multiple relative path information to obtain a standard array;
[0013] Performing a first hash calculation on the standard array to obtain a hash value corresponding to the standard array;
[0014] Perform information splicing processing on the plurality of relative path information and the hash values corresponding to the standard array to obtain a first string sequence;
[0015] A first hash calculation is performed on the first string sequence to obtain a hash value corresponding to the first string sequence.
[0016] Optionally, performing a second string concatenation process and a second hash calculation on the summary array to obtain a second string sequence and a hash value corresponding to the second string sequence includes:
[0017] Sorting the plurality of pieces of relative path information in the summary array according to the names to obtain a first sorted array;
[0018] Based on preset punctuation marks, the plurality of relative path information in the first sorted array are concatenated in the order of sorting to obtain a second string sequence;
[0019] A second hash calculation is performed on the second string sequence using a preset hash function to obtain a hash value corresponding to the second string sequence.
[0020] Optionally, uploading the hash value corresponding to the second string sequence to a preset server for version difference package matching processing to obtain a matching result includes:
[0021] querying, based on the cache memory of the server, whether there is a difference package corresponding to the hash value corresponding to the second string sequence;
[0022] If the difference package exists in the cache memory, the matching result is that the difference package is matched;
[0023] If a complete packet exists in the cache memory, the matching result is that no difference packet is matched.
[0024] Optionally, performing incremental generation processing on the summary array to obtain an incremental package includes:
[0025] Obtaining new version information of the project to be released, and recording the new version information into a preset first array and a second array;
[0026] The new version information is processed in a loop to obtain a loop file, and a hash calculation is performed on the loop file to obtain a hash value corresponding to the loop file;
[0027] Recording the hash value corresponding to the loop file in the first array to obtain a first standard array, and recording the loop file in the second array to obtain a second standard array;
[0028] Sort the plurality of relative path information in the summary array by time to obtain a second sorted array, extract array values in the first standard array excluding the second sorted array, and obtain incremental paths corresponding to a plurality of array values in the second standard array according to positions of the array values in the second sorted array to which they belong;
[0029] An incremental package is generated according to the incremental path.
[0030] Optionally, generating an incremental package according to the incremental path includes:
[0031] Obtaining a preset incremental database, and performing an incremental query in the incremental database based on the incremental path;
[0032] The data corresponding to the incremental path in the incremental database is aggregated to generate an incremental package.
[0033] Optionally, after generating the incremental package according to the incremental path, the method further includes:
[0034] Uploading the incremental package to a preset content distribution network, and generating an incremental address corresponding to the incremental package;
[0035] Performing splicing processing on the second sorted arrays, and performing hash value calculation on the spliced second sorted arrays to obtain a spliced hash value;
[0036] A mapping relationship is formed based on the incremental address and the concatenated hash value, and the mapping relationship is stored in the cache memory.
[0037] In order to solve the above problem, the present invention further provides an incremental packet generation device, the device comprising:
[0038] A first hash value calculation module is used to obtain file information of a project to be released, perform a first string concatenation process and a first hash calculation on the file information, and obtain a first string sequence and a hash value corresponding to the first string sequence;
[0039] A second hash value calculation module is used to aggregate the hash value corresponding to the first string sequence and the file information to obtain a summary array, and perform a second string concatenation process and a second hash calculation on the summary array to obtain a second string sequence and a hash value corresponding to the second string sequence;
[0040] a difference package matching module, used for uploading the hash value corresponding to the second string sequence to a preset server for version difference package matching processing to obtain a matching result, and if the matching result is a match to a difference package, using the matched difference package as an incremental package;
[0041] The incremental generation module is used to perform incremental generation processing on the summary array to obtain an incremental package if the matching result is that no difference package is matched.
[0042] In order to solve the above problem, the present invention further provides an electronic device, the electronic device comprising:
[0043] at least one processor; and,
[0044] a memory communicatively connected to the at least one processor; wherein,
[0045] The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the incremental packet generation method described above.
[0046] In order to solve the above problems, the present invention also provides a computer-readable storage medium, in which at least one computer program is stored. The at least one computer program is executed by a processor in an electronic device to implement the incremental packet generation method described above.
[0047] The embodiment of the present invention performs a first string concatenation process and a first hash calculation on the file information of the project to be published, obtains a first string sequence and a hash value corresponding to the first string sequence, obtains a specific hash value corresponding to the file information, summarizes the hash value corresponding to the first string sequence and the file information, obtains a summary array, performs a second string concatenation process and a second hash calculation on the summary array, obtains a second string sequence and a hash value corresponding to the second string sequence, obtains a hash value corresponding to the summary array, and uploads the hash value corresponding to the second string sequence to a preset server for version difference package matching processing to obtain a matching result. The hash value dynamically matches the version of the server side to solve the incremental package distribution problem of any version file. When a difference package is matched, the matched difference package is used as an incremental package. When the difference package is not matched, the summary array is incrementally generated to obtain an incremental package. The version difference package matching process can be judged according to the obtained matching result. Only when the difference package is not matched will the summary array be incrementally generated. When the difference package is matched, the difference package is directly used as the incremental package, which can improve the efficiency of incremental package generation. Therefore, the incremental packet generation method, device, electronic device and computer-readable storage medium proposed in the present invention can solve the problem of insufficient efficiency in incremental packet generation. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] Figure 1 A schematic diagram of a flow chart of a method for generating an incremental package provided by an embodiment of the present invention;
[0049] Figure 2 A functional module diagram of an incremental packet generation device provided by an embodiment of the present invention;
[0050] Figure 3 A schematic diagram of the structure of an electronic device for implementing the incremental packet generation method provided in one embodiment of the present invention.
[0051] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0052] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.
[0053] The embodiment of the present application provides a method for generating an incremental package. The execution subject of the incremental package generation method includes but is not limited to at least one of the electronic devices such as a server, a terminal, etc. that can be configured to execute the method provided by the embodiment of the present application. In other words, the incremental package generation method can be executed by software or hardware installed on a terminal device or a server device, and the software can be a blockchain platform. The server includes but is not limited to: a single server, a server cluster, a cloud server or a cloud server cluster, etc. The server can be an independent server, or it can be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (Content Delivery Network, CDN), and big data and artificial intelligence platforms.
[0054] Reference Figure 1 The figure is a flow chart of an incremental package generation method provided by an embodiment of the present invention.
[0055] In this embodiment, the incremental package generation method includes:
[0056] S1. Obtain file information of a project to be released, perform a first string concatenation process and a first hash calculation on the file information, and obtain a first string sequence and a hash value corresponding to the first string sequence.
[0057] In an embodiment of the present invention, the file information of the project to be released refers to the relative path information of all files of a function of a project. The file information of the relative file path of the project A to be released may be app / mall / home / a.png, app / mall / home / b.png, app / mall / home / c.png, app / mall / second / c.png, app / mall / second / d.png, app / mall / third / a.png, app / mall / third / b.png, app / mall / third / c.png.
[0058] Specifically, performing a first string concatenation process and a first hash calculation on the file information to obtain a first string sequence and a hash value corresponding to the first string sequence includes:
[0059] Extracting multiple relative path information of preset functions in the file information, and looping through the multiple relative path information to obtain a standard array;
[0060] Performing a first hash calculation on the standard array to obtain a hash value corresponding to the standard array;
[0061] Perform information splicing processing on the plurality of relative path information and the hash values corresponding to the standard array to obtain a first string sequence;
[0062] A first hash calculation is performed on the first string sequence to obtain a hash value corresponding to the first string sequence.
[0063] In detail, extracting multiple relative path information of preset functions in the file information refers to collecting relative path information of all files of a function in project A, and looping the relative path information to obtain a standard array Y. Performing information splicing processing on the multiple relative path information and the hash values corresponding to the standard array refers to splicing the relative path information with the hash values corresponding to the relative path information in the standard array to obtain a first string sequence XP, performing a first hash calculation on the first string sequence XP, and obtaining a hash value XPMD5 corresponding to the first string sequence.
[0064] For example, the standard array Y contains app / mall / home / a.png, app / mall / home / b.png, and app / mall / home / c.png. The standard array is hashed using a preset hash function to obtain a hash value corresponding to the standard array. Among them, the hash values corresponding to the standard array are b0a47be4ee5892f28287975dd21f1414, 3d79c2c777b61eb416bcf7ec61b4e204, and 0293fc37a1c083728a70bda0a7eff9da. The plurality of relative path information and the hash values corresponding to the standard array are spliced, wherein the information splicing is to splice the relative path information with the hash values in the standard array corresponding to the relative path information. The first string sequence is app / mall / home / a.png / b0a47be4ee5892f28287975dd21f1414, app / mall / home / b.png3d79c2c777b61eb416bcf7ec61b4e204, and app / mall / home / c.png0293fc37a1c083728a70bda0a7eff9da. A hash calculation is performed on the first string sequence XP to obtain a hash value corresponding to the first string sequence. For example, the hash value of the first string sequence app / mall / home / a.png / b0a47be4ee5892f28287975dd21f1414 is 563798740dafb43d0f8c7f443f882d72.
[0065] S2. Aggregate the hash value corresponding to the first string sequence and the file information to obtain a summary array, perform a second string concatenation process and a second hash calculation on the summary array to obtain a second string sequence and a hash value corresponding to the second string sequence.
[0066] In an embodiment of the present invention, the hash value corresponding to the first string sequence is aggregated with the file information, that is, the hash value corresponding to the first string sequence is aggregated with the standard array extracted from the file information, and the hash value corresponding to the first string sequence is added to the standard array to obtain a summarized array.
[0067] Specifically, performing a second string concatenation process and a second hash calculation on the summary array to obtain a second string sequence and a hash value corresponding to the second string sequence includes:
[0068] Sorting the plurality of pieces of relative path information in the summary array according to the names to obtain a first sorted array;
[0069] Based on preset punctuation marks, the plurality of relative path information in the first sorted array are concatenated in the order of sorting to obtain a second string sequence;
[0070] A second hash calculation is performed on the second string sequence using a preset hash function to obtain a hash value corresponding to the second string sequence.
[0071] In detail, the first string sequence is XP, and the hash value corresponding to the first string sequence is XPMD5. The hash value XPMD5 corresponding to the first string sequence is recorded in the standard array Y, and the summary array is sorted to obtain a first sorted array Z. Based on preset punctuation marks, the multiple relative path information in the first sorted array are spliced in the sorted order to obtain a second string sequence ZS. The preset punctuation mark is a comma. A second hash calculation is performed on the second string sequence using a preset hash function to obtain a hash value ZSMD5 corresponding to the second string sequence.
[0072] S3. Upload the hash value corresponding to the second character string sequence to a preset server for version difference package matching processing to obtain a matching result.
[0073] In the embodiment of the present invention, uploading the hash value corresponding to the second string sequence to a preset server for version difference package matching processing to obtain a matching result includes:
[0074] querying, based on the cache memory of the server, whether there is a difference package corresponding to the hash value corresponding to the second string sequence;
[0075] If the difference package exists in the cache memory, the matching result is that the difference package is matched;
[0076] If a complete packet exists in the cache memory, the matching result is that no difference packet is matched.
[0077] Among them, the cache memory only contains two situations: storing the difference package and storing the complete package. When the difference package exists in the cache memory, the matching result is judged as matching the difference package. Only when the complete package exists in the cache memory, the matching result is judged as not matching the difference package.
[0078] In detail, the server will receive the hash value and ZSMD5 value corresponding to the second string sequence uploaded by the client. If it is found that there is an incremental package, i.e., a diff package, in the cache memory on the server, the address of the diff package will be returned to the client, otherwise the complete package will be returned. The difference package refers to the sum of the difference files between the offline package file of a certain project and the new version offline package file of a certain project. The complete package refers to the file package that is consistent with the offline package of a certain project in terms of the new version offline package.
[0079] S4. If the matching result is that a difference package is matched, the matched difference package is used as an incremental package.
[0080] In the embodiment of the present invention, when the matching result is that a difference package is matched, the matched difference package is used as an incremental package, and the incremental package is generated according to the matching result, so as to improve the efficiency of the incremental package generation.
[0081] S5. If the matching result is that no difference package is matched, an incremental generation process is performed on the summary array to obtain an incremental package.
[0082] In the embodiment of the present invention, if the matching result is that no difference package is matched, it is necessary to perform incremental generation processing on the summary array.
[0083] Specifically, performing incremental generation processing on the sorted summary array to obtain an incremental package includes:
[0084] Obtaining new version information of the project to be released, and recording the new version information into a preset first array and a second array;
[0085] The new version information is processed in a loop to obtain a loop file, and a hash calculation is performed on the loop file to obtain a hash value corresponding to the loop file;
[0086] Recording the hash value corresponding to the loop file in the first array to obtain a first standard array, and recording the loop file in the second array to obtain a second standard array;
[0087] Sort the plurality of relative path information in the summary array by time to obtain a second sorted array, extract array values in the first standard array excluding the second sorted array, and obtain incremental paths corresponding to a plurality of array values in the second standard array according to positions of the array values in the second sorted array to which they belong;
[0088] An incremental package is generated according to the incremental path.
[0089] Further, generating an incremental package according to the incremental path includes:
[0090] Obtaining a preset incremental database, and performing an incremental query in the incremental database based on the incremental path;
[0091] The data corresponding to the incremental path in the incremental database is aggregated to generate an incremental package.
[0092] In detail, the new version information of the project to be released is a collection of relative path information of all files of the currently released version of project A, and the first array Y and the second array PATH are defined. The current loop file is recorded as X, the MD5 of X is calculated, and the file path is concatenated and recorded as a string XD, and then the MD5 value XDMD5 of the XD string is obtained. XDMD5 is appended to the first array Y, and the loop file X is appended to the second array PATH. The second sorted array P after the array is sorted from the client is received, and all non-existent array values N in the second sorted array P are checked from the first array Y, and based on the position of the array value N in the array P, the diff paths corresponding to all the array values N in the second array PATH are obtained, and diff packages are generated according to the diff paths.
[0093] Furthermore, after generating the incremental package according to the incremental path, the method further includes:
[0094] Uploading the incremental package to a preset content distribution network, and generating an incremental address corresponding to the incremental package;
[0095] Performing splicing processing on the second sorted arrays, and performing hash value calculation on the spliced second sorted arrays to obtain a spliced hash value;
[0096] A mapping relationship is formed based on the incremental address and the concatenated hash value, and the mapping relationship is stored in the cache memory.
[0097] Specifically, the second sorted array P is concatenated by commas to form a string PS, and then the MD5 value PSMD5 of the PS string is calculated, and the PSMD5 and the diff packet address are stored in a cache memory in a mapping relationship, waiting for query acquisition.
[0098] The embodiment of the present invention performs a first string concatenation process and a first hash calculation on the file information of the project to be published, obtains a first string sequence and a hash value corresponding to the first string sequence, obtains a specific hash value corresponding to the file information, summarizes the hash value corresponding to the first string sequence and the file information, obtains a summary array, performs a second string concatenation process and a second hash calculation on the summary array, obtains a second string sequence and a hash value corresponding to the second string sequence, obtains a hash value corresponding to the summary array, and uploads the hash value corresponding to the second string sequence to a preset server for version difference package matching processing to obtain a matching result. The hash value dynamically matches the version of the server end to solve the incremental package distribution problem of any version file. When a difference package is matched, the matched difference package is used as an incremental package. When the difference package is not matched, the summary array is incrementally generated to obtain an incremental package. The version difference package matching process can be judged according to the obtained matching result. Only when the difference package is not matched, the summary array will be incrementally generated. When the difference package is matched, the difference package is directly used as the incremental package, which can improve the efficiency of incremental package generation. Therefore, the incremental package generation method proposed in the present invention can solve the problem of insufficient efficiency of incremental package generation.
[0099] like Figure 2 , which is a functional module diagram of an incremental packet generation device provided by an embodiment of the present invention.
[0100] The incremental package generation device 100 of the present invention can be installed in an electronic device. According to the functions to be implemented, the incremental package generation device 100 may include a first hash value calculation module 101, a second hash value calculation module 102, a difference package matching module 103 and an incremental generation module 104. The module of the present invention may also be referred to as a unit, which refers to a series of computer program segments that can be executed by an electronic device processor and can complete fixed functions, which are stored in the memory of the electronic device.
[0101] In this embodiment, the functions of each module / unit are as follows:
[0102] The first hash value calculation module 101 is used to obtain file information of the project to be released, perform a first string concatenation process and a first hash calculation on the file information, and obtain a first string sequence and a hash value corresponding to the first string sequence;
[0103] The second hash value calculation module 102 is used to aggregate the hash value corresponding to the first string sequence and the file information to obtain a summary array, and perform a second string concatenation process and a second hash calculation on the summary array to obtain a second string sequence and a hash value corresponding to the second string sequence;
[0104] The difference package matching module 103 is used to upload the hash value corresponding to the second string sequence to a preset server for version difference package matching processing to obtain a matching result. If the matching result is that a difference package is matched, the matched difference package is used as an incremental package;
[0105] The incremental generation module 104 is used to perform incremental generation processing on the summary array to obtain an incremental package if the matching result is that no difference package is matched.
[0106] In detail, the specific implementation of each module of the incremental packet generation device 100 is as follows:
[0107] Step 1: Obtain file information of the project to be released, perform a first string concatenation process and a first hash calculation on the file information, and obtain a first string sequence and a hash value corresponding to the first string sequence.
[0108] In an embodiment of the present invention, the file information of the project to be released refers to the relative path information of all files of a function of a project. The file information of the relative file path of the project A to be released may be app / mall / home / a.png, app / mall / home / b.png, app / mall / home / c.png, app / mall / second / c.png, app / mall / second / d.png, app / mall / third / a.png, app / mall / third / b.png, app / mall / third / c.png.
[0109] Specifically, performing a first string concatenation process and a first hash calculation on the file information to obtain a first string sequence and a hash value corresponding to the first string sequence includes:
[0110] Extracting multiple relative path information of preset functions in the file information, and looping through the multiple relative path information to obtain a standard array;
[0111] Performing a first hash calculation on the standard array to obtain a hash value corresponding to the standard array;
[0112] Perform information splicing processing on the plurality of relative path information and the hash values corresponding to the standard array to obtain a first string sequence;
[0113] A first hash calculation is performed on the first string sequence to obtain a hash value corresponding to the first string sequence.
[0114] In detail, extracting multiple relative path information of preset functions in the file information refers to collecting relative path information of all files of a function in project A, and looping the relative path information to obtain a standard array Y. Performing information splicing processing on the multiple relative path information and the hash values corresponding to the standard array refers to splicing the relative path information with the hash values corresponding to the relative path information in the standard array to obtain a first string sequence XP, performing a first hash calculation on the first string sequence XP, and obtaining a hash value XPMD5 corresponding to the first string sequence.
[0115] For example, the standard array Y contains app / mall / home / a.png, app / mall / home / b.png, and app / mall / home / c.png. The standard array is hashed using a preset hash function to obtain a hash value corresponding to the standard array. Among them, the hash values corresponding to the standard array are b0a47be4ee5892f28287975dd21f1414, 3d79c2c777b61eb416bcf7ec61b4e204, and 0293fc37a1c083728a70bda0a7eff9da. The plurality of relative path information and the hash values corresponding to the standard array are spliced, wherein the information splicing is to splice the relative path information with the hash values in the standard array corresponding to the relative path information. The first string sequence is app / mall / home / a.png / b0a47be4ee5892f28287975dd21f1414, app / mall / home / b.png3d79c2c777b61eb416bcf7ec61b4e204, and app / mall / home / c.png0293fc37a1c083728a70bda0a7eff9da. A hash calculation is performed on the first string sequence XP to obtain a hash value corresponding to the first string sequence. For example, the hash value of the first string sequence app / mall / home / a.png / b0a47be4ee5892f28287975dd21f1414 is 563798740dafb43d0f8c7f443f882d72.
[0116] Step 2: Aggregate the hash value corresponding to the first string sequence with the file information to obtain a summary array, perform a second string concatenation process and a second hash calculation on the summary array to obtain a second string sequence and a hash value corresponding to the second string sequence.
[0117] In an embodiment of the present invention, the hash value corresponding to the first string sequence is aggregated with the file information, that is, the hash value corresponding to the first string sequence is aggregated with the standard array extracted from the file information, and the hash value corresponding to the first string sequence is added to the standard array to obtain a summarized array.
[0118] Specifically, performing a second string concatenation process and a second hash calculation on the summary array to obtain a second string sequence and a hash value corresponding to the second string sequence includes:
[0119] Sorting the plurality of pieces of relative path information in the summary array according to the names to obtain a first sorted array;
[0120] Based on preset punctuation marks, the plurality of relative path information in the first sorted array are concatenated in the order of sorting to obtain a second string sequence;
[0121] A second hash calculation is performed on the second string sequence using a preset hash function to obtain a hash value corresponding to the second string sequence.
[0122] In detail, the first string sequence is XP, and the hash value corresponding to the first string sequence is XPMD5. The hash value XPMD5 corresponding to the first string sequence is recorded in the standard array Y, and the summary array is sorted to obtain a first sorted array Z. Based on preset punctuation marks, the multiple relative path information in the first sorted array are spliced in the sorted order to obtain a second string sequence ZS. The preset punctuation mark is a comma. A second hash calculation is performed on the second string sequence using a preset hash function to obtain a hash value ZSMD5 corresponding to the second string sequence.
[0123] Step 3: Upload the hash value corresponding to the second string sequence to a preset server for version difference package matching processing to obtain a matching result.
[0124] In the embodiment of the present invention, uploading the hash value corresponding to the second string sequence to a preset server for version difference package matching processing to obtain a matching result includes:
[0125] querying, based on the cache memory of the server, whether there is a difference package corresponding to the hash value corresponding to the second string sequence;
[0126] If the difference package exists in the cache memory, the matching result is that the difference package is matched;
[0127] If a complete packet exists in the cache memory, the matching result is that no difference packet is matched.
[0128] Among them, the cache memory only contains two situations: storing the difference package and storing the complete package. When the difference package exists in the cache memory, the matching result is judged as matching the difference package. Only when the complete package exists in the cache memory, the matching result is judged as not matching the difference package.
[0129] In detail, the server will receive the hash value and ZSMD5 value corresponding to the second string sequence uploaded by the client. If it is found that there is an incremental package, i.e., a diff package, in the cache memory on the server, the address of the diff package will be returned to the client, otherwise the complete package will be returned. The difference package refers to the sum of the difference files between the offline package file of a certain project and the new version offline package file of a certain project. The complete package refers to the file package that is consistent with the offline package of a certain project in terms of the new version offline package.
[0130] Step 4: If the matching result is that a difference package is matched, the matched difference package is used as an incremental package.
[0131] In the embodiment of the present invention, when the matching result is that a difference package is matched, the matched difference package is used as an incremental package, and the incremental package is generated according to the matching result, so as to improve the efficiency of the incremental package generation.
[0132] Step 5: If the matching result is that no difference package is matched, the summary array is incrementally generated to obtain an incremental package.
[0133] In the embodiment of the present invention, if the matching result is that no difference package is matched, it is necessary to perform incremental generation processing on the summary array.
[0134] Specifically, performing incremental generation processing on the sorted summary array to obtain an incremental package includes:
[0135] Obtaining new version information of the project to be released, and recording the new version information into a preset first array and a second array;
[0136] The new version information is processed in a loop to obtain a loop file, and a hash calculation is performed on the loop file to obtain a hash value corresponding to the loop file;
[0137] Recording the hash value corresponding to the loop file in the first array to obtain a first standard array, and recording the loop file in the second array to obtain a second standard array;
[0138] Sorting the plurality of relative path information in the summary array according to time to obtain a second sorted array, extracting array values in the first standard array excluding the second sorted array, and obtaining incremental paths corresponding to a plurality of array values in the second standard array according to positions of the array values in the second sorted array to which they belong;
[0139] An incremental package is generated according to the incremental path.
[0140] Further, generating an incremental package according to the incremental path includes:
[0141] Obtaining a preset incremental database, and performing an incremental query in the incremental database based on the incremental path;
[0142] The data corresponding to the incremental path in the incremental database is aggregated to generate an incremental package.
[0143] In detail, the new version information of the project to be released is a collection of relative path information of all files of the currently released version of project A, and the first array Y and the second array PATH are defined. The current loop file is recorded as X, the MD5 of X is calculated, and the file path is concatenated and recorded as a string XD, and then the MD5 value XDMD5 of the XD string is obtained. XDMD5 is appended to the first array Y, and the loop file X is appended to the second array PATH. The second sorted array P after the array is sorted from the client is received, and all non-existent array values N in the second sorted array P are checked from the first array Y, and based on the position of the array value N in the array P, the diff paths corresponding to all the array values N in the second array PATH are obtained, and diff packages are generated according to the diff paths.
[0144] Furthermore, after the incremental package is generated according to the incremental path, the following steps are further performed:
[0145] Uploading the incremental package to a preset content distribution network, and generating an incremental address corresponding to the incremental package;
[0146] Performing splicing processing on the second sorted arrays, and performing hash value calculation on the spliced second sorted arrays to obtain a spliced hash value;
[0147] A mapping relationship is formed based on the incremental address and the concatenated hash value, and the mapping relationship is stored in the cache memory.
[0148] Specifically, the second sorted array P is concatenated by commas to form a string PS, and then the MD5 value PSMD5 of the PS string is calculated, and the PSMD5 and the diff packet address are stored in a cache memory in a mapping relationship, waiting for query acquisition.
[0149] The embodiment of the present invention performs a first string concatenation process and a first hash calculation on the file information of the project to be published, obtains a first string sequence and a hash value corresponding to the first string sequence, obtains a specific hash value corresponding to the file information, summarizes the hash value corresponding to the first string sequence and the file information, obtains a summary array, performs a second string concatenation process and a second hash calculation on the summary array, obtains a second string sequence and a hash value corresponding to the second string sequence, obtains a hash value corresponding to the summary array, and uploads the hash value corresponding to the second string sequence to a preset server for version difference package matching processing to obtain a matching result. The hash value dynamically matches the version of the server end to solve the incremental package distribution problem of any version file. When a difference package is matched, the matched difference package is used as an incremental package. When the difference package is not matched, the summary array is incrementally generated to obtain an incremental package. The version difference package matching process can be judged according to the obtained matching result. Only when the difference package is not matched, the summary array will be incrementally generated. When the difference package is matched, the difference package is directly used as the incremental package, which can improve the efficiency of incremental package generation. Therefore, the incremental package generation device proposed by the present invention can solve the problem of insufficient efficiency of incremental package generation.
[0150] like Figure 3 , which is a schematic diagram of the structure of an electronic device for implementing an incremental packet generation method provided by an embodiment of the present invention.
[0151] The electronic device 1 may include a processor 10, a memory 11, a communication bus 12, and a communication interface 13, and may also include a computer program stored in the memory 11 and executable on the processor 10, such as an incremental package generation program.
[0152] In some embodiments, the processor 10 may be composed of an integrated circuit, for example, a single packaged integrated circuit, or a plurality of integrated circuits with the same or different functions, including one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and combinations of various control chips. The processor 10 is the control core (ControlUnit) of the electronic device, and uses various interfaces and lines to connect various components of the entire electronic device, and executes or executes programs or modules stored in the memory 11 (for example, executing an incremental package generation program, etc.), and calls data stored in the memory 11 to execute various functions of the electronic device and process data.
[0153] The memory 11 includes at least one type of readable storage medium, and the readable storage medium includes a flash memory, a mobile hard disk, a multimedia card, a card-type memory (for example, an SD or DX memory, etc.), a magnetic memory, a disk, an optical disk, etc. In some embodiments, the memory 11 may be an internal storage unit of an electronic device, such as a mobile hard disk of the electronic device. In other embodiments, the memory 11 may also be an external storage device of an electronic device, such as a plug-in mobile hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the electronic device. Furthermore, the memory 11 may also include both an internal storage unit of the electronic device and an external storage device. The memory 11 can not only be used to store application software and various types of data installed in the electronic device, such as the code of the incremental package generation program, but also can be used to temporarily store data that has been output or is to be output.
[0154] The communication bus 12 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. The bus is configured to realize connection and communication between the memory 11 and at least one processor 10, etc.
[0155] The communication interface 13 is used for communication between the above-mentioned electronic device and other devices, including a network interface and a user interface. Optionally, the network interface may include a wired interface and / or a wireless interface (such as a WI-FI interface, a Bluetooth interface, etc.), which is generally used to establish a communication connection between the electronic device and other electronic devices. The user interface may be a display (Display), an input unit (such as a keyboard (Keyboard)), and optionally, the user interface may also be a standard wired interface, a wireless interface. Optionally, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, and an OLED (Organic Light-Emitting Diode, organic light-emitting diode) touch device, etc. Among them, the display may also be appropriately referred to as a display screen or a display unit, which is used to display information processed in the electronic device and to display a visual user interface.
[0156] Figure 3 Only an electronic device with components is shown, and those skilled in the art will understand that Figure 3 The structure shown does not constitute a limitation on the electronic device 1, and may include fewer or more components than shown in the figure, or combine certain components, or arrange the components differently.
[0157] For example, although not shown, the electronic device may also include a power source (such as a battery) for supplying power to each component. Preferably, the power source may be logically connected to the at least one processor 10 through a power management device, so that the power management device can realize functions such as charging management, discharging management, and power consumption management. The power source may also include one or more DC or AC power sources, recharging devices, power failure detection circuits, power converters or inverters, power status indicators, and other arbitrary components. The electronic device may also include a variety of sensors, Bluetooth modules, Wi-Fi modules, etc., which will not be repeated here.
[0158] It should be understood that the embodiment is for illustration only and the scope of the patent application is not limited to this structure.
[0159] The incremental packet generation program stored in the memory 11 of the electronic device 1 is a combination of multiple instructions. When running in the processor 10, it can achieve:
[0160] Acquire file information of the project to be published, perform first string concatenation processing and first hash calculation on the file information, and obtain a first string sequence and a hash value corresponding to the first string sequence;
[0161] Aggregate the hash value corresponding to the first string sequence and the file information to obtain a summary array, perform a second string concatenation process and a second hash calculation on the summary array to obtain a second string sequence and a hash value corresponding to the second string sequence;
[0162] Uploading the hash value corresponding to the second string sequence to a preset server for version difference package matching processing to obtain a matching result;
[0163] If the matching result is that a difference package is matched, the matched difference package is used as an incremental package;
[0164] If the matching result is that no difference package is matched, an incremental generation process is performed on the summary array to obtain an incremental package.
[0165] Specifically, the specific implementation method of the processor 10 for the above instructions can refer to the description of the relevant steps in the corresponding embodiment of the accompanying drawings, which will not be repeated here.
[0166] Furthermore, if the module / unit integrated in the electronic device 1 is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. The computer-readable storage medium can be volatile or non-volatile. For example, the computer-readable medium can include: any entity or device capable of carrying the computer program code, a recording medium, a USB flash drive, a mobile hard disk, a magnetic disk, an optical disk, a computer memory, and a read-only memory (ROM).
[0167] The present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor of an electronic device, the computer program can implement:
[0168] Acquire file information of the project to be published, perform first string concatenation processing and first hash calculation on the file information, and obtain a first string sequence and a hash value corresponding to the first string sequence;
[0169] Aggregate the hash value corresponding to the first string sequence and the file information to obtain a summary array, perform a second string concatenation process and a second hash calculation on the summary array to obtain a second string sequence and a hash value corresponding to the second string sequence;
[0170] Uploading the hash value corresponding to the second string sequence to a preset server for version difference package matching processing to obtain a matching result;
[0171] If the matching result is that a difference package is matched, the matched difference package is used as an incremental package;
[0172] If the matching result is that no difference package is matched, an incremental generation process is performed on the summary array to obtain an incremental package.
[0173] In the several embodiments provided by the present invention, it should be understood that the disclosed devices, apparatuses and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of the modules is only a logical function division, and there may be other division methods in actual implementation.
[0174] The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0175] In addition, each functional module in each embodiment of the present invention may be integrated into one processing unit, each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of hardware plus software functional modules.
[0176] It is obvious to those skilled in the art that the present invention is not limited to the details of the above exemplary embodiments, and that the present invention can be implemented in other specific forms without departing from the spirit or essential characteristics of the present invention.
[0177] Therefore, no matter from which point of view, the embodiments should be regarded as illustrative and non-restrictive, and the scope of the present invention is limited by the appended claims rather than the above description, so it is intended that all changes falling within the meaning and scope of the equivalent elements of the claims are included in the present invention. Any attached figure mark in the claims should not be regarded as limiting the claims involved.
[0178] The blockchain referred to in this invention is a new application mode of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm, etc. Blockchain is essentially a decentralized database, a string of data blocks generated by cryptographic methods. Each data block contains a batch of network transaction information, which is used to verify the validity of its information (anti-counterfeiting) and generate the next block. Blockchain can include the underlying blockchain platform, platform product service layer, and application service layer.
[0179] The embodiments of the present application can acquire and process relevant data based on artificial intelligence technology. Among them, artificial intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.
[0180] In addition, it is clear that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. Multiple units or devices stated in the system claim can also be implemented by one unit or device through software or hardware. The words first, second, etc. are used to indicate names, and do not indicate any particular order.
[0181] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solution of the present invention can be modified or replaced by equivalents without departing from the spirit and scope of the technical solution of the present invention.
Claims
1. A method for generating an incremental package, It is characterized in that The method comprises: Acquire file information of the project to be published, perform first string concatenation processing and first hash calculation on the file information, and obtain a first string sequence and a hash value corresponding to the first string sequence; Aggregate the hash value corresponding to the first string sequence and the file information to obtain a summary array, perform a second string concatenation process and a second hash calculation on the summary array to obtain a second string sequence and a hash value corresponding to the second string sequence; Uploading the hash value corresponding to the second string sequence to a preset server for version difference package matching processing to obtain a matching result; If the matching result is that a difference package is matched, the matched difference package is used as an incremental package; If the matching result is that no difference package is matched, performing incremental generation processing on the summary array to obtain an incremental package; The performing of the first string concatenation processing and the first hash calculation on the file information to obtain a first string sequence and a hash value corresponding to the first string sequence includes: extracting multiple relative path information of preset functions in the file information, and performing loop processing on the multiple relative path information to obtain a standard array; performing the first hash calculation on the standard array to obtain a hash value corresponding to the standard array; performing information concatenation processing on the multiple relative path information and the hash values corresponding to the standard array to obtain a first string sequence; performing the first hash calculation on the first string sequence to obtain a hash value corresponding to the first string sequence; The performing a second string concatenation process and a second hash calculation on the summary array to obtain a second string sequence and a hash value corresponding to the second string sequence includes: sorting the plurality of relative path information in the summary array according to the name to obtain a first sorted array; concatenating the plurality of relative path information in the first sorted array in the sorted order based on preset punctuation marks to obtain a second string sequence; performing a second hash calculation on the second string sequence using a preset hash function to obtain a hash value corresponding to the second string sequence; The incremental generation processing of the summary array to obtain an incremental package includes: obtaining new version information of the to-be-released project, and recording the new version information into a preset first array and a second array; loop processing the new version information to obtain a loop file, and hashing the loop file to obtain a hash value corresponding to the loop file; recording the hash value corresponding to the loop file in the first array to obtain a first standard array, and recording the loop file in the second array to obtain a second standard array; sorting the multiple relative path information in the summary array according to time to obtain a second sorted array, extracting the array value of the first standard array excluding the second sorted array, and obtaining the incremental paths corresponding to the multiple array values in the second standard array according to the position of the array value in the second sorted array; and generating an incremental package according to the incremental path.
2. The incremental packet generation method according to claim 1, It is characterized in that The step of uploading the hash value corresponding to the second string sequence to a preset server for version difference package matching processing to obtain a matching result includes: querying, based on the cache memory of the server, whether there is a difference package corresponding to the hash value corresponding to the second string sequence; If the difference package exists in the cache memory, the matching result is that the difference package is matched; If a complete packet exists in the cache memory, the matching result is that no difference packet is matched.
3. The incremental packet generation method according to claim 1, It is characterized in that The step of generating an incremental package according to the incremental path includes: Obtaining a preset incremental database, and performing an incremental query in the incremental database based on the incremental path; The data corresponding to the incremental path in the incremental database is aggregated to generate an incremental package.
4. The incremental packet generation method according to claim 2, It is characterized in that After generating the incremental package according to the incremental path, the method further includes: Uploading the incremental package to a preset content distribution network, and generating an incremental address corresponding to the incremental package; Performing splicing processing on the second sorted arrays, and performing hash value calculation on the spliced second sorted arrays to obtain a spliced hash value; A mapping relationship is formed based on the incremental address and the concatenated hash value, and the mapping relationship is stored in the cache memory.
5. An incremental packet generation device, used to implement the incremental packet generation method according to any one of claims 1 to 4, It is characterized in that The device comprises: A first hash value calculation module is used to obtain file information of a project to be released, perform a first string concatenation process and a first hash calculation on the file information, and obtain a first string sequence and a hash value corresponding to the first string sequence; A second hash value calculation module is used to aggregate the hash value corresponding to the first string sequence and the file information to obtain a summary array, and perform a second string concatenation process and a second hash calculation on the summary array to obtain a second string sequence and a hash value corresponding to the second string sequence; a difference package matching module, used for uploading the hash value corresponding to the second string sequence to a preset server for version difference package matching processing to obtain a matching result, and if the matching result is a match to a difference package, using the matched difference package as an incremental package; The incremental generation module is used to perform incremental generation processing on the summary array to obtain an incremental package if the matching result is that no difference package is matched.
6. An electronic device, It is characterized in that The electronic device comprises: at least one processor; and, a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the incremental packet generation method as described in any one of claims 1 to 4.
7. A computer-readable storage medium storing a computer program, It is characterized in that When the computer program is executed by a processor, the incremental packet generation method as described in any one of claims 1 to 4 is implemented.
