Remote file differential transfer and iteration method and apparatus
By locating and sending the compressed data of the target file using an index file in the target compressed package, the client decompresses the file to achieve iterative updates of the software/service. This solves the problems of high CPU resource consumption and mount point list access bottlenecks in existing technologies, and achieves efficient iterative updates.
Patent Information
- Application Number
- CN202511368695.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-24
- Publication Date
- 2025-12-12
- Estimated Expiration
- 2045-09-24
AI Technical Summary
Existing technologies consume high CPU resources and are inefficient during software and service iteration, and accessing the mount point list becomes a performance bottleneck.
By receiving the hash value from the client, the target compressed file is located using the index file in the target compressed package, and the compressed data of the target file is sent. The client decompresses the data according to the index table to achieve iterative updates, thus avoiding the decompression of the target compressed package and mounting of the file system.
It reduces CPU resource consumption, improves transmission efficiency, and avoids performance issues caused by accessing the mount point list.
Smart Images

Figure CN120849355B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of computers, in particular to a remote file differential transmission and iteration method and device. BACKGROUND
[0002] With the development of Internet technology, rapid iteration of software and services has become the norm. When iterating, the Archivemount tool can be used on the server to mount the compressed package of the new version of software / service to a specific directory through the fuse file system, and then the rsync tool can be used to compare the compressed package file list under the specific directory on the server with the file list on the terminal to determine the difference file and download the difference file to the terminal. On the one hand, since the general compressed package does not have a file positioning function, when the difference file needs to be downloaded, the Archivemount tool will decompress the entire compressed package from the beginning until the difference file is found, and cannot directly locate the difference file, resulting in high CPU resource consumption and low efficiency of the entire scheme. On the other hand, since the Archivemount tool mounts the compressed package of the new version of software to a specific directory through the fuse file system, the corresponding mount point needs to be added to the mount point list, and when there are multiple difference files being downloaded at the same time, the access of the file system to the mount point list will also become a performance bottleneck.
[0003] Therefore, how to provide an iteration scheme applicable to software and services, which can reduce CPU resource consumption and improve efficiency, has become a technical problem to be solved. SUMMARY
[0004] In view of the technical problems existing in the prior art, the present application provides a remote file differential transmission and iteration method and device.
[0005] In a first aspect, the present application provides a remote file differential transmission method applied to a server, comprising:
[0006] receiving a hash value of at least one file in a specific directory transmitted by a client, reading an index file in a target compressed package, traversing the information of each file in the index file, obtaining the hash value of the current file from the index file, if it is determined that the hash value of the current file is different from the hash value of each file in the at least one file, and the hash value of the current file is different from the hash value of the file that has been traversed, obtaining the compressed data size of the current file from the index file, wherein the index file contains the file name, hash value, compressed data size and offset position of the compressed data of each file in the target compressed package;
[0007] determining a target file header according to the compressed data size of each file, and sending the target file header and the index table in the target compressed package to the client.
[0008] For each target file, the compressed data of the target file is determined according to the offset position of the compressed data of the target file in the target compressed package, and the compressed data of the target file is sent to the client, wherein the target file includes a file whose compressed data size is obtained in the traversal process;
[0009] The tail of the target file and at least part of the data in the index file are sent to the client, wherein the at least part of the data includes the file name and the hash value.
[0010] In a second aspect, the embodiments of the present application further provide a remote file differential iteration method applied to a client, comprising:
[0011] The target file header and the index table sent by the server are received;
[0012] The compressed data of the target file sent by the server is received, wherein the target file includes a file whose hash value in the target compressed package is different from the hash value of at least one file in a specific directory of the client, and the hash values of different target files are different;
[0013] The tail of the target file and at least part of the data in the index file of the target compressed package sent by the server are received, wherein the at least part of the data includes the file name and the hash value;
[0014] The compressed data of the target file is decompressed to the target directory by using the index table, and the information of each file in the index file is traversed, if the hash value of the current file is different from the hash value of each file in the at least one file, and the hash value of the current file is different from the hash value of the file that has been traversed, then the current file is skipped.
[0015] In a third aspect, the embodiments of the present application further provide a remote file differential transmission device applied to a server, comprising:
[0016] The hash value of at least one file in a specific directory transmitted by the client is received, the index file in the target compressed package is read, the information of each file in the index file is traversed, the hash value of the current file is obtained from the index file, if it is judged that the hash value of the current file is different from the hash value of each file in the at least one file, and the hash value of the current file is different from the hash value of the file that has been traversed, then the compressed data size of the current file is obtained from the index file, wherein the index file includes the file name, the hash value, the compressed data size and the offset position of the compressed data in the target compressed package of each file in the target compressed package;
[0017] The sending unit is configured to determine a target file header according to the compressed data size of each file, and send the target file header and an index table in the target compressed package to the client.
[0018] For each target file, the compressed data of the target file is determined according to the offset position of the compressed data of the target file in the target compressed package, and the compressed data of the target file is sent to the client, wherein the target file includes a file whose compressed data size is obtained in the traversal process; and
[0019] The target file tail and at least part of data in the index file are sent to the client, wherein the at least part of data includes a file name and a hash value.
[0020] In a fourth aspect, the embodiments of the present application further provide a remote file differential iteration device, applied to a client, comprising:
[0021] The receiving unit is configured to receive the target file header and the index table sent by the server; and
[0022] The receiving unit is configured to receive the compressed data of the target file sent by the server, wherein the target file includes a file whose hash value in the target compressed package is different from the hash value of each file in at least one file in a specific directory of the client, and the hash values of different target files are different; and
[0023] The receiving unit is configured to receive the target file tail and at least part of data in the index file of the target compressed package sent by the server, wherein the at least part of data includes a file name and a hash value.
[0024] The decompression unit is configured to decompress the compressed data of the target file to a target directory by using the index table, and traverse the information of each file in the index file, and if the hash value of a current file is different from the hash value of each file in the at least one file and the hash value of the current file is different from the hash value of the file that has been traversed, the current file is skipped.
[0025] In summary, the remote file differential transmission and iteration method and device provided by the embodiments of the present application extract the compressed data of the target file from the target compressed package by using the index file in the target compressed package, and send the compressed data of the target file and at least part of data in the index file to the client. After receiving the data, the client can decompress the compressed data to realize the iteration update of the software / service. Compared with the prior art, the whole scheme can directly locate the data that needs to be downloaded in the target compressed package, does not need to decompress the target compressed package, and does not need to mount the file system, so that the performance problem caused by the access to the mount point list does not occur, thereby reducing the CPU resource consumption and improving the efficiency. BRIEF DESCRIPTION OF DRAWINGS
[0026] Figure 1A flow diagram of an embodiment of a remote file differential transmission method provided by the embodiments of the present application is shown in FIG. 1.
[0027] Figure 2 A flow diagram of an embodiment of a remote file differential iteration method provided by the embodiments of the present application is shown in FIG. 2.
[0028] Figure 3 A structural diagram of an embodiment of a remote file differential transmission device provided by the embodiments of the present application is shown in FIG. 3.
[0029] Figure 4 A structural diagram of an embodiment of a remote file differential iteration device provided by the embodiments of the present application is shown in FIG. 4. DETAILED DESCRIPTION
[0030] To make the objectives, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be described below in detail with reference to the drawings in the embodiments of the present application. It should be understood that the drawings in the present application are only used for the purpose of description and illustration, and are not used to limit the scope of protection of the present application. In addition, it should be understood that the schematic drawings are not drawn according to the actual proportions. The flowchart shows the operations implemented according to some embodiments of the present application. It should be understood that the operations of the flowchart can not be implemented in sequence, and the steps without logical context relationship can be reversed in sequence or implemented simultaneously. In addition, one or more other operations can be added to the flowchart or one or more operations can be removed from the flowchart under the guidance of the content of the present application.
[0031] In addition, the described embodiments are only some of the embodiments of the present application, not all the embodiments. The components of the embodiments of the present application described and shown in the drawings herein can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the claimed present application, but only represents selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without creative labor are within the scope of protection of the present application.
[0032] It should be noted that the term "comprising" will be used in the embodiments of the present application to indicate the presence of the features declared thereafter, but does not exclude the addition of other features.
[0033] Reference Figure 1 As shown in FIG. 1, the embodiments of the present application provide a flowchart of a remote file differential transmission method, which is applied to a server and includes the following steps.
[0034] S10, receiving the hash value of at least one file in the specific directory transmitted by the client, reading the index file in the target compression package, traversing the information of each file in the index file, obtaining the hash value of the current file from the index file, if it is judged that the hash value of the current file is different from the hash value of each file in the at least one file, and the hash value of the current file is different from the hash value of the file that has been traversed, obtaining the compression data size of the current file from the index file, wherein the index file contains the file name, hash value, compression data size and offset position of the compression data of each file in the target compression package;
[0035] In the embodiment, it should be noted that the index file is pre-generated and compressed into the target compression package, and the compression algorithm used can be the same as the compression algorithm used to generate the target compression package. The index file contains the file name, hash value, compression data size and offset position of the compression data of each ordinary file in the target compression package, in addition to this, it can also contain the file name, hash value, compression data size and offset position of the compression data of each special file and folder in the target compression package. The ordinary file refers to the file that actually stores the file data content in the disk, and the special file refers to the file that does not store the file data content in the disk. The file recorded in the embodiment refers to the ordinary file, and for the special file and folder in the target compression package, because the compression data is small, the compression data can be directly extracted from the target compression package and sent to the client for decompression, so as to update the special file and folder under the target directory. The file name of the file / folder can include the relative path of the file / folder relative to the target compression package. When reading the index file in the target compression package, it can be directly read without decompressing the target compression package. When traversing the information of the file in the index file, if the hash value of the current file is different from the hash value of each file in the at least one file transmitted by the client, and the hash value of the current file is different from the hash value of the file that has been traversed, the compression data size of the current file is obtained from the index file, and the compression data size of the at least one file is finally obtained. These files are the files that need to transmit the compression data to the client, that is, the target files referred to in step S12.
[0036] S11, determining the target file header according to the obtained compression data size of each file, and sending the target file header and the index table in the target compression package to the client;
[0037] It should be noted that in this embodiment, after the at least one compressed data size is obtained in step S10, the size of a new compressed package is calculated according to the at least one compressed data size, and a target file header is generated according to the size of the new compressed package, the target file header being the file header of the new compressed package, and the target file header containing the size of the new compressed package. The target file header (fixed size), an index table (an index table in the target compressed package), compressed data to be transmitted to the client, and a target file tail (fixed size) constitute the new compressed package, and the total size of the contents included in the new compressed package is the size of the new compressed package. The new compressed package needs to be transmitted to the client, and when the new compressed package is transmitted, the target file header and the index table can be transmitted first in a streaming manner, then the compressed data is transmitted, and finally the target file tail is transmitted.
[0038] S12, for each target file, determining the compressed data of the target file according to the offset position of the compressed data of the target file in the target compressed package, and sending the compressed data of the target file to the client, wherein the target file includes a file whose compressed data size is obtained in the traversal process;
[0039] It should be noted that the target file in step S12 is the file whose compressed data needs to be transmitted to the client, and the compressed data of the target file needs to be determined according to the offset position of the compressed data of the target file in the target compression package in the index file. The compressed data of the target file is not necessarily the compressed data of the target file in the target compression package: if the target file is independently compressed (i.e., the data of the target file is not merged and compressed with the data of other files / folders), the compressed data of the target file is the compressed data of the target file in the target compression package; if the target file is not independently compressed (i.e., the data of the target file is merged and compressed with the data of other files / folders), the compressed data of the target file is not the compressed data of the target file in the target compression package. In this case, the compressed data of the target file includes the independently compressed data of the target file in the index file and the independently compressed data of the target file in the target compression package. For example, the compressed data of the target file A in the target compression package includes three parts I1, I2 and I3, wherein I1 is obtained by merging and compressing part of the data N of the file B in the target compression package with part of the data M1 of the target file A, I1 is the non-independently compressed data part of the target file A in the target compression package, I2 and I3 are obtained by compressing part of the data M2 and part of the data M3 of the target file A, respectively, I2 and I3 are the independently compressed data parts of the target file A in the target compression package, M1, M2 and M3 constitute all the data of the target file A, the index file contains I11 and M1, I11 is the compressed data obtained by compressing M1, i.e., I11 is the independently compressed data of the data source M1 of the target file A, and the finally determined compressed data of the target file A includes the compressed data I11 of part of the data M1 of the target file A in the index file, I2 and I3, wherein the index file further includes the offset positions of I1, I2 and I3 in the target compression package. Thus, I1, I2 and I3 can be extracted from the target compression package according to the offset positions of I1, I2 and I3 in the target compression package, I11 corresponding to M1 is determined from the index file, and finally I11, I2 and I3 are determined as the finally determined compressed data of the target file A (i.e., the compressed data of the target file A to be sent to the client).
[0040] S13, sending the target file tail and at least part of the data in the index file to the client, wherein the at least part of the data includes the file name and the hash value.
[0041] In this embodiment, it should be noted that the file name and the hash value in the index file are sent to the client to enable the client to check whether there is a file in the at least one file under the specific directory whose hash value is different from the hash value sent by the server, because if there is a file whose hash value is different from the hash value sent by the server, it needs to be ensured that there is no such file in the updated target directory.
[0042] The remote file differential transmission method provided by the embodiments of the present application extracts the compressed data of the target file from the target compressed package by using the index file in the target compressed package, and sends the compressed data of the target file and at least part of the data in the index file to the client, so that the client decompresses the compressed data to realize the iterative update of the software / service. Compared with the prior art, the whole scheme can directly locate the data to be downloaded in the target compressed package, does not need to decompress the target compressed package, and does not need to mount the file system, so that the performance problem caused by the access to the mount point list does not occur, thereby reducing the CPU resource consumption and improving the efficiency.
[0043] On the basis of the foregoing method embodiments, the compressed data of the target file can be determined according to the offset position of the compressed data of the target file in the target compressed package, which can include:
[0044] If the compressed data of the target file in the target compressed package is independent compressed data, the compressed data of the target file is directly extracted from the target compressed package according to the offset position of the compressed data of the target file in the target compressed package; or
[0045] If the compressed data of the target file in the target compressed package is non-independent compressed data, the independent compressed data corresponding to the non-independent compressed data part of the target file in the target compressed package is obtained from the index file, the independent compressed data part of the target file in the target compressed package is directly extracted from the target compressed package according to the offset position of the compressed data of the target file in the target compressed package, and the independent compressed data obtained from the index file and the independent compressed data part of the target file in the target compressed package are combined to obtain the compressed data of the target file, wherein the index file further includes the independent compressed data corresponding to the non-independent compressed data part and the source data.
[0046] In the embodiments, it should be noted that if the compressed data of the target file in the target compressed package is independent compressed data, the compressed data of the target file can be directly extracted from the target compressed package according to the offset position of the compressed data of the target file in the target compressed package, for example, the compressed data of the target file C in the target compressed package includes two parts of I4 and I5, I4 and I5 are respectively compressed data of part data M4 and part data M5 of the target file C, and M4 and M5 constitute all data of the target file C, so I4 and I5 can be directly extracted from the target compressed package according to the offset position of I4 and I5 in the target compressed package included in the index file.
[0047] If the compressed data of the target file in the target compressed package is non-independent compressed data, the independent compressed data corresponding to the non-independent compressed data part of the target file in the target compressed package is obtained from the index file, the independent compressed data part of the target file in the target compressed package is directly extracted from the target compressed package according to the offset position of the compressed data of the target file in the target compressed package, and the compressed data of the target file is obtained by combining the independent compressed data obtained from the index file and the independent compressed data part extracted from the target compressed package, such as the target file A in the foregoing example, the independent compressed data I11 corresponding to the non-independent compressed data part I1 of the target file A in the target compressed package is obtained from the index file, the independent compressed data parts I2 and I3 of the target file A in the target compressed package are directly extracted from the target compressed package according to the offset positions of I2 and I3 in the target compressed package, and the compressed data of the target file A is obtained by combining I11, I2 and I3, that is, the compressed data of the target file A to be sent to the client.
[0048] On the basis of the foregoing method embodiment, before the index file in the target compressed package is read, the method can further include:
[0049] The target compressed package is decompressed to obtain a decompression result, wherein the decompression result includes a plurality of items;
[0050] The index file is generated, the information of each item in the plurality of items is obtained, and the information of the item is saved into the index file, wherein the information of the item includes the file name corresponding to the item, the hash value of the item, the compressed data size of the item, and the offset position of the compressed data in the target compressed package;
[0051] The index file is compressed into the target compressed package.
[0052] In this embodiment, it should be noted that this embodiment is the process of creating an index file, which needs to be performed in advance, and this process needs to decompress the target compression package once, and the subsequent process of iterative updating between the client and the server does not need to decompress the target compression package. The decompression result of the target compression package can be a file (such as a tar package) or a folder. If the decompression result is a file, the information of each item in the file needs to be obtained and saved into the index file; if the decompression result is a folder (each file / folder in the folder is an item), the information of each file / folder in the folder needs to be obtained and saved into the index file. The information of each item includes the file name corresponding to the item, the hash value of the item, the compressed data size of the item, and the offset position of the compressed data in the target compression package, wherein the compressed data size of the item is the size of the compressed data of the file corresponding to the item that needs to be sent to the client, such as the total size of I11, I2 and I3 for the target file A in the foregoing example. The offset position of the compressed data in the target compression package refers to the offset position of the compressed data of the file / folder corresponding to the item in the target compression package, such as the offset positions of I1, I2 and I3 in the target compression package for the target file A in the foregoing example. In addition to the file name, the hash value, the compressed data size and the offset position of the compressed data in the target compression package, the index file can also include the independent compressed data and the source data corresponding to the non-independent compressed data part of the corresponding file / folder, such as the independent compressed data I11 and the source data M1 corresponding to the non-independent compressed data part I1 of the target file A in the foregoing example. It should be noted that if the index table includes the corresponding relationship between the independent compressed data and the source data, the corresponding relationship can be directly used, and if the index table does not include the corresponding relationship between the independent compressed data and the source data, the corresponding relationship needs to be constructed, and the construction of the corresponding relationship needs to ensure that there is no conflict with the original corresponding relationship in the index table. In addition, the index file can also include the file mode (FileMode), the file owner user identifier (FileUid), the file owner group identifier (FileGid), the file modification time (FileModifyTime) and the file device number (FileDev) of the corresponding file / folder. In addition, when compressing the index file, the index file can be placed behind the file tail in the target compression package, so that the decompression of the target compression package (such as the decompression of the tar.gz format target compression package by the tar program of the Linux system) can automatically skip the index file, so that the original code of the decompression program does not need to be modified.
[0053] Referring toFigure 2 As shown, the embodiment of the present application provides a flowchart of a remote file differential iteration method, which is applied to a client and includes the following steps.
[0054] S20, receiving a target file header and an index table sent by a server;
[0055] In the embodiment, it should be noted that the target file header contains the size of the compressed package sent by the server, and the client can evaluate whether there is enough storage space for storing the compressed package data sent by the server based on the size of the compressed package after receiving the target file header, and then take corresponding measures.
[0056] S21, receiving compressed data of a target file sent by the server, wherein the target file includes a file whose hash value is different from the hash value of each file in at least one file under a specific directory of the client in the target compressed package, and the hash values of different target files are different;
[0057] In the embodiment, it should be noted that the target file is a file that exists in the target compressed package but does not exist in at least one file under the specific directory of the client, and the hash values of different target files are different, so that the file generated after the compressed data received by the client is decompressed will not be repeated with the file content in at least one file under the specific directory, and the content of the file decompressed by the client will not be repeated, so that the client can complete the iterative update of the software / service on the basis of downloading the minimum data.
[0058] S22, receiving a target file tail and at least part of data in an index file of the target compressed package sent by the server, wherein the at least part of data includes a file name and a hash value;
[0059] S23, decompressing the compressed data of the target file to a target directory by using the index table, and traversing the information of each file in the index file, if the hash value of the current file is different from the hash value of each file in the at least one file, and the hash value of the current file is different from the hash value of the traversed file, then skipping.
[0060] In the embodiment, it should be noted that the target file header, the index table, the compressed data of the target file and the target file tail received by the client logically constitute a new compressed package. After receiving the compressed data of the target file, the client can decompress the compressed data of the target file to the target directory by using the index table.
[0061] If the target directory is the specific directory, it is required to decompress the compressed data to the corresponding path (the relative path of which can be the relative path of the file corresponding to the compressed data) under the specific directory, and traverse the information of each file in the index file: if the hash value of the current file is different from the hash value of each file in the at least one file, and the hash value of the current file is different from the hash value of the file that has been traversed, skip; if the hash value of the current file is different from the hash value of each file in the at least one file, and the hash value of the current file is the same as the hash value of a file that has been traversed, it is required to create the current file or modify the content of the existing file (the relative path of which is the same as the relative path of the current file) under the specific directory based on the relative path of the current file (the content of the existing file after modification is the current file), and make the content of the current file the same as the content of the file that has been traversed and the hash value of which is the same as the hash value of the current file (such as copying the content of the file that has been traversed and the hash value of which is the same as the hash value of the current file into the current file, or creating a hard link to make the two files share the same file content); if the hash value of the current file is the same as the hash value of a file in the at least one file, it is required to determine whether there is a file with the same relative path as the relative path of the current file under the specific directory, if not, it is required to create a file with the relative path of the current file under the specific directory, and make the created file the same as the content of a file (the hash value of which is the same as the hash value of the current file) in the at least one file, or if there is, it is required to ensure that the content of the file with the same relative path as the relative path of the current file under the specific directory is the same as the content of a file (the hash value of which is the same as the hash value of the current file) in the at least one file, such as if the content of the file with the same relative path as the relative path of the current file under the specific directory is the same as the content of the file, no processing is required, otherwise, the content of the file with the same relative path as the relative path of the current file under the specific directory can be overwritten by the content of the file, and other means such as making the content of the file with the same relative path as the relative path of the current file under the specific directory the same as the content of the file.
[0062] If the target directory is not the specific directory, the compressed data needs to be decompressed to the corresponding path under the target directory, and the information of each file in the index file is traversed: if the hash value of the current file is different from the hash value of each file in the at least one file, and the hash value of the current file is different from the hash value of the traversed file, the current file is skipped; if the hash value of the current file is different from the hash value of each file in the at least one file, and the hash value of the current file is the same as the hash value of the traversed file, the current file needs to be created under the target directory, and the content of the current file is the same as the content of the file whose hash value is the same as that of the current file; if the hash value of the current file is the same as the hash value of one file in the at least one file, the current file needs to be created under the target directory, and the content of the current file is the same as the content of the file whose hash value is the same as that of the current file.
[0063] In addition, it should be noted that, in addition to the file name and the hash value, the at least part of the data can also include other information, such as independent compressed data corresponding to a non-independent compressed data part of a target file and source data. If the compressed data of a certain target file is independent compressed data, the index table can be directly used to decompress the compressed data of the target file; and if the compressed data of a certain target file is non-independent compressed data, the index table and the index file need to be used to decompress the compressed data of the target file, for example, for the target file A in the foregoing example, the decompressed data includes I11, I2 and I3, I11 needs to be decompressed using the independent compressed data I11 and the corresponding source data M1 included in the index file to decompress I11 into M1, and I2 and I3 need to be decompressed into M2 and M3 respectively using the index table, and finally the source data of the target file A includes M1, M2 and M3.
[0064] The remote file difference iteration method provided by the embodiment of the application receives the compressed data of the target file sent by the server, and decompresses the compressed data to realize the iterative update of the software / service. Since the compressed data of the target file is extracted from the target compressed package by the server using the index file in the target compressed package, compared with the prior art, the entire scheme can directly locate the data that needs to be downloaded in the target compressed package, does not need to decompress the target compressed package, and does not need to mount the file system, and thus the performance problem caused by the access to the mount point list does not occur, so that the CPU resource consumption can be reduced and the efficiency can be improved.
[0065] On the basis of the foregoing method embodiment, the method can further include:
[0066] If the hash value of the current file is not the same as the hash value of each file in the at least one file, and the hash value of the current file is the same as the hash value of a file that has been traversed, a new file is created under the target directory according to the file name of the current file.
[0067] On the basis of the foregoing method embodiment, the method can further comprise:
[0068] The file in the at least one file whose hash value is not the same as the hash value in the at least part of data is deleted.
[0069] Referring to Figure 3 FIG. 1 shows a structure schematic diagram of a remote file differential transmission device provided by an embodiment of the present application. The device is applied to a server and comprises:
[0070] The obtaining unit 30 is configured to receive the hash value of at least one file in a specific directory transmitted by a client, read an index file in a target compression package, traverse the information of each file in the index file, obtain the hash value of a current file from the index file, if it is judged that the hash value of the current file is not the same as the hash value of each file in the at least one file, and the hash value of the current file is not the same as the hash value of a file that has been traversed, obtain the compressed data size of the current file from the index file, wherein the index file contains the file name, hash value, compressed data size and offset position of the compressed data of each file in the target compression package.
[0071] The sending unit 31 is configured to determine a target file head according to the compressed data size of each file obtained, and send the target file head and the index table in the target compression package to the client; and
[0072] For each target file, the compressed data of the target file is determined according to the offset position of the compressed data of the target file in the target compression package, and the compressed data of the target file is sent to the client, wherein the target file comprises a file whose compressed data size is obtained in the traversal process; and
[0073] The target file tail and at least part of data in the index file are sent to the client, wherein the at least part of data comprises the file name and hash value.
[0074] The remote file differential transmission device provided by the embodiment of the present application extracts the compressed data of the target file from the target compressed package by using the index file in the target compressed package, and sends the compressed data of the target file and at least part of the data in the index file to the client, so that the client decompresses the compressed data to realize the iterative update of the software / service. Compared with the prior art, the whole scheme can directly locate the data to be downloaded in the target compressed package, does not need to decompress the target compressed package, and does not need to mount the file system, so that the performance problem caused by the access to the mount point list does not occur, and thus the CPU resource consumption can be reduced and the efficiency can be improved.
[0075] The remote file differential transmission device provided by the embodiment of the present application has the same implementation process and effect as the remote file differential transmission method provided by the embodiment of the present application, and thus the details are not described herein.
[0076] Referring to Figure 4 The device is applied to a client and includes:
[0077] The receiving unit 40 is configured to receive the target file header and the index table sent by the server.
[0078] The receiving unit 40 is configured to receive the compressed data of the target file sent by the server, wherein the target file includes a file whose hash value is different from the hash value of each file in at least one file in a specific directory of the client in the target compressed package, and the hash values of different target files are different.
[0079] The receiving unit 40 is configured to receive the target file tail and at least part of the data in the index file of the target compressed package sent by the server, wherein the at least part of the data includes a file name and a hash value.
[0080] The decompression unit 41 is configured to decompress the compressed data of the target file to the target directory by using the index table, and traverse the information of each file in the index file, and if the hash value of the current file is different from the hash value of each file in the at least one file and the hash value of the current file is different from the hash value of the traversed file, the current file is skipped.
[0081] The remote file differential transmission device provided by the embodiment of the present application receives the compressed data of the target file sent by the server, and decompresses the compressed data to realize the iterative update of the software / service. Since the compressed data of the target file is extracted from the target compressed package by using the index file in the target compressed package by the server, compared with the prior art, the whole scheme can directly locate the data to be downloaded in the target compressed package, does not need to decompress the target compressed package, and does not need to mount the file system, so that the performance problem caused by the access to the mount point list does not occur, and thus the CPU resource consumption can be reduced and the efficiency can be improved.
[0082] The remote file differential iteration device provided by the embodiments of the present application has the same implementation process and the same effect as the remote file differential iteration method provided by the embodiments of the present application, and thus will not be described here again.
[0083] The above merely describes specific embodiments of the present application, but the protection scope of the present application is not limited thereto, and any person skilled in the art can easily think of changes or replacements within the technical scope disclosed by the present application, which should be covered within the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.
Claims
1. A remote file differential transmission method, applied to a server, and characterized in that, The method comprises the following steps: receiving a hash value of at least one file in a specific directory transmitted by a client, reading an index file in a target compressed package, traversing information of each file in the index file, obtaining a hash value of a current file from the index file, if it is determined that the hash value of the current file is different from hash values of each file in the at least one file, and the hash value of the current file is different from hash values of the files that have been traversed, obtaining a compressed data size of the current file from the index file, wherein the index file contains file names, hash values, compressed data sizes and offset positions of compressed data of each file in the target compressed package; determining a target file header according to the obtained compressed data sizes of each file, and sending the target file header and an index table in the target compressed package to the client; for each target file, determining compressed data of the target file according to an offset position of the compressed data of the target file in the target compressed package, and sending the compressed data of the target file to the client, wherein the target file includes a file whose compressed data size is obtained in the traversing process; sending a target file tail and at least part of data in the index file to the client, wherein the at least part of data includes file names and hash values.
2. The method of claim 1, wherein, The determining of the compressed data of the target file according to the offset position of the compressed data of the target file in the target compressed package comprises: if the compressed data of the target file in the target compressed package is independent compressed data, directly extracting the compressed data of the target file from the target compressed package according to the offset position of the compressed data of the target file in the target compressed package; or if the compressed data of the target file in the target compressed package is non-independent compressed data, obtaining independent compressed data corresponding to a non-independent compressed data part of the target file in the target compressed package from the index file, directly extracting an independent compressed data part of the target file in the target compressed package from the target compressed package according to the offset position of the compressed data of the target file in the target compressed package, and combining the independent compressed data obtained from the index file and the independent compressed data part of the target file in the target compressed package to obtain the compressed data of the target file, wherein the index file further includes independent compressed data corresponding to the non-independent compressed data part and source data.
3. The method of claim 1 or 2, wherein, Before the reading of the index file in the target compressed package, the method further comprises the following steps: decompressing the target compressed package to obtain a decompression result, wherein the decompression result contains a plurality of items; generating an index file, obtaining information of each item in the plurality of items, and saving the information of the item into the index file, wherein the information of the item contains a file name corresponding to the item, a hash value of the item, a compressed data size of the item, and an offset position of compressed data in the target compressed package; compressing the index file into the target compressed package.
4. The method of claim 3, wherein, The information of the item further contains independent compressed data corresponding to a non-independent compressed data part of the item in the target compressed package and source data.
5. The method of claim 3, wherein, The index file is located behind a file tail in the target compressed package.
6. A remote file differential iteration method applied to a client, comprising: The method comprises the following steps: receiving a target file header and an index table sent by a server; receive the compressed data of the target file sent by the server, wherein the target file includes a file whose hash value is different from the hash value of each file in the at least one file in the specific directory of the client in the target compression package, and the hash values of different target files are different; receive the tail of the target file and at least part of the data in the index file of the target compression package, wherein the at least part of the data includes the file name and the hash value; decompress the compressed data of the target file to the target directory by using the index table, and traverse the information of each file in the index file, if the hash value of the current file is different from the hash value of each file in the at least one file, and the hash value of the current file is different from the hash value of the file that has been traversed, skip the information of the current file.
7. The method of claim 6, wherein, Further comprising: if the hash value of the current file is different from the hash value of each file in the at least one file, and the hash value of the current file is the same as the hash value of the file that has been traversed, create a new file according to the file name of the current file in the target directory.
8. The method of claim 6 or 7, wherein, Further comprising: delete the file whose hash value is different from the hash value in the at least part of the data in the at least one file.
9. A remote file differential transmission device, applied to a server, characterized in that, Comprise: an acquisition unit, configured to receive the hash value of the at least one file in the specific directory transmitted by the client, read the index file in the target compression package, traverse the information of each file in the index file, acquire the hash value of the current file from the index file, if it is judged that the hash value of the current file is different from the hash value of each file in the at least one file, and the hash value of the current file is different from the hash value of the file that has been traversed, acquire the compressed data size of the current file from the index file, wherein the index file contains the file name, the hash value, the compressed data size and the offset position of the compressed data of each file in the target compression package; a sending unit, configured to determine the target file header according to the compressed data size of each file acquired, and send the target file header and the index table in the target compression package to the client; and for each target file, determine the compressed data of the target file according to the offset position of the compressed data of the target file in the target compression package, and send the compressed data of the target file to the client, wherein the target file includes the file whose compressed data size is acquired in the traversal process; and send the tail of the target file and at least part of the data in the index file to the client, wherein the at least part of the data includes the file name and the hash value.
10. A remote file differential iteration apparatus applied to a client, characterized in that, Comprise: a receiving unit, configured to receive the target file header and the index table sent by the server; and receive the compressed data of the target file sent by the server, wherein the target file includes a file whose hash value is different from the hash value of each file in the at least one file in the specific directory of the client in the target compression package, and the hash values of different target files are different; and receive the tail of the target file and at least part of the data in the index file of the target compression package, wherein the at least part of the data includes the file name and the hash value; The decompression unit is configured to decompress the compressed data of the target file to the target directory by using the index table, and traverse the information of each file in the index file, and if the hash value of the current file is different from the hash value of each file in the at least one file, and the hash value of the current file is different from the hash value of the traversed file, skip the information of the current file.
Citation Information
Patent Citations
Business data compression and decompression method and device, equipment and medium
CN119441164A