A block differential upgrade method, terminal device and computer-readable storage medium
By calculating the full differential packages of the original and new files and generating block exchange tables, the generation and upgrading process of differential upgrade files is optimized, and the problem of unstable size of differential upgrade files in the existing technology is solved, and the upgrade speed and stability are improved. sex.
Patent Information
- Application Number
- CN202111628899.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-28
- Publication Date
- 2025-02-18
- Estimated Expiration
- 2041-12-28
AI Technical Summary
After erasing the original data, the existing differential upgrade algorithm causes the new data to lose reference information, the proportion of differential information becomes smaller, and the proportion of additional information becomes larger, resulting in unstable size of the differential upgrade file, affecting the upgrade speed.
By calculating the full difference package of the original file and the new file, a chunked weight table is obtained. The chunked moving table is obtained based on the chunked weight table, the chunked moving table is inserted into the binary tree, and the chunked swap table is obtained, which is based on the chunked swap table order. Find the chunked differential content of each new file, generate a differential upgrade file, and upgrade the original file to a new file according to the order of the exchange table.
This avoids the problem of unstable size of differential upgrade files, improves the upgrade speed and stability, and ensures the reliability of differential upgrade files.
Smart Images

Figure CN114356386B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of differential upgrade technology, and in particular to a block differential upgrade method, a terminal device and a computer-readable storage medium. Background Art
[0002] At present, upgrading through differential upgrade algorithms can reduce the size of upgrade packages, speed up upgrades, and reduce energy consumption. The differential upgrade algorithm of the prior art requires direct erasure of the original data information; after erasing the original data, the new data will lose reference information when referencing the original data, resulting in a smaller proportion of differential information and a larger proportion of additional information, resulting in a larger differential upgrade file. Therefore, the differential upgrade algorithm of the prior art will cause the size of the differential upgrade file to be unstable, affecting the upgrade speed. Summary of the invention
[0003] To solve the above problems, the present application provides a block differential upgrade method, comprising the following steps: calculating a full differential package of an original file and a new file, pre-blocking the original file and the new file, and obtaining multiple blocks of the original file and multiple blocks of the new file; obtaining a block weight table based on the full differential package, and obtaining a block movement table based on the block weight table; inserting the block movement table into a binary tree, and traversing all binary trees to obtain a block exchange table; based on the order of the block exchange table, sequentially calculating the differential content of the blocks of each new file to obtain a differential upgrade file; based on the order of the differential upgrade file and the block exchange table, upgrading the original file to a new file.
[0004] Among them, the step of obtaining a block weight table based on the full difference package includes: obtaining the character string of the block of the original file corresponding to the block reference of each new file; calculating the ratio of the character string to the block of the corresponding original file, and obtaining the block weight table based on the corresponding ratio of the blocks of all new files; the step of obtaining a block movement table based on the block weight table includes: moving each block of the original file to the corresponding block of the new file in the block weight table to obtain the block movement table.
[0005] Among them, the step of inserting the block movement table into the binary tree includes: taking the block of each original file in the block movement table as the parent node of the binary tree; taking the block of each new file in the block movement table as the child node of the binary tree; when there are two identical blocks in the block movement table, the two identical blocks are not inserted into the binary tree; when there are two mutually referenced blocks in the block movement table, the block with a higher ratio in the two mutually referenced blocks is taken as the parent node of the binary tree.
[0006] The step of traversing all binary trees to obtain a block exchange table includes: performing subsequent traversal on each binary tree to obtain a block exchange table.
[0007] Among them, based on the order of the block exchange table, the differential content of the blocks of each new file is calculated in turn, and the step of obtaining the differential upgrade file includes: based on the order of the block exchange table, the block of each new file is differentiated from the suffix array of the original file to obtain the first information and the second information corresponding to the block of each new file; based on the first information and the second information, a differential upgrade file package is obtained, wherein the first information and the second information are respectively used as the first area and the second area of the differential upgrade file package; the blocks of the new file are overwritten with the corresponding blocks of the original file, and the suffix array of the original file is recalculated.
[0008] The step of obtaining the differential upgrade file includes: inserting the block exchange table into the file header of the differential upgrade file package; and compressing the differential upgrade file package to obtain the differential upgrade file.
[0009] Among them, the steps of upgrading the original file to a new file based on the order of the differential upgrade file and the block exchange table include: obtaining the first structure and the second structure of the differential upgrade file; obtaining the first address information from the first structure and obtaining the second address information from the second structure; based on the order of the block exchange table of the differential upgrade file, upgrading the original file to a new file.
[0010] Among them, the steps of upgrading the original file to a new file based on the order of the block exchange table of the differential upgrade file include: writing the blocks of the new file to the backup area; erasing the contents of the blocks of the original file corresponding to the blocks of the new file; copying the contents of the backup area to the corresponding blocks of the original file; erasing the contents of the backup area; repeating the above steps based on the order of the block exchange table to upgrade the original file to a new file.
[0011] Among them, the step of upgrading the original file to a new file based on the order of the differential upgrade file and the block exchange table also includes: saving the current step when a power-off signal is received; and continuing to execute the current step when a recovery signal is received.
[0012] In order to solve the above technical problems, the present application also provides a terminal device, which includes a processor and a memory; a computer program is stored in the memory, and the processor is used to execute the computer program to implement the above block differential upgrade method.
[0013] In order to solve the above technical problems, the present application also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed, the above block differential upgrade method is implemented.
[0014] The beneficial effect of the present application is that, different from the prior art, the technical solution of the present application calculates the full differential package of the original file and the new file, obtains the block weight table based on the full differential package, obtains the block movement table based on the block weight table, inserts the block movement table into the binary tree for processing, and obtains the block exchange table. Based on the order of the block exchange table, the differential content of the blocks of each new file is calculated in turn to obtain the differential upgrade file; based on the order of the differential upgrade file and the block exchange table, the original file is upgraded to a new file, that is, the blocks of multiple original files are erased in turn according to the order of the block exchange table, and the original file is upgraded to a new file, so as to avoid the instability of the differential upgrade file and improve the upgrade speed and stability. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] In order to more clearly illustrate the technical solutions in the embodiments of the present application, 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 application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. Among them:
[0016] Figure 1 It is a flowchart of the first embodiment of the block differential upgrade method provided by the present application;
[0017] Figure 2 yes Figure 1 A schematic diagram of an embodiment of pre-segmenting the original file and the new file;
[0018] Figure 3 It is a flowchart of the second embodiment of the block differential upgrade method provided by the present application;
[0019] Figure 4 yes Figure 1 A schematic diagram of an embodiment of a block exchange table;
[0020] Figure 5 It is a flowchart of the third embodiment of the block differential upgrade method provided by the present application;
[0021] Figure 6 This is a schematic diagram of the structure of the differential upgrade file package;
[0022] Figure 7 It is a flowchart of the fourth embodiment of the block differential upgrade method provided by the present application;
[0023] Figure 8 It is a flowchart of the fifth embodiment of the block differential upgrade method provided by the present application;
[0024] Fig. 9 It is a structural schematic diagram of an embodiment of the terminal device of the present application;
[0025] Fig.10 It is a structural diagram of an embodiment of the computer-readable storage medium of the present application.
[0026] Among them, 100, terminal device; 101, processor; 102, memory; 103, bus; 110, computer-readable storage medium; 111, program instructions. DETAILED DESCRIPTION
[0027] In order to make the above-mentioned purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are described in detail below in conjunction with the accompanying drawings. It is to be understood that the specific embodiments described herein are only used to explain the present application, rather than to limit the present application. It should also be noted that, for ease of description, only some structures related to the present application are shown in the accompanying drawings, rather than all structures. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0028] The terms "first", "second", etc. in this application are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "including" and "provided with" and any variations thereof 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 limited to the listed steps or units, but optionally includes steps or units that are not listed, or optionally includes other steps or units inherent to these processes, methods, products or devices.
[0029] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0030] The differential upgrade method usually uses the Bsdiff algorithm as a code template to add as little new content as possible to construct a new file. Taking the Bsdiff algorithm as an example, the differential upgrade file corresponding to the Bsdiff algorithm includes: control information, information on the difference of different bytes in the probability match (diff info), and extra information (extrainfo) that does not belong to the probability match content. When generating a differential upgrade file using the Bsdiff method, the original file is first sorted by suffix, and then the string in the new file is compared with the string in the original file to generate the corresponding difference information and extra information; the difference information, extra information and corresponding control information are compressed into a differential upgrade file.
[0031] In order to solve the problems of unstable differential upgrade files and low upgrade efficiency in the prior art, the present application proposes a block differential upgrade method, which can be run in the OTA upgrade of the IoT module firmware, and can be specifically applied to a terminal device and a computer-readable storage medium; the terminal device can be a mobile phone, a computer, or other terminal device with a processor and a memory; the computer-readable storage medium can be a computer-readable storage medium such as a U disk, an SD card, or a PD optical drive.
[0032] See also Figure 1 , Figure 2 , Figure 1 is a flowchart of an embodiment of a block differential upgrade method provided by the present application, Figure 2 yes Figure 1 A schematic diagram of an embodiment of pre-segmenting the original file and the new file in FIG.
[0033] The block differential upgrade method includes the following steps:
[0034] S10: Calculate the full differential package of the original file and the new file, perform preset block division on the original file and the new file, and obtain multiple blocks of the original file and multiple blocks of the new file.
[0035] Using the differential algorithm, the original file and the new file are differentially calculated to obtain the full differential package of the original file and the new file. A preset block is pre-set, and the original file and the new file are divided into blocks based on the preset block to obtain multiple blocks of the original file and multiple blocks of the new file, wherein the preset block can be 32k bytes, and the original file and the new file are divided into blocks based on each 32k bytes. For example, using a block array, the original file and the new file are divided into 32k blocks based on the preset block to obtain multiple blocks of the original file and multiple blocks of the new file, such as Figure 2 As shown, the blocks of the multiple original files are block 0, block 1, ..., block n of the original files; the blocks of the multiple new files are block 0, block 1, ..., block n of the new files.
[0036] S20: Obtain a block weight table based on the full differential packet, and obtain a block movement table based on the block weight table.
[0037] Based on the full differential package, a weight table of the proportion of each block of the new file referring to the corresponding block of the original file is obtained, that is, the block weight table; based on the block weight table, a movement order table representing the movement of each block of the original file to the block of the new file is obtained, that is, the block movement table.
[0038] S30: Insert the block movement table into the binary tree, and traverse all binary trees to obtain the block exchange table.
[0039] Since the block movement table indicates the order in which the blocks of the original file are to be moved to the blocks of the new file, if the data of a block of the original file is erased, another block of the new file will not be able to reference the relevant reference information. Therefore, based on the order of the block movement table, the block movement table is inserted into the binary tree, and all binary trees are traversed to obtain the block exchange table and the order of erasing the original data.
[0040] S40: Based on the order of the block exchange table, the differential content of each block of the new file is obtained in turn to obtain a differential upgrade file.
[0041] Based on the order of the block exchange table, the blocks of each new file are differentiated from the original file, and the differential content of each new file block is obtained in turn. Based on the differential content of each new file block, a differential upgrade file is obtained.
[0042] S50: Upgrading the original file to a new file based on the order of the differential upgrade file and the block exchange table.
[0043] Based on the order of the differential upgrade file and the block exchange table, the block contents of the original file are replaced with the block contents of the new file in sequence, completing the step of upgrading the original file to the new file.
[0044] Different from the prior art, the technical solution of the present application first obtains a block weight table based on the full differential package, obtains a block movement table based on the block weight table, inserts the block movement table into a binary tree for processing, obtains a block exchange table, and then calculates the differential content of each new file based on the order of the block exchange table to obtain a differential upgrade file, and finally upgrades the original file to a new file based on the order of the differential upgrade file and the block exchange table. The block exchange table represents the upgrade order of the block difference, which can avoid the new file from losing important reference information when referencing the original file, avoid the instability of the differential upgrade file, and improve the upgrade speed and stability.
[0045] See also Figure 3 , Figure 3 This is a flow chart of the second embodiment of the block differential upgrade method provided by the present application. Step S20 further includes the following steps:
[0046] S210: Obtain the first character string of the block of the original file corresponding to each block reference of the new file.
[0047] Based on the full differential package obtained in step S10 above, a character string of the original file's block corresponding to each block reference of the new file is obtained from the full differential package, where the character string may be a diff string.
[0048] For example, the diff string in block 0 of the new file has 11754 bytes that reference block 0 of the original file; and the diff string in block 2 of the new file has 32768 bytes that reference block 2 of the original file.
[0049] S220: Calculate the ratio of the character string to the corresponding blocks of the original file, and obtain a block weight table based on the corresponding ratios of the blocks of all new files.
[0050] When the preset block obtained based on the above step S10 is 32k bytes, the size of each original file block is 32768 bytes, then the ratio of the string of the corresponding original file block referenced by each new file block to the string of the original file block can be calculated. For example, the diff string in block 0 of the new file has 11754 bytes that reference block 0 of the original file, then the ratio of the diff string to the string of the corresponding original file block is 11754 to 32768, that is, the proportion of block 0 of the new file that references block 0 of the original file is 35%; the diff string in block 2 of the new file has 32768 bytes that reference block 1 of the original file, then the proportion of block 2 of the new file that references block 1 of the original file is 100%.
[0051] Based on the ratio of all new file blocks to the corresponding original file blocks, a block weight table is obtained. The block weight table is a weight table of the proportion of each block of the new file referring to the corresponding original file block.
[0052] S230: Each block of the original file in the block weight table is moved to the corresponding block of the new file to obtain a block movement table.
[0053] Based on the block weight table, it can be seen that when each block of the new file references the block content of the corresponding original file, the block of the original file needs to be moved to the block of the new file. It can be recorded as original file block a->new file block b, where a and b are integers from 0 to n. For example, block 0 of the original file moves to block 0 of the new file, recorded as 0->0; block 1 of the original file moves to block 2 of the new file, recorded as 1->2; block 2 of the original file moves to block 3 of the new file, recorded as 2->3.
[0054] Therefore, each block of the original file in the block weight table is moved to the corresponding block of the new file to obtain a block movement table.
[0055] Optionally, step S30 includes the following steps: taking the block of each original file in the block movement table as the parent node of the binary tree; taking the block of each new file in the block movement table as the child node of the binary tree; when there are two identical blocks in the block movement table, the two identical blocks are not inserted into the binary tree; when there are two mutually referencing blocks in the block movement table, taking the block with a higher ratio between the two mutually referencing blocks as the parent node of the binary tree.
[0056] This embodiment uses a binary tree to process the block movement table. A binary tree is a computer data structure consisting of a parent node and a subtree of the parent node. The blocks of the original file in the block movement table are taken as parent nodes, and the blocks of the new file are taken as child nodes; if the blocks of the original file are the same as the blocks of the new file, that is, there is no reference relationship between the blocks of the original file and the new file, no insertion processing is performed; if the blocks of the original file and the new file reference each other, the blocks with a high proportion of the two mutually referenced bytes are taken as the parent nodes of the binary tree, and the blocks with a low proportion are taken as child nodes. Among them, the mutual reference between the original file and the new file refers to a reference relationship in which the new file block contains the blocks of the original file, and the new file block references part of the character string of the original file block.
[0057] Furthermore, step S30 includes the following steps: performing subsequent traversal on each binary tree to obtain a block exchange table.
[0058] Traversing a binary tree means walking through all the nodes of the binary tree according to certain rules and order, so that each node is visited once, and the nodes of the binary tree are converted into a linear sequence. Subsequent traversal is a traversal method that traverses the child nodes first and then visits the parent node. Since the child nodes are the least important parts and have the lowest priority for being referenced, subsequent traversal is used here. After the traversal is completed, the block exchange table is obtained. For example, inserting the block movement table into the binary tree and traversing all binary trees, the results are: 0; 5, 4, 3, 2, 1; 21, 20, 19, ..., 7, 6; 60, 59, 58, ..., 24, 23.
[0059] like Figure 4 As shown, Figure 4 yes Figure 1 Schematic diagram of an embodiment of a block exchange table in FIG. In this embodiment, the block exchange table represents an exchange sequence table of the original file blocks. For example, Figure 4 This means that the block 0 of the original file is erased first, and then the block 5, block 4, block 3, and so on are erased until the erasure of block 23 is completed.
[0060] Different from the prior art, the technical solution of this embodiment inserts the block movement table into a binary tree, takes the block of each original file in the block movement table as the parent node of the binary tree, takes the block of each new file in the block movement table as the child node of the binary tree, and subsequently traverses all binary trees to obtain a block exchange table. The block exchange table is an exchange sequence table of the blocks of the original file. Based on the sequence of the block exchange table, the block upgrade sequence can be planned to avoid instability in differential upgrade files and improve upgrade speed and stability.
[0061] like Figure 5 As shown, Figure 5 This is a flow chart of the third embodiment of the block differential upgrade method provided by the present application. Step S40 includes the following steps:
[0062] S410: Based on the order of the block exchange table, the blocks of each new file are differentiated from the suffix array of the original file to obtain the first information and the second information corresponding to the blocks of each new file.
[0063] Based on the order of the block exchange table, the block of each new file is differentiated from the suffix array of the original file to obtain the differential content of the block in turn. The differential content includes first information and second information, the first information is difference information (diff info), and the second information is extra information (extra info).
[0064] S420: Obtain a differential upgrade file package based on the first information and the second information, wherein the first information and the second information are used as a first area and a second area of the differential upgrade file package respectively.
[0065] The first information and the second information are used as the first area and the second area of the differential upgrade file package respectively, wherein the first area is the difference information area (diff area) and the second area is the extra information area (extra area).
[0066] S430: Overwrite the corresponding blocks of the original file with the blocks of the new file, and recalculate the suffix array of the original file.
[0067] Since the block content of the original file is overwritten by the block of the new file, the modified array needs to be updated and sorted, that is, the suffix array of the original file is recalculated, and the difference between the block of the new file and the updated suffix array of the original file is used for difference calculation when calculating the difference of the next block.
[0068] Based on the order of the block exchange table, steps S410-S430 are repeated until the first information and the second information of the last block of the new file and the original file are obtained. For example, if the first item of the block exchange table is 0, the difference between block 0 of the new file and the suffix array of the original file is obtained to obtain the difference information and additional information of block 0 of the new file, and the block 0 of the new file is overwritten with the block 0 of the original file, and the suffix array of the original file is recalculated; if the second item of the block exchange table is 5, the difference between block 5 of the new file and the suffix array of the original file is obtained to obtain the difference information and additional information of block 5 of the new file, and the block 5 of the new file is overwritten with the block 5 of the original file, and the suffix array of the original file is recalculated.
[0069] Furthermore, step S40 also includes the following steps: inserting the block exchange table into the file header of the differential upgrade file package; compressing the differential upgrade file package to obtain a differential upgrade file.
[0070] In an optional implementation, xz compression can be used when compressing the differential upgrade file package. Xz compression is a compressed file format that can be compressed using multiple threads. It takes less time to compress and the size of the compressed file is smaller. Using xz compression takes less time and the resulting differential upgrade file is smaller, which can effectively improve the efficiency of differential upgrades. The compression method can also be other existing compression methods such as 7z and gzip, which are not limited here.
[0071] like Figure 6 As shown, Figure 6 This is a schematic diagram of the structure of the differential upgrade file package. The differential upgrade file package includes a file header, a differential information area, and an additional information area. The differential information area and the additional information area respectively store the differential information and additional information obtained by differential calculation according to the order of the block exchange table; the file header includes control information and a block exchange table. During the differential upgrade process, the control information and the block exchange table can be called to obtain the address information of the differential upgrade file and perform the corresponding upgrade steps.
[0072] Different from the prior art, the technical solution of the present application is based on the order of the block exchange table. By differentiating the blocks of each new file with the original file, the differential content of the blocks of the new file is obtained in sequence. The differential content includes differential information and additional information, which are respectively used as the differential information area and the additional information area of the differential upgrade file. Based on the differential information and the additional information, a differential upgrade file is obtained. The differential upgrade file obtained based on the order of the block exchange table is differentially upgraded, which can avoid the instability of the differential upgrade file and improve the upgrade speed and stability.
[0073] like Figure 7 , Figure 8 shown. Figure 7 It is a flowchart of the fourth embodiment of the block differential upgrade method provided by the present application; Figure 8It is a flowchart of the fifth embodiment of the block differential upgrade method provided by the present application.
[0074] Optionally, step S50 includes the following steps:
[0075] S510: Obtain a first structure and a second structure of a differential upgrade file.
[0076] S520: Acquire first address information from the first structure, and acquire second address information from the second structure.
[0077] S530: Based on the order of the block exchange table of the differential upgrade file, the original file is upgraded to a new file.
[0078] In one embodiment, the differential upgrade file package is xz compressed to obtain a differential upgrade file. When the differential upgrade file is decompressed, the first structure (diff_xz) and the second structure (extra_xz) are used to quickly locate the first address information and the second address information, and the positions of the first information (diffinfo) and the second information (extra info) are determined based on the first address information and the second address information. At the same time, the block exchange table of the differential upgrade file is taken out, and the original file is upgraded to a new file based on the block upgrade sequence of the block exchange table.
[0079] Furthermore, step S50 also includes the following steps:
[0080] S540: Write the blocks of the new file into the backup area.
[0081] S550: Erasing the content of the blocks of the original file corresponding to the blocks of the new file.
[0082] S560: Copy the content of the backup area to the corresponding blocks of the original file.
[0083] S570: Erase the content of the backup area.
[0084] The above steps S540-S570 are repeatedly executed based on the order of the block exchange table to upgrade the original file to a new file.
[0085] Based on the order of the block exchange table, each block of the original file is upgraded to the content of the new file. For example, if the first item of the block exchange table is 0, first restore block 0 of the new file and write it to the backup area until 32k is filled; erase block 0 of the original file; copy the content of the backup area to block 0 of the original file; erase the content of the backup area; the second item of the block exchange table is 5, repeat the above steps, and upgrade block 5 of the original file to block 5 of the new file; based on the order of the block exchange table, repeat the above steps until the last block of the original file is upgraded to the last block of the new file.
[0086] Different from the prior art, the technical solution of the present application replaces the original file blocks with new file blocks based on the order of the block exchange table, upgrades the original file to a new file, optimizes the block upgrade order, avoids instability in differential upgrade files, and improves upgrade speed and stability.
[0087] Optionally, the step of upgrading the original file to a new file based on the order of the differential upgrade file and the block exchange table in step S105 also includes: saving the current step when a power-off signal is received; and continuing to execute the current step when a recovery signal is received.
[0088] In the differential upgrade process, in order to prevent the upgrade process from being interrupted by a sudden power outage, a power-off control block is used to save the steps of each upgrade. When a power-off signal is received, the current upgrade steps can be saved so that the next time the power is turned on, the upgrade can be restored to the last completed step to continue, avoiding the need to re-upgrade the next time the power is turned on, which affects the user's upgrade experience.
[0089] The present application also proposes a terminal device, such as Fig. 9 As shown, Fig. 9 1 is a schematic diagram of the structure of an embodiment of the terminal device of the present application, and the terminal device 100 includes: a processor 101, a memory 102 and a bus 103. The processor 101 and the memory 102 are respectively connected to the bus 103, and the memory 102 stores program instructions. The processor 101 is used to execute the program instructions to implement the differential upgrade method in the above embodiment.
[0090] In this embodiment, the processor 101 may also be referred to as a CPU (Central Processing Unit). The processor 101 may be an integrated circuit chip having signal processing capabilities. The processor 101 may also be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. A general-purpose processor may be a microprocessor or the processor 101 may also be any conventional processor, etc.
[0091] The present application also proposes a computer-readable storage medium, such as Fig.10 As shown, Fig.10 It is a structural diagram of an embodiment of a computer-readable storage medium of the present application. The computer-readable storage medium 110 stores program instructions 111 thereon. When the program instructions 111 are executed by a processor (not shown), the differential upgrade method in the above embodiment is implemented.
[0092] In this embodiment, the computer-readable storage medium 110 can be, but is not limited to, a USB flash drive, an SD card, a PD optical drive, a mobile hard disk, a large-capacity floppy drive, a flash memory, a multimedia memory card, a server, a storage unit in an FPGA or an ASIC, etc.
[0093] Different from the prior art, the technical solution of the present application calculates the reference ratio of the new file block to the corresponding original file block to obtain a block weight table, obtains a block movement table based on the block weight table, inserts the block movement table into a binary tree for subsequent traversal, obtains a block differential upgrade order based on the block exchange table, and sequentially calculates the differential content of each new file block based on the order of the block exchange table to obtain a differential upgrade file, and upgrades the original file to a new file based on the order of the differential upgrade file and the block exchange table. The present application optimizes the block differential upgrade order to avoid the loss of important reference information when erasing the original data, avoids instability in the differential upgrade file, and improves the upgrade speed and stability.
[0094] The above description is only an implementation method of the present application, and does not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly used in other related technical fields, are also included in the patent protection scope of the present application.
Claims
1. A block differential upgrade method, characterized in that: The following steps are involved: Calculate the full difference package of the original file and the new file, perform preset block division on the original file and the new file, and obtain a plurality of blocks of the original file and a plurality of blocks of the new file; Obtain a block weight table based on the full differential packet, and obtain a block movement table based on the block weight table; Inserting the block movement table into a binary tree, and traversing all the binary trees to obtain a block exchange table; Based on the order of the block exchange table, the differential content of each block of the new file is obtained in turn to obtain a differential upgrade file; Based on the sequence of the differential upgrade file and the block exchange table, the original file is upgraded to the new file; The step of obtaining a block weight table based on the full differential packet includes: Obtain a character string of the block of the original file corresponding to each block reference of the new file; Calculating the ratio of the character string to the corresponding block of the original file, and obtaining the block weight table based on the corresponding ratios of all the blocks of the new file; The step of obtaining the block movement table based on the block weight table comprises: Each block of the original file in the block weight table is moved to the corresponding block of the new file to obtain the block movement table; The step of inserting the block movement table into the binary tree comprises: Taking each block of the original file in the block movement table as a parent node of the binary tree; Taking each block of the new file in the block movement table as a child node of the binary tree; When there are two identical blocks in the block movement table, the two identical blocks are not inserted into the binary tree; When the blocks of the new file in the block movement table contain references to the blocks of the original file, and the blocks of the new file reference a partial character string of the blocks of the original file, it is determined that the blocks of the original file and the blocks of the new file reference each other, and the block with a higher ratio among the two mutually referenced blocks is used as the parent node of the binary tree; The step of traversing all the binary trees to obtain a block exchange table comprises: Perform a subsequent traversal on each of the binary trees to obtain the block exchange table; The block movement table is used to indicate the order in which the blocks of the original file are to be moved to the blocks of the new file, and the block exchange table is used to indicate the order in which the data of the original file is erased.
2. The block differential upgrade method according to claim 1, characterized in that: The step of sequentially finding the differential content of the blocks of each of the new files based on the order of the block exchange table to obtain the differential upgrade file comprises: Based on the order of the block exchange table, the blocks of each new file are differentiated from the suffix array of the original file to obtain first information and second information corresponding to the blocks of each new file, wherein the first information is difference information and the second information is additional information; Obtaining a differential upgrade file package based on the first information and the second information, wherein the first information and the second information are used as a first area and a second area of the differential upgrade file package respectively, the first area is a difference information area, and the second area is an additional information area; The blocks of the new file are overwritten with the corresponding blocks of the original file, and the suffix array of the original file is recalculated.
3. The block differential upgrade method according to claim 2, characterized in that: The step of obtaining the differential upgrade file includes: Inserting the block exchange table into the file header of the differential upgrade file package; The differential upgrade file package is compressed to obtain the differential upgrade file.
4. The block differential upgrade method according to claim 3, characterized in that: The differential upgrade file includes a first structure and a second structure, the first structure corresponds to the first address information, and the second structure corresponds to the second address information; The step of upgrading the original file to the new file based on the sequence of the differential upgrade file and the block exchange table includes: Obtaining a first structure and a second structure of the differential upgrade file; Acquire first address information from the first structure, and acquire second address information from the second structure; determining a location of the first information based on the first address information, and determining a location of the second information based on the second address information; The original file is upgraded to the new file based on the order of the block exchange table of the differential upgrade file.
5. The block differential upgrade method according to claim 4, characterized in that: The step of upgrading the original file to the new file based on the order of the block exchange table of the differential upgrade file includes: Writing the blocks of the new file into the backup area; Erasing the content of the blocks of the original file corresponding to the blocks of the new file; Copying the contents of the backup area to the corresponding blocks of the original file; Erasing the content of the backup area; The above steps are repeatedly performed based on the order of the block exchange table to upgrade the original file to the new file.
6. The block differential upgrade method according to claim 4, characterized in that: The step of upgrading the original file to the new file based on the sequence of the differential upgrade file and the block exchange table also includes: When receiving a power-off signal, save the current step; When the recovery signal is received, the current step is continued.
7. A terminal device, characterized in that: The terminal device includes a processor and a memory; a computer program is stored in the memory, and the processor is used to execute the computer program to implement the steps of the block differential upgrade method as described in any one of claims 1 to 6.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed, the steps of the block differential upgrade method according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Differential upgrade package generation method, device and equipment
CN111258620A
Differential packet generation method, differential packet generation equipment and upgrading method
CN113721967A