Differential data determination method, differential restoration method, device, equipment and medium
Through differential processing of the core area of target compression packages and the core area to be upgraded to upgrade, determine the differential files and differential data packets, solve the problem of poor differential reduction effects caused by non -differential and friendly data, and achieve streamlined and accurate differential data packets. And accurate file header restore.
Patent Information
- Application Number
- CN202311074562.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-24
- Publication Date
- 2025-01-28
- Estimated Expiration
- 2043-08-24
AI Technical Summary
During the differential upgrade process, non-differential friendly data leads to poor differential restoration effect, and it is impossible to accurately obtain the differential data of new and old software.
Differential processing is performed by the core area of the target compression package and the core area to be upgraded to upgrade, the core area differential packet is obtained, and the central directory recording area is used to determine the first file collection table and the second file collection table to determine the differential files and differential packet packets Essence
A streamlined and accurate differential data packets are realized, with less space occupation, and can accurately restore the file head data of the target compressed package, solving the problem of poor differential reduction effects caused by non -differential and friendly data.
Smart Images

Figure CN117112004B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computers, and in particular to a differential data determination method, a differential restoration method, a device, a equipment and a medium. Background Art
[0002] At present, software upgrades usually use differential upgrades. Differential upgrades can be understood as the device actively reporting the currently running software version to the cloud server. After receiving the report, the cloud server determines whether there is a new software version. If there is a newer software version, the new version of the software is differentially calculated with the software version currently running on the device to obtain the differential data of the new and old versions, and send it to the device. The device receives the differential data and combines it with the currently running software to complete the upgrade from the old version to the new software version. The advantage of using differential upgrades is that the amount of downloaded data is small, the demand for network traffic is small, and the device storage space is also smaller.
[0003] However, during the differential upgrade process, it is necessary to ensure that the data in the new and old software versions involved in the differential cannot be non-differential friendly data that is not suitable for differential (non-differential friendly data can be understood as data whose encoding is completely changed due to secondary encoding and cannot be compared with the original data for similarity). The secondary encoded data in the file has no similarity with the original encoding, resulting in a large number of differences after secondary encoding even if the new software version and the old software version only modify a small part of the data, making it impossible to obtain accurate differential data between the new and old software by comparing the new and old software. Summary of the invention
[0004] The present invention provides a differential data determination method, a differential restoration method, an apparatus, a device and a medium to solve the problem of poor differential restoration effect on non-differential friendly data.
[0005] In a first aspect, the present invention provides a differential data determination method, comprising:
[0006] Performing differential processing on the core areas of the target compressed package and the compressed package to be upgraded to obtain a core area differential data packet, and using the central directory record area of the core area to determine a first file set table and a second file set table, wherein the core area at least includes the central directory record area, the first file set table contains the file name recorded in the central directory record area of the target compressed package, and the second file set table contains the file name recorded in the central directory record area of the compressed package to be upgraded;
[0007] Determine difference files by using the first file set table and the second file set table;
[0008] The differential data package is determined by using the differential file and the core area differential data package.
[0009] In a second aspect, the present invention provides a differential restoration method, comprising:
[0010] Obtaining a differential data packet, and using the differential data packet and the compressed package to be upgraded to differentially restore the core area of the target compressed package to obtain a restored core area, wherein the differential data packet is obtained by the differential data determination method as described in the first aspect above;
[0011] Restoring the file header of the target compressed package by using the central directory record area in the restoration core area to obtain a restored file header;
[0012] The file data of the target compressed package is restored using the differential data package to obtain restored file data.
[0013] In a third aspect, the present invention provides a differential data determination device, comprising:
[0014] A file collection table determination module is used to perform differential processing on the core areas of the target compressed package and the compressed package to be upgraded to obtain a core area differential data packet, and determine a first file collection table and a second file collection table using a central directory record area of the core area, wherein the core area at least includes the central directory record area, the first file collection table contains the file name recorded in the central directory record area of the target compressed package, and the second file collection table contains the file name recorded in the central directory record area of the compressed package to be upgraded;
[0015] A difference file determination module, used for determining a difference file by using the first file set table and the second file set table;
[0016] The differential data determination module is used to determine the differential data packet using the differential file and the core area differential data packet.
[0017] In a fourth aspect, the present invention provides a differential restoration device, comprising:
[0018] a core area restoration module, used to obtain a differential data packet, and use the differential data packet and the compressed package to be upgraded to differentially restore the core area of the target compressed package to obtain a restored core area, wherein the differential data packet is obtained by the differential data determination method according to any one of claims 1 to 6;
[0019] A file header restoration module, used to restore the file header of the target compressed package by using the central directory record area in the restoration core area to obtain a restored file header;
[0020] The restoration module is used to restore the file data of the target compressed package using the differential data package to obtain the restored file data.
[0021] In a fifth aspect, the present invention provides an electronic device, the electronic device comprising:
[0022] at least one processor;
[0023] and a memory communicatively coupled to the at least one processor;
[0024] Among them, the memory stores a computer program that can be executed by at least one processor, and the computer program is executed by at least one processor so that the at least one processor can execute the differential data determination method of the first aspect mentioned above, and / or execute the differential restoration method of the second aspect mentioned above.
[0025] In a sixth aspect, the present invention provides a computer-readable storage medium storing computer instructions, which are used to enable a processor to implement the differential data determination method of the first aspect and / or the differential restoration method of the second aspect when executed.
[0026] The differential data determination scheme provided by the present invention performs differential processing on the core areas of the target compressed package and the compressed package to be upgraded to obtain a core area differential data packet, and uses the central directory record area of the core area to determine a first file collection table and a second file collection table, wherein the core area at least includes the central directory record area, the first file collection table contains the file name recorded in the central directory record area of the target compressed package, and the second file collection table contains the file name recorded in the central directory record area of the compressed package to be upgraded, the first file collection table and the second file collection table are used to determine the differential file, and the differential data packet is determined using the differential file and the core area differential data packet. By adopting the above technical solution, the differential data packets of the target compressed package and the compressed package to be upgraded can be determined by using the core area differential data packets and differential files. Compared with the traditional method of directly performing differential calculations on the data packets, this method obtains a concise and accurate differential data packet by determining the differential file. The determined differential data packet occupies less space, and by performing differential processing on the core areas of the target compressed package and the compressed package to be upgraded, it is ensured that the core area differential data packet in the differential data packet can be used during differential restoration to accurately restore the file header data of the target compressed package, and differentially processes the compressed package containing non-differential friendly data in a friendly manner.
[0027] The differential data determination scheme provided by the present invention obtains a differential data packet, and uses the differential data packet and the compressed package to be upgraded to differentially restore the core area of the target compressed package to obtain the restored core area, wherein the differential data packet is obtained by the differential data determination method described above, and the central directory record area in the restored core area is used to restore the file header of the target compressed package to obtain the restored file header, and the differential data packet is used to restore the filedata data of the target compressed package to obtain the restored file data. By adopting the above technical scheme, the core area of the target compressed package can be restored using the differential data packet and the compressed package to be upgraded, and then the core area and the differential data packet can be used to make the file data and file head (file header) data generated after restoration completely consistent with the data in the target compressed package participating in the differential calculation, thereby solving the problem of poor differential restoration effect caused by the existence of non-differential friendly data.
[0028] It should be understood that the content described in this section is not intended to identify the key or important features of the present invention, nor is it intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0030] Figure 1 is a flow chart of a differential data determination method provided according to Embodiment 1 of the present invention;
[0031] Figure 2 is a schematic diagram of a data structure of a Zip compression package provided according to Embodiment 1 of the present invention;
[0032] Figure 3 This is a schematic diagram of the data structure of an Apk compression package provided according to the first embodiment of the present invention;
[0033] Figure 4 is a schematic diagram of an ApkSigningBlock data structure provided according to Embodiment 1 of the present invention;
[0034] Figure 5 is a flow chart of a differential data determination method provided according to Embodiment 2 of the present invention;
[0035] Figure 6 is a schematic diagram of a differential processing principle provided according to Embodiment 2 of the present invention;
[0036] Figure 7 is a flowchart of another differential data determination method provided according to Embodiment 3 of the present invention;
[0037] Figure 8 is a flow chart of a differential restoration method provided according to Embodiment 4 of the present invention;
[0038] Fig. 9 is a structural schematic diagram of a differential data determination device provided according to Embodiment 5 of the present invention;
[0039] Fig.10 is a structural schematic diagram of a differential restoration device provided according to Embodiment 6 of the present invention;
[0040] Fig.11 It is a structural schematic diagram of an electronic device provided according to Embodiment 7 of the present invention. DETAILED DESCRIPTION
[0041] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0042] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In the description of the present invention, unless otherwise specified, "multiple" refers to two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist, for example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the objects associated before and after are an "or" relationship. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0043] For conventional software upgrades, you can first decompress it in the cloud, then perform differential operations to obtain differential data, and then decompress it on the device side as required, then restore the differential data, and then recompress the file package after restoration. The cost of doing this is that both the device side and the cloud side need to provide additional storage space for caching the decompressed intermediate files, or provide additional memory to decompress the data into the memory, and due to issues such as compression time and modification time, the final compressed file may be slightly different from the original compressed file. For Apk (Android Application Package), due to the signing method after Apk V2.0, signature data will be written in the compressed file, which makes Apk unable to be decompressed in the ordinary way, otherwise the signature information in the Apk compressed file will be destroyed, and the difference caused by recompression cannot pass the data signature verification.
[0044] Currently, there are two main solutions for differential restoration of compressed files (such as installation packages of software to be upgraded): 1. Perform differential restoration on ordinary files after decompression; 2. Accept the reality that the differential effect is not ideal and directly perform rough differential restoration on the compressed files.
[0045] The above two existing methods have the following advantages and disadvantages:
[0046] 1) Perform differential restoration on the decompressed common files:
[0047] Principle: Before differential, it takes time and space to decompress the source data compression package and the target data compression package into source data files and target data files respectively, so as to facilitate differential restoration. And when restoring, the source data compression package needs to be decompressed into the source data file (corresponding to the differential calculation), so as to generate the target data file by combining the differential data. Finally, the generated target data file is compressed into the target data package.
[0048] Disadvantages: waste of time and space. There is a difference in compression information between the restored target data compression package and the target data compression package during differential. It is impossible to restore applications with Android Apk V2 signature or above.
[0049] 2) Perform a rough difference directly on the compressed file:
[0050] Principle: Directly use string difference calculation algorithms such as BSDIFF to perform difference calculation on the source data compression package and the target data compression package.
[0051] Disadvantages: Since the difference is directly made on the compressed and encoded data, the source data and the target data are not difference-friendly, and a smaller difference packet cannot be obtained. In addition, during the difference calculation process, the amount of analysis is large and the analysis takes longer.
[0052] Embodiment 1
[0053] Figure 1 A flowchart of a differential data determination method is provided for the first embodiment of the present invention. This embodiment can be applied to determining the differential data between a compressed file to be upgraded and a target compressed package generated after compression by a compression algorithm such as deflate. The method can be executed by a differential data determination device. The differential data determination device can be implemented in the form of hardware and / or software. The differential data determination device can be configured in an electronic device. The electronic device can be composed of two or more physical entities or one physical entity.
[0054] like Figure 1 As shown, a differential data determination method provided in the first embodiment of the present invention specifically includes the following steps:
[0055] S101, performing differential processing on the core areas of the target compressed package and the compressed package to be upgraded to obtain a core area differential data packet, and using the central directory record area of the core area to determine a first file set table and a second file set table.
[0056] Among them, the core area at least includes the central directory record area, the first file collection table contains the file name recorded in the central directory record area of the target compressed package, and the second file collection table contains the file name recorded in the central directory record area of the compressed package to be upgraded.
[0057] In this embodiment, the target compressed package can be understood as a compressed package different from the compressed package to be upgraded, and the compressed package to be upgraded can be a Zip compressed package, an Apk compressed package, and the like. Figure 2 A schematic diagram of the data structure of a Zip compression package is shown in FIG. Figure 2 As shown, the format of the Zip compression package is mainly composed of three parts: 1) Data area: stores compressed file data. Each file in the Zip package has its own unique data area. Each data area is divided into two parts: the compressed information header file head and the compressed data file data. 2) Central directory record area (also called core directory record): stores the relevant information of the compressed file, such as the file name, the size before and after compression, the compression method, etc. (Note: the central directory record area is similar to an archive list, which records the file information in the data area in a unified manner). 3) Central directory record tail area: used to mark the end position of the central directory record area. Assume that there is a Zip compression package containing N files, and the contents contained therein can be shown in the following Table 1 file head directory table, Table 2 central directory record area directory table and Table 3 central directory record tail area directory table:
[0058] Table 1 file head directory table
[0059] Offset Bytes Description 0 4 File header identifier: 0x04034b50 4 2 Unzip the file to the required version 6 2 General bit flag 8 2 Compression method 10 2 The time when the file was last modified 12 2 Date the file was last modified 14 4 CRC-32 checksum 18 4 Compressed size 22 4 Uncompressed size 26 2 File name length 28 2 Extension area length 30 n file name 30+n m Extension Area
[0060] Table 2 Central Directory Record Area Directory Table
[0061]
[0062]
[0063] Table 3 Central Directory Record Tail Area Directory Table
[0064] Offset Bytes Description 0 4 End of central directory marker: 0x06054b50 4 2 Current disk number 6 2 The disk number where the central directory starts 8 2 The number of central directories recorded on this disk 10 2 Total number of central directory structures 12 4 Size of the central directory 16 4 Relative displacement of the start position of the central directory 20 2 Comment Length 22 n Note content
[0065] Figure 3 This is a schematic diagram of the data structure of an Apk compression package. Figure 3 As shown, the format of the Apk compressed package is almost the same as the format of the Zip compressed package, except that the ApkSigningBlock (APK signature block) part is added on the basis of the Zip format, which is used to verify the integrity of the Apk.
[0066] Specifically, the main data in the Zip and Apk compressed packages are in the file data, and the file data of the Zip and Apk compressed packages using the deflate algorithm may only exist in two situations: only storage (original file encoding) and deflate encoding compression. When the file data of the target compressed package and the compressed package to be upgraded are completely consistent, the filehead may be different due to reasons such as compression level, file time attribute (last modification time), compression description information, and file compression order, resulting in multiple differential restorations, and the information in the target compressed package cannot be completely restored. However, the information in the file head is fully recorded in the corresponding central directory area. When restoring, the core area where the central directory is located can be restored first, and all file heads can be restored. Therefore, for the Apk compressed package, at least the ApkSigningBlock, the central directory record area, and the central directory record tail area can be recorded as the core area. For the Zip compressed package, at least the central directory record area and the central directory record tail area can be recorded as the core area. According to the above, we can know that at the end of the Zip and Apk compression packages is the central directory record tail area, which can be used to determine the entire central directory record area, and the central directory record area records the compressed file information and the specific storage location after the file is compressed. Figure 4 Figure 1 is a schematic diagram of the ApkSigningBlock data structure. Figure 4As shown, if the 16 bytes of data before the central directory record area are the characteristic code "APK Sig Block 42" of the ApkSigningBlock, it means that it is necessary to obtain the complete ApkSigningBlock data based on the size of the Apk signature block, so that the data of the entire core area can be determined. Then, the core areas of the target compressed package and the compressed package to be upgraded are differentially processed to obtain the core area differential data packet. If the data of the core areas of the target compressed package and the compressed package to be upgraded are exactly the same, it means that the target compressed package and the compressed package to be upgraded are exactly the same, and you can exit directly. The file names in the central directory record area of the core area can be integrated to obtain the first file collection table of the target compressed package and the second file collection table of the compressed package to be upgraded.
[0067] S102: Determine difference files by using the first file set table and the second file set table.
[0068] In this embodiment, by comparing the first file set table with the second file set table, a difference file in the target compressed package can be determined, and the difference file can be understood as a file that is different from the file in the compressed package to be upgraded. For example, a file corresponding to a file name that only exists in the first file set table can be determined as a difference file.
[0069] S103: Determine a differential data package using the differential file and the core area differential data package.
[0070] In this embodiment, the difference file may be subjected to a preset process, such as compression, and then the preset processed data and the core area differential data packet may be packaged to obtain a differential data packet.
[0071] The differential data determination method provided by the embodiment of the present invention performs differential processing on the core areas of the target compressed package and the compressed package to be upgraded to obtain a core area differential data packet, and uses the central directory record area of the core area to determine a first file collection table and a second file collection table, wherein the core area at least includes the central directory record area, the first file collection table contains the file name recorded in the central directory record area of the target compressed package, and the second file collection table contains the file name recorded in the central directory record area of the compressed package to be upgraded, the first file collection table and the second file collection table are used to determine the differential file, and the differential data packet is determined using the differential file and the core area differential data packet. The technical solution of the embodiment of the present invention utilizes the core area differential data packet and the differential file to determine the differential data packet of the target compressed package and the compressed package to be upgraded. Compared with the traditional method of directly performing differential calculation on the data packet, the method obtains a concise and accurate differential data packet by determining the differential file. The determined differential data packet occupies less space, and by performing differential processing on the core areas of the target compressed package and the compressed package to be upgraded, it is ensured that the core area differential data packet in the differential data packet can be used during differential restoration to accurately restore the file header data of the target compressed package, and differential-friendly processing includes compressed packages with non-differential-friendly data.
[0072] Optionally, the use of the first file collection table and the second file collection table to determine the difference file includes: comparing the first file collection table and the second file collection table, determining the file corresponding to the file name that only exists in the first file collection table as a newly added file; and / or determining the file corresponding to the file name that exists in both the first file collection table and the second file collection table as a changed file; wherein both the changed file and the newly added file are the difference files. The advantage of such a setting is that by comparing the first file collection table and the second file collection table, files that may be different from the files in the compressed package to be upgraded can be accurately screened out from the multiple files contained in the target compressed package.
[0073] Specifically, for the compressed package to be upgraded, the file corresponding to the file name that only exists in the first file collection table is a newly added file, so the file can be determined as a newly added file in the difference file, and the file corresponding to the file name that exists in the first file collection table and the second file collection table can be determined as a changed file. Although the file name of the file is consistent in the compressed package to be upgraded and the target compressed package, the content of the file may have changed. Among them, if there is a file corresponding to the file name that only exists in the second file collection table, it means that the file is an invalid reference to the target compressed package, and the file does not belong to the difference file.
[0074] Embodiment 2
[0075] Figure 5 This is a flow chart of a method for determining differential data provided in the second embodiment of the present invention. The technical solution of the embodiment of the present invention is further optimized on the basis of the above-mentioned optional technical solutions, and a specific method for determining differential data is given.
[0076] Optionally, the differential data packet is determined by using the differential file and the core area differential data packet, including: if the differential file contains the newly added file, then according to the central directory record area of the target compressed package, determine whether the newly added file has been compressed by the first preset compression algorithm; if not, then determine the differential data packet according to the first target data packet and the core area differential data packet, wherein the first target data packet at least includes the file name of the newly added file in the file header data of the target compressed package, the newly added file, and the first preset operation type, and the first preset operation type is used to indicate that the newly added file is written to the preset location of the software to be upgraded when performing differential restore upgrade on the software to be upgraded. The advantage of such a setting is that by packaging the newly added file that has not been compressed by the first preset compression algorithm, the file name, the newly added file, the first preset operation type, and the core area differential data packet in the file header data of the target compressed package, not only the differential data packet is quickly generated, but also a smaller memory space is occupied, and better efficiency is achieved in the corresponding restoration process.
[0077] Optionally, after determining whether the newly added file has been compressed by the first preset compression algorithm, it also includes: if so, decompressing the newly added file to obtain a decompressed file, and compressing the decompressed file using a second preset compression algorithm to obtain a compressed file, wherein the second preset compression algorithm is different from the first preset compression algorithm; judging whether the compressed file is smaller than the decompressed file; if greater, determining a differential data packet based on a second target data packet and the core area differential data packet, wherein the second target data packet at least includes the file name of the newly added file in the file header data of the target compressed data packet, the decompressed file, and the first preset operation type; if less than or equal to, determining a differential data packet based on a third target data packet and the core area differential data packet, wherein the third target data packet at least includes the file name of the newly added file in the file header data of the target compressed data packet, the compressed file, and the second preset operation type, and the second preset operation type is used to indicate that the data obtained after decompression of the compressed file is used to restore the newly added file in the target compressed data packet when performing differential restore upgrade on the software to be upgraded. The advantage of this setting is that by decompressing the compressed new files and then highly compressing them, the simplicity of the differential data packet is further guaranteed while ensuring that no compression information is lost, making the differential packet data more efficient in network transmission.
[0078] like Figure 5 As shown, a differential data determination method provided by Embodiment 2 of the present invention specifically includes the following steps:
[0079] S201, performing differential processing on the core areas of the target compressed package and the compressed package to be upgraded to obtain a core area differential data packet, and using the central directory record area of the core area to determine a first file set table and a second file set table.
[0080] S202: Compare the first file set table with the second file set table, and determine the file corresponding to the file name that only exists in the first file set table as a newly added file.
[0081] S203, determining whether the newly added file has been compressed by the first preset compression algorithm according to the central directory record area of the target compression package, if not, executing step 204, if yes, executing step 205.
[0082] Exemplarily, if the first preset compression algorithm is the deflate compression algorithm, when the difference file contains only newly added files, it can be determined whether the current newly added files have been compressed by the deflate compression algorithm. Among them, the files in the Zip and Apk compression packages compressed by the deflate compression algorithm contain two existence modes, one is storage only, and the other is deflate compression. The reason is that during the compression process, if the compression result is larger than the original data, the file will be directly packaged in a storage-only mode.
[0083] S204: Determine a differential data packet according to the first target data packet and the core area differential data packet.
[0084] Among them, the first target data packet at least includes the file name of the newly added file in the file header data of the target compressed package, the newly added file and a first preset operation type, and the first preset operation type is used to instruct the newly added file to be written to the preset location of the software to be upgraded when performing differential restoration upgrade on the software to be upgraded.
[0085] Specifically, if the newly added file has not been compressed by the deflate compression algorithm, the newly added file can be directly included, that is, the file name of the newly added file in the file head data of the target compressed package, the newly added file, the first preset operation type and the core area differential data packet are packaged to obtain a differential data packet. Among them, the first preset operation type can be recorded as adding, which can indicate that the newly added file is written to the specified location of the software to be upgraded when performing differential restoration upgrade on the software to be upgraded, and the specified location corresponds to the location of the newly added file in the target compressed package.
[0086] S205: decompress the newly added file to obtain a decompressed file, and compress the decompressed file using a second preset compression algorithm to obtain a compressed file.
[0087] The second preset compression algorithm is different from the first preset compression algorithm.
[0088] Specifically, if the newly added file is compressed by the deflate compression algorithm, the newly added file can be first decompressed to obtain a decompressed file, and then the decompressed file is compressed by the second preset compression algorithm to obtain a compressed file. The second preset compression algorithm can be a best compression algorithm determined after compression by multiple compression algorithms such as LZMA (Lempel-Ziv-Markov chain-Algorithm) and comparison of compression effects.
[0089] S206, determine whether the compressed file is less than or equal to the decompressed file, if not, execute step 207, if yes, execute step 208.
[0090] Specifically, a threshold value can be set in advance, such as 10 kilobytes. When the difference in size between the compressed file and the decompressed file is greater than the set threshold value, it can be determined that the compressed file is larger than the decompressed file. When the difference in size between the compressed file and the decompressed file is less than or equal to the set threshold value, it can be determined that the compressed file is less than or equal to the decompressed file.
[0091] S207: Determine a differential data packet according to the second target data packet and the core area differential data packet.
[0092] The second target data packet at least includes the file name of the newly added file in the file header data of the target compressed package, the decompressed file, and the first preset operation type.
[0093] Specifically, if the compressed file after compression is larger than the decompressed file before compression, the file name, decompressed file, first preset operation type and core area differential data packet of the current newly added file in the file header data of the target compressed package can be packaged to obtain a differential data packet.
[0094] S208. Determine a differential data packet according to the third target data packet and the core area differential data packet.
[0095] Among them, the third target data packet at least includes the file name of the newly added file in the file header data of the target compressed package, the compressed file and a second preset operation type, and the second preset operation type is used to indicate the use of data obtained after decompressing the compressed file to restore the newly added file in the target compressed package when performing a differential restoration upgrade on the software to be upgraded.
[0096] Specifically, if the compressed file after compression is less than or equal to the decompressed file before compression, the file name, compressed file, second preset operation type and core area differential data packet of the current newly added file in the file header data of the target compressed package can be packaged to obtain a differential data packet. Among them, the second preset operation type can be recorded as compression increase.
[0097] The differential data determination method provided by the embodiment of the present invention, when a target compressed package contains a newly added file, not only quickly generates a differential data package, but also occupies a smaller memory space, and then highly compresses the compressed newly added file after decompression, thereby further ensuring the simplicity of the differential data package on the basis of ensuring that no compression information is lost, by packaging the file name, the newly added file, the first preset operation type and the core area differential data package in the file header data of the target compressed package.
[0098] Optionally, the differential data packet is determined by using the differential file and the core area differential data packet, including: if the differential file contains the change file, then using a preset summary algorithm to determine whether the content of the change file in the target compressed package is the same as the content of the change file in the compressed package to be upgraded; if they are the same, then determining the differential data packet according to a fourth target data packet and the core area differential data packet, wherein the fourth target data packet at least includes the file name of the change file in the file header data of the target compressed package and a third preset operation type, and the third preset operation type is used to indicate a replacement operation for the change file in the compressed package to be upgraded when performing a differential restore upgrade on the software to be upgraded. The advantage of such a setting is that when the target compressed package contains a change file, and the content of the change file is the same as the content of the change file in the compressed package to be upgraded, there is no need to package the change file into a differential data packet, and a streamlined differential data packet can be quickly obtained by directly packaging the file name of the change file and the third preset operation type.
[0099] Specifically, if the difference file contains a changed file, a preset digest algorithm, such as SHA256 and MD5, can be used to determine whether the content of the changed file in the target compressed package is the same as the content of the changed file in the compressed package to be upgraded. If they are the same, it is only necessary to package the file name of the changed file in the file header data of the target compressed package, the third preset operation type, and the core area differential data packet to obtain a differential data packet. Among them, the third preset operation type can be recorded as move.
[0100] Optionally, after using the preset summary algorithm to determine whether the content of the changed file in the target compressed package is the same as the content of the changed file in the compressed package to be upgraded, it also includes: if they are not the same, determining whether the changed file has been compressed by a first preset compression algorithm; if not compressed, performing differential processing on the changed file in the target compressed package and the changed file in the compressed package to be upgraded, and compressing the differential data obtained by the differential processing to obtain a differential data packet; determining a differential data packet based on a fifth target data packet and the core area differential data packet, wherein the fifth target data packet at least includes the file name of the changed file in the file header data of the target compressed package, the differential data packet and a fourth preset operation type, and the fourth preset operation type is used to indicate that when performing a differential restore upgrade on the software to be upgraded, the data obtained after decompression of the differential data packet and the changed file in the compressed package to be upgraded are used to restore the changed file in the target compressed package. The advantage of this setting is that when the target compressed package contains a changed file, and the content of the changed file is different from the content of the changed file in the compressed package to be upgraded, the difference data package of the changed file is highly compressed, which further ensures the simplicity of the difference data package while ensuring that no compression information is lost.
[0101] Specifically, if the content of the changed file in the target compressed package is different from the content of the changed file in the compressed package to be upgraded, it is necessary to first determine whether the changed file has been compressed by the first preset compression algorithm. If not, the changed file in the target compressed package and the changed file in the compressed package to be upgraded are differentially processed, and the differential data obtained by the differential processing are compressed to obtain a differential data packet. Then, the file name of the changed file in the file header data of the target compressed package, the differential data packet, the fourth preset operation type, and the core area differential data packet are packaged to obtain a differential data packet. The fourth preset operation type can be recorded as DIFF. When the operation type contained in the differential data packet is DIFF, it is necessary to use the corresponding compression algorithm to decompress the differential data packet to obtain differential data. At the same time, it is necessary to use the compressed package to be upgraded to determine the second file collection table, and obtain the change file from the corresponding position in the second file collection table. If the data type of the change file is deflate compressed data, it is necessary to first perform deflate decompression (if the data type is to store only uncompressed data, skip the decompression process) to obtain the decompressed data of the change file involved in the differential calculation, and then combine the difference data packet to obtain the change file data in the target compressed package. If compression information is recorded in the differential data packet, if the compression information is deflate compression, then the change file data needs to be deflate compressed at this time to obtain the change file in the target compressed package. Among them, when compressing the differential data obtained after differential processing of the changed files in the target compressed package and the changed files in the compressed package to be upgraded, it is also necessary to judge the size of the data obtained after compression and the data before compression. If the data obtained after compression is larger than the data before compression, the data before compression, that is, the differential data of the changed files, can be determined as a differential data packet. If the data obtained after compression is less than or equal to the data before compression, the compressed data can be determined as a differential data packet.
[0102] Optionally, the difference data can be encoded as follows:
[0103] If the changed files in the target compressed package are recorded as t_data, and the changed files in the compressed package to be upgraded are recorded as s_data, assuming that s_data is a string "abcavbegfh", its subscript (starting position) is i, and t_data is a string "abccvdegfh", its subscript (starting position) is j, the difference data between the above two is stored in st_data, and st_data uses subscript k as the storage starting address, and the storage length is 3. Figure 6 A schematic diagram of differential processing principle is shown in Figure 2. Figure 6 As shown, the process of performing differential processing on s_data and t_data can be:
[0104] 1. Determine the identical data substrings in s_data and t_data, and record the information of the identical data, such as the starting position of the identical data substring in s_data, the starting position in t_data, and the data length, such as Figure 6 The two identical data substrings "abc" and "egfh" can be recorded as M(i,j,3)(i+6,j+6,4).
[0105] 2. Determine the different data substrings in s_data and t_data, record the information of the different data substrings, such as the starting position of the different data substrings in t_data, the starting position of the different data substrings that can be stored in st_data, and the data length, and write the different data substrings in st_data. Figure 6 In the example, although the substring "v" is also the same data substring, its length is short and the encoding cost is high, so "cvd" is integrated as a different data substring, which can be recorded as R(k, j+3, 3).
[0106] Embodiment 3
[0107] Figure 7 This is a flowchart of another differential data determination method provided in Embodiment 3 of the present invention. The technical solution of the embodiment of the present invention is further optimized on the basis of the above-mentioned optional technical solutions, and provides another specific method for determining differential data.
[0108] like Figure 7 As shown, another differential data determination method provided by Embodiment 2 of the present invention specifically includes the following steps:
[0109] S301, performing differential processing on the core areas of the target compressed package and the compressed package to be upgraded to obtain a core area differential data packet, and using the central directory record area of the core area to determine a first file set table and a second file set table.
[0110] S302: Compare the first file set table with the second file set table, determine the file corresponding to the file name that only exists in the first file set table as a newly added file, and determine the file corresponding to the file name that exists in both the first file set table and the second file set table as a changed file.
[0111] S303, determine whether the current file is a newly added file, if so, execute step 304, if not, execute step 310.
[0112] S304, determining whether the newly added file has been compressed by the first preset compression algorithm according to the central directory record area of the target compression package, if not, executing step 305, if yes, executing step 306.
[0113] S305: Determine a differential data packet according to the first target data packet and the core area differential data packet.
[0114] S306: decompress the newly added file to obtain a decompressed file, and compress the decompressed file using a second preset compression algorithm to obtain a compressed file.
[0115] S307, determine whether the compressed file is less than or equal to the decompressed file, if not, execute step 308, if yes, execute step 309.
[0116] S308. Determine a differential data packet according to the second target data packet and the core area differential data packet.
[0117] S309: Determine a differential data packet according to the third target data packet and the core area differential data packet.
[0118] S310, using a preset digest algorithm to determine whether the content of the changed file in the target compressed package is the same as the content of the changed file in the compressed package to be upgraded, if so, execute step 311, if not, execute step 312.
[0119] S311. Determine a differential data packet according to the fourth target data packet and the core area differential data packet.
[0120] S312: Determine whether the changed file has been compressed by the first preset compression algorithm. If not, execute step 313; if yes, execute step 315.
[0121] S313: Perform differential processing on the changed files in the target compressed package and the changed files in the compressed package to be upgraded, and compress the differential data obtained by the differential processing to obtain a differential data packet.
[0122] S314. Determine a differential data packet according to the fifth target data packet and the core area differential data packet.
[0123] S315, decompressing the changed file to obtain a target decompressed file, performing differential processing on the target decompressed file and the changed file in the compressed package to be upgraded, and compressing the target differential data obtained by the differential processing to obtain a target difference data packet.
[0124] Specifically, if the changed file has been compressed by the first preset compression algorithm, the changed file can be decompressed first to obtain the target decompressed file, and then the target decompressed file and the changed file in the compressed package to be upgraded are differentially processed to obtain target difference data, and then the target difference data is compressed, and the size of the data obtained after compression and the data before compression is determined. If the data obtained after compression is larger than the data before compression, the data before compression, that is, the target difference data, can be determined as the target difference data packet. If the data obtained after compression is less than or equal to the data before compression, the data after compression of the target difference data packet can be determined as the target difference data packet.
[0125] S316. Determine a differential data packet according to the sixth target data packet and the core area differential data packet.
[0126] The sixth target data packet at least includes the file name of the changed file in the file header data of the target compressed package, the target difference data packet and the fourth preset operation type.
[0127] Specifically, the file name of the changed file in the file header data of the target compressed package, the target difference data packet, the fourth preset operation type and the core area difference data packet are packaged to obtain a difference data packet.
[0128] Specifically, when there are both changed files and newly added files in the target compressed package, the core area differential data package can be packaged only once, that is, after any one of the first target data package, the second target data package, the third target data package, the fourth target data package, the fifth target data package and the sixth target data package is packaged once with the core area differential data package, after obtaining the differential data package, the remaining other target data packages only need to be directly packaged into the differential data package, and after the above steps are completed, the final differential data package can be obtained. Alternatively, after obtaining the target data packages corresponding to all the difference files in the target compressed package, the obtained target data packages and the core area differential data package can be packaged to obtain the final differential data package.
[0129] The differential data determination method provided by the embodiment of the present invention, when the target compression package contains both new files and changed files, can obtain a differential data packet that occupies a smaller memory space and contains all compressed information by separately processing the new files and the changed files, and comparing the processed data (i.e., the target data packet) and the core area differential data packet, thereby further ensuring simplicity.
[0130] Embodiment 4
[0131] Figure 8A flowchart of a differential restoration method is provided for Embodiment 4 of the present invention. This embodiment is applicable to the case of differential restoration of data. The method can be executed by a differential restoration device. The differential restoration device can be implemented in the form of hardware and / or software. The differential restoration device can be configured in an electronic device. The electronic device can be composed of two or more physical entities or one physical entity.
[0132] like Figure 8 As shown, the fourth embodiment of the present invention provides a differential restoration method, which specifically includes the following steps:
[0133] S401, obtaining a differential data packet, and using the differential data packet and the compressed package to be upgraded to differentially restore the core area of the target compressed package to obtain a restored core area.
[0134] The differential data packet is obtained by the differential data determination method described in the above embodiment.
[0135] Specifically, differential restoration processing is performed on the core area differential data packet in the differential data packet and the core area data in the compressed package to be upgraded, so as to restore the core area data of the target compressed package, that is, to obtain the restored core area.
[0136] S402: Using the central directory record area in the restoration core area, restore the file header of the target compressed package to obtain a restored file header.
[0137] Specifically, as described in the above embodiment, since the central directory record area of the target compressed package records all the contents of the file head, the file head of the target compressed package can be restored by parsing the central directory record area in the restoration core area to obtain the restored file header.
[0138] S403: Use the differential data packet to restore the file data of the target compressed package to obtain restored file data.
[0139] Specifically, the file data of the target compressed package can be restored by using the data in the differential data package, such as the target data package and the preset operation type in the differential data package, to obtain the restored file data. The file data has a large amount of data and takes a long time to restore, so it can be reasonably restored concurrently according to the storage space and computer performance.
[0140] The differential data determination scheme provided by the embodiment of the present invention obtains a differential data packet, and uses the differential data packet and the compressed package to be upgraded to differentially restore the core area of the target compressed package to obtain the restored core area, wherein the differential data packet is obtained by the differential data determination method described above, and the central directory record area in the restored core area is used to restore the file header of the target compressed package to obtain the restored file header, and the differential data packet is used to restore the file data of the target compressed package to obtain the restored file data. The technical scheme of the embodiment of the present invention uses the differential data packet and the compressed package to be upgraded to restore the core area of the target compressed package, and then uses the core area and the differential data packet to make the file data and file head (file header) data generated after the restoration completely consistent with the data in the target compressed package participating in the differential calculation, thereby solving the problem of poor differential restoration effect caused by the existence of non-differential friendly data.
[0141] Embodiment 5
[0142] Fig. 9 This is a schematic diagram of the structure of a differential data determination device provided in Embodiment 3 of the present invention. Fig. 9 As shown, the device includes: a file set table determination module 501, a difference file determination module 502 and a difference data determination module 503, wherein:
[0143] A file collection table determination module is used to perform differential processing on the core areas of the target compressed package and the compressed package to be upgraded to obtain a core area differential data packet, and determine a first file collection table and a second file collection table using a central directory record area of the core area, wherein the core area at least includes the central directory record area, the first file collection table contains the file name recorded in the central directory record area of the target compressed package, and the second file collection table contains the file name recorded in the central directory record area of the compressed package to be upgraded;
[0144] A difference file determination module, used for determining a difference file by using the first file set table and the second file set table;
[0145] The differential data determination module is used to determine the differential data packet using the differential file and the core area differential data packet.
[0146] The differential data determination device provided in the embodiment of the present invention can determine the differential data packets of the target compressed package and the compressed package to be upgraded by using the core area differential data packets and the differential files. Compared with the traditional method of directly performing differential calculations on the data packets, the method obtains a concise and accurate differential data packet by determining the differential files. The determined differential data packet occupies less space, and by performing differential processing on the core areas of the target compressed package and the compressed package to be upgraded, it is ensured that the core area differential data packet in the differential data packet can be used during differential restoration to accurately restore the file header data of the target compressed package, and differential-friendly processing includes compressed packages with non-differential-friendly data.
[0147] Optionally, the difference file determination module includes:
[0148] a newly added file determining unit, configured to compare the first file set table with the second file set table, and determine a file corresponding to a file name that only exists in the first file set table as a newly added file; and / or,
[0149] The changed file determining unit is used to determine the file corresponding to the file name that exists in both the first file set table and the second file set table as a changed file; wherein the changed file and the newly added file both belong to the difference file.
[0150] Optionally, the differential data determination module includes:
[0151] A first compression judgment unit, configured to determine whether the newly added file has been compressed by a first preset compression algorithm according to the central directory record area of the target compressed package if the newly added file is included in the difference file;
[0152] The first differential data determination unit is used to determine the differential data packet based on the first target data packet and the core area differential data packet if the information returned by the first compression judgment unit is no, wherein the first target data packet at least includes the file name of the newly added file in the file header data of the target compression packet, the newly added file and a first preset operation type, and the first preset operation type is used to instruct the newly added file to be written to the preset location of the software to be upgraded when performing differential restoration upgrade on the software to be upgraded.
[0153] Optionally, the differential data determination module further includes:
[0154] a compressed file determining unit, configured to, after determining whether the newly added file has been compressed by the first preset compression algorithm, if yes, decompress the newly added file to obtain a decompressed file, and compress the decompressed file by using a second preset compression algorithm to obtain a compressed file, wherein the second preset compression algorithm is different from the first preset compression algorithm;
[0155] A judging unit, used to judge whether the compressed file is smaller than the decompressed file;
[0156] A second differential data determination unit is used to determine a differential data packet according to a second target data packet and the core area differential data packet if the information returned by the judgment unit is greater than, wherein the second target data packet at least includes the file name of the newly added file in the file header data of the target compressed packet, the decompressed file, and the first preset operation type;
[0157] The third differential data determination unit is used to determine the differential data packet based on the third target data packet and the core area differential data packet if the information returned by the judgment unit is less than or equal to, wherein the third target data packet at least includes the file name of the newly added file in the file header data of the target compressed package, the compressed file and a second preset operation type, and the second preset operation type is used to indicate the use of the data obtained after decompressing the compressed file to restore the newly added file in the target compressed package when performing a differential restore upgrade on the software to be upgraded.
[0158] Optionally, the differential data determination module includes:
[0159] a content determination unit, configured to determine whether the content of the changed file in the target compressed package is the same as the content of the changed file in the compressed package to be upgraded by using a preset digest algorithm if the changed file is included in the difference file;
[0160] A fourth differential data determination unit is used to determine a differential data packet based on a fourth target data packet and the core area differential data packet if the information returned by the content judgment unit is the same, wherein the fourth target data packet at least includes the file name of the changed file in the file header data of the target compressed packet and a third preset operation type, and the third preset operation type is used to indicate a replacement operation for the changed file in the compressed packet to be upgraded when performing a differential restore upgrade on the software to be upgraded.
[0161] Optionally, the differential data determination module further includes:
[0162] a second compression judgment unit, configured to determine whether the content of the changed file in the target compressed package and the content of the changed file in the compressed package to be upgraded are the same after determining whether the content of the changed file in the target compressed package and the content of the changed file in the compressed package to be upgraded are the same, and if they are not the same, determine whether the changed file has been compressed by the first preset compression algorithm;
[0163] a difference data determination unit, configured to perform difference processing on the changed files in the target compressed package and the changed files in the compressed package to be upgraded if the information returned by the second compression judgment unit is uncompressed, and compress the difference data obtained by the difference processing to obtain a difference data packet;
[0164] A fifth differential data determination unit is used to determine a differential data packet based on a fifth target data packet and the core area differential data packet, wherein the fifth target data packet at least includes the file name of the changed file in the file header data of the target compressed package, the difference data packet and a fourth preset operation type, and the fourth preset operation type is used to indicate the use of the data obtained after decompressing the differential data packet and the changed files in the compressed package to be upgraded to restore the changed files in the target compressed package when performing a differential restore upgrade on the software to be upgraded.
[0165] The differential data determination device provided in the embodiment of the present invention can execute the differential data determination method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0166] Embodiment 6
[0167] Fig.10 This is a schematic diagram of the structure of a differential restoration device provided in Embodiment 3 of the present invention. Fig.10 As shown, the device includes: a core area restoration module 601, a file header restoration module 602 and a restoration module 603, wherein:
[0168] a core area restoration module, used to obtain a differential data packet, and use the differential data packet and the compressed package to be upgraded to differentially restore the core area of the target compressed package to obtain a restored core area, wherein the differential data packet is obtained by the differential data determination method according to any one of claims 1 to 6;
[0169] A file header restoration module, used to restore the file header of the target compressed package by using the central directory record area in the restoration core area to obtain a restored file header;
[0170] The restoration module is used to restore the file data of the target compressed package using the differential data package to obtain the restored file data.
[0171] The differential restoration device provided in the embodiment of the present invention can restore the core area of the target compressed package by using the differential data packet and the compressed package to be upgraded, and then use the core area and the differential data packet to make the file data and file head (file header) data generated after the restoration completely consistent with the data in the target compressed package participating in the differential calculation, thereby solving the problem of poor differential restoration effect caused by the existence of non-differential friendly data.
[0172] Embodiment 7
[0173] A schematic diagram of an electronic device 40 that can be used to implement an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or claimed herein.
[0174] like Fig.11 As shown, the electronic device 70 includes at least one processor 71, and a memory connected to the at least one processor 71, such as a read-only memory (ROM) 72, a random access memory (RAM) 73, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 71 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 72 or the computer program loaded from the storage unit 78 to the random access memory (RAM) 73. In the RAM 73, various programs and data required for the operation of the electronic device 70 can also be stored. The processor 71, the ROM 72, and the RAM 73 are connected to each other via a bus 74. An input / output (I / O) interface 75 is also connected to the bus 74.
[0175] A number of components in the electronic device 70 are connected to the I / O interface 75, including: an input unit 76, such as a keyboard, a mouse, etc.; an output unit 77, such as various types of displays, speakers, etc.; a storage unit 78, such as a disk, an optical disk, etc.; and a communication unit 79, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 79 allows the electronic device 70 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0176] The processor 71 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 71 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The processor 71 performs the various methods and processes described above, such as a differential data determination method, and / or a differential restoration method.
[0177] In some embodiments, the differential data determination method, and / or the differential restoration method may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 78. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 70 via the ROM 72 and / or the communication unit 79. When the computer program is loaded into the RAM 73 and executed by the processor 71, one or more steps of the differential data determination method, and / or the differential restoration method described above may be performed. Alternatively, in other embodiments, the processor 71 may be configured to perform the differential data determination method, and / or the differential restoration method, in any other appropriate manner (e.g., by means of firmware).
[0178] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0179] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0180] The computer device provided above can be used to execute the differential data determination method and / or the differential restoration method provided in any of the above embodiments, and has corresponding functions and beneficial effects.
[0181] Embodiment 5
[0182] In the context of the present invention, a computer-readable storage medium may be a tangible medium, wherein the computer-executable instructions, when executed by a computer processor, are used to perform a differential data determination method, and / or a differential restoration method, the differential data determination method comprising:
[0183] Performing differential processing on the core areas of the target compressed package and the compressed package to be upgraded to obtain a core area differential data packet, and using the central directory record area of the core area to determine a first file set table and a second file set table, wherein the core area at least includes the central directory record area, the first file set table contains the file name recorded in the central directory record area of the target compressed package, and the second file set table contains the file name recorded in the central directory record area of the compressed package to be upgraded;
[0184] Determine difference files by using the first file set table and the second file set table;
[0185] The differential data package is determined by using the differential file and the core area differential data package.
[0186] The differential restoration method includes:
[0187] Obtaining a differential data packet, and using the differential data packet and the compressed package to be upgraded to differentially restore the core area of the target compressed package to obtain a restored core area, wherein the differential data packet is obtained by the differential data determination method described above;
[0188] Restoring the file header of the target compressed package by using the central directory record area in the restoration core area to obtain a restored file header;
[0189] The file data of the target compressed package is restored using the differential data package to obtain restored file data.
[0190] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by an instruction execution system, device or equipment or used with an instruction execution system, device or equipment or used in combination with an instruction execution system, device or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0191] The computer device provided above can be used to execute the differential data determination method and / or the differential restoration method provided in any of the above embodiments, and has corresponding functions and beneficial effects.
[0192] It is worth noting that in the embodiment of the above-mentioned differential data determination device, the various units and modules included are only divided according to functional logic, but are not limited to the above-mentioned division, as long as the corresponding functions can be achieved; in addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of the present invention.
[0193] Note that the above are only preferred embodiments of the present invention and the technical principles used. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present invention, and the scope of the present invention is determined by the scope of the appended claims.
Claims
1. A method for determining differential data, characterized in that: include: Performing differential processing on the core areas of the target compressed package and the compressed package to be upgraded to obtain a core area differential data packet, and using the central directory record area of the core area to determine a first file set table and a second file set table, wherein the core area at least includes the central directory record area, the first file set table contains the file name recorded in the central directory record area of the target compressed package, and the second file set table contains the file name recorded in the central directory record area of the compressed package to be upgraded, the central directory record area is an archive list, which stores the information of the compressed files and uniformly records the file information of the data area; Determine difference files by using the first file set table and the second file set table; Determine the differential data packet using the differential file and the core area differential data packet; The determining of difference files by using the first file set table and the second file set table includes: Comparing the first file set table with the second file set table, determining the file corresponding to the file name that only exists in the first file set table as a newly added file; and / or, Determine a file corresponding to a file name that exists in both the first file set table and the second file set table as a changed file; Wherein, the changed file and the newly added file both belong to the difference file; The step of using the difference file and the core area difference data packet to determine the difference data packet includes: If the difference file includes the newly added file, determining whether the newly added file has been compressed by a first preset compression algorithm according to the central directory record area of the target compressed package; If not, determining a differential data packet according to the first target data packet and the core area differential data packet, wherein the first target data packet at least includes the file name of the newly added file in the file header data of the target compressed package, the newly added file, and a first preset operation type, and the first preset operation type is used to instruct to write the newly added file to the preset location of the software to be upgraded when performing differential restore upgrade on the software to be upgraded; After determining whether the newly added file has been compressed by the first preset compression algorithm, the method further includes: If yes, decompress the newly added file to obtain a decompressed file, and compress the decompressed file using a second preset compression algorithm to obtain a compressed file, wherein the second preset compression algorithm is different from the first preset compression algorithm; Determine whether the compressed file is less than or equal to the decompressed file; If it is greater than, determining a differential data packet according to a second target data packet and the core area differential data packet, wherein the second target data packet at least includes the file name of the newly added file in the file header data of the target compressed packet, the decompressed file, and the first preset operation type; If it is less than or equal to, determining a differential data packet according to a third target data packet and the core area differential data packet, wherein the third target data packet at least includes the file name of the newly added file in the file header data of the target compressed package, the compressed file, and a second preset operation type, and the second preset operation type is used to instruct to use the data obtained after decompressing the compressed file to restore the newly added file in the target compressed package when performing differential restore upgrade on the software to be upgraded; The step of using the difference file and the core area difference data packet to determine the difference data packet includes: If the difference file contains the changed file, determine whether the content of the changed file in the target compressed package is the same as the content of the changed file in the compressed package to be upgraded by using a preset digest algorithm; If they are the same, the differential data packet is determined based on the fourth target data packet and the core area differential data packet, wherein the fourth target data packet at least includes the file name of the changed file in the file header data of the target compressed package and the third preset operation type, and the third preset operation type is used to indicate the replacement operation of the changed file in the compressed package to be upgraded when performing a differential restore upgrade on the software to be upgraded.
2. The method according to claim 1, characterized in that After using the preset digest algorithm to determine whether the content of the changed file in the target compressed package is the same as the content of the changed file in the compressed package to be upgraded, the method further includes: If they are not the same, determining whether the changed file has been compressed by a first preset compression algorithm; If they have not been compressed, performing differential processing on the changed files in the target compressed package and the changed files in the compressed package to be upgraded, and compressing the differential data obtained by the differential processing to obtain a differential data packet; A differential data packet is determined based on the fifth target data packet and the core area differential data packet, wherein the fifth target data packet at least includes the file name of the changed file in the file header data of the target compressed package, the difference data packet and a fourth preset operation type, and the fourth preset operation type is used to indicate the use of the data obtained after decompression of the differential data packet and the changed files in the compressed package to be upgraded to restore the changed files in the target compressed package when performing a differential restore upgrade on the software to be upgraded.
3. A differential restoration method, characterized in that: include: Obtain a differential data packet, and use the differential data packet and the compressed package to be upgraded to differentially restore the core area of the target compressed package to obtain the restored core area, wherein the differential data packet is obtained by the differential data determination method according to any one of claims 1 to 2; Restoring the file header of the target compressed package by using the central directory record area in the restoration core area to obtain a restored file header; The file data of the target compressed package is restored using the differential data package to obtain restored file data.
4. A differential data determination device, characterized in that: include: A file collection table determination module is used to perform differential processing on the core areas of the target compressed package and the compressed package to be upgraded to obtain a core area differential data packet, and determine a first file collection table and a second file collection table using the central directory record area of the core area, wherein the core area at least includes the central directory record area, the first file collection table contains the file name recorded in the central directory record area of the target compressed package, and the second file collection table contains the file name recorded in the central directory record area of the compressed package to be upgraded, the central directory record area is an archive list, which stores the information of the compressed files and uniformly records the file information of the data area; A difference file determination module, used for determining a difference file by using the first file set table and the second file set table; A differential data determination module, used to determine a differential data packet using the differential file and the core area differential data packet; The difference file determination module includes: a newly added file determining unit, configured to compare the first file set table with the second file set table, and determine a file corresponding to a file name that only exists in the first file set table as a newly added file; and / or, a changed file determining unit, configured to determine a file corresponding to a file name existing in both the first file set table and the second file set table as a changed file; wherein both the changed file and the newly added file belong to the difference file; The differential data determination module includes: A first compression judgment unit, configured to determine whether the newly added file has been compressed by a first preset compression algorithm according to the central directory record area of the target compressed package if the newly added file is included in the difference file; a first differential data determination unit, configured to determine a differential data packet according to a first target data packet and the core area differential data packet if the information returned by the first compression judgment unit is negative, wherein the first target data packet at least includes the file name of the newly added file in the file header data of the target compressed packet, the newly added file, and a first preset operation type, wherein the first preset operation type is used to instruct to write the newly added file to a preset location of the software to be upgraded when performing differential restore upgrade on the software to be upgraded; The differential data determination module also includes: a compressed file determining unit, configured to, after determining whether the newly added file has been compressed by the first preset compression algorithm, if yes, decompress the newly added file to obtain a decompressed file, and compress the decompressed file by using a second preset compression algorithm to obtain a compressed file, wherein the second preset compression algorithm is different from the first preset compression algorithm; A judging unit, used to judge whether the compressed file is smaller than the decompressed file; A second differential data determination unit is used to determine a differential data packet according to a second target data packet and the core area differential data packet if the information returned by the judgment unit is greater than, wherein the second target data packet at least includes the file name of the newly added file in the file header data of the target compressed packet, the decompressed file, and the first preset operation type; A third differential data determination unit is configured to determine a differential data packet according to a third target data packet and the core area differential data packet if the information returned by the judgment unit is less than or equal to the value of the differential data packet, wherein the third target data packet at least includes the file name of the newly added file in the file header data of the target compressed data packet, the compressed file, and a second preset operation type, and the second preset operation type is configured to indicate that the newly added file in the target compressed data packet is restored by using the data obtained by decompressing the compressed file when performing differential restore upgrade on the software to be upgraded; The differential data determination module includes: a content determination unit, configured to determine whether the content of the changed file in the target compressed package is the same as the content of the changed file in the compressed package to be upgraded by using a preset digest algorithm if the changed file is included in the difference file; A fourth differential data determination unit is used to determine a differential data packet based on a fourth target data packet and the core area differential data packet if the information returned by the content judgment unit is the same, wherein the fourth target data packet at least includes the file name of the changed file in the file header data of the target compressed packet and a third preset operation type, and the third preset operation type is used to indicate a replacement operation for the changed file in the compressed packet to be upgraded when performing a differential restore upgrade on the software to be upgraded.
5. A differential restoration device, characterized in that: include: A core area restoration module, used to obtain a differential data packet, and use the differential data packet and the compressed package to be upgraded to differentially restore the core area of the target compressed package to obtain a restored core area, wherein the differential data packet is obtained by the differential data determination method according to any one of claims 1 to 2; A file header restoration module, used to restore the file header of the target compressed package by using the central directory record area in the restoration core area to obtain a restored file header; The restoration module is used to restore the file data of the target compressed package using the differential data package to obtain the restored file data.
6. An electronic device, 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 executable 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 differential data determination method described in any one of claims 1-2, and / or execute the differential restoration method described in claim 3.
7. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the differential data determination method described in any one of claims 1-2 and / or the differential restoration method described in claim 3 when executed.
Citation Information
Patent Citations
Software upgrading method and device, electronic equipment and storage medium
CN113986313A
Method and device for modifying file
CN115203148A