A method, device, equipment, medium and product for rapid release of program files
By generating a comparison between the local hash tree and the cloud hash tree, using the file comparison table to locate the difference files, and only uploading or downloading the incremental files, the problem of low efficiency in publishing large program files is solved, and fast publishing and efficient cloud container startup are achieved.
Patent Information
- Application Number
- CN202210149975.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-02-18
- Publication Date
- 2025-09-09
- Estimated Expiration
- 2042-02-18
AI Technical Summary
In the prior art, program files are large in size, which results in long upload and download times to the cloud, and is particularly inefficient when repeated releases are required during the initial release verification phase.
By comparing the local hash tree with the cloud hash tree, using the file comparison table to locate the difference files, only uploading or downloading the incremental files, generating a complete program image and loading it into the cloud container.
It improves the efficiency of program file publishing, reduces upload and download time, speeds up cloud container startup, and saves resources.
Smart Images

Figure CN114661304B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method, apparatus, device, medium, and product for quickly publishing program files. Background Art
[0002] Currently, publishing programs on the cloud involves compiling them locally, packaging them, and uploading them to the cloud. The cloud container runs a public base image, and the packaged program is downloaded, decompressed, and run. Alternatively, there are two methods: compiling the program locally, packaging it into an image, and uploading it. The image is then downloaded and run on the cloud.
[0003] When the program file itself is relatively large, uploading and downloading will take a lot of time, resulting in low release efficiency. Especially in the initial release verification stage of the program, the program needs to be released repeatedly, and the development efficiency is particularly low.
[0004] With respect to the above-mentioned related technologies, the inventor believes that when the program file itself is relatively large and the program needs to be released repeatedly, there is a defect of low release efficiency. Summary of the Invention
[0005] In order to improve the efficiency of program file publishing, the present application provides a method, apparatus, device, medium and product for quickly publishing program files.
[0006] In a first aspect, the present application provides a method for quickly publishing a program file, which has the characteristic of improving the efficiency of program file publishing.
[0007] This application is achieved through the following technical solutions:
[0008] A method for quickly publishing a program file comprises the following steps:
[0009] Based on the directory hierarchy of the program files to be released, traverse in the depth direction and generate a local hash tree from the bottom to the top;
[0010] Compare the local hash tree with a cloud hash tree generated from the bottom layer to the top layer in the cloud, including all program files in the base image, to obtain a comparison result;
[0011] generating a file comparison table according to the comparison result;
[0012] Based on the file comparison table, data is uploaded with a data size smaller than that of the program file to be released, thereby completing the interaction with the cloud server.
[0013] In a preferred example, the present application may be further configured to include the following steps: based on the file comparison table, uploading data with a data size smaller than the data size of the program file to be released, and completing the step of interacting with the cloud server includes:
[0014] When the program files to be released are newly added compared to all the program files in the basic image on the cloud, the partial files in the program files to be released corresponding to the file comparison table are packaged and uploaded, and the file comparison table is uploaded at the same time.
[0015] In a preferred example, the present application can be further configured as follows: further comprising the following steps:
[0016] After receiving the file and the file comparison table, the cloud server downloads the preset files based on the file comparison table and filters and deletes them, and at the same time, assembles the downloaded files that have been deleted with the received files to generate a complete program;
[0017] A program image is generated based on the complete program, and the program image is loaded into a cloud container.
[0018] In a preferred example, the present application can be further configured as follows: further comprising the following steps:
[0019] After receiving the file and the file comparison table, the cloud server downloads a preset file based on the file comparison table, and simultaneously assembles the downloaded file with the received file to generate a complete program;
[0020] A program image is generated based on the complete program, and the program image is loaded into a cloud container.
[0021] In a preferred example, the present application may be further configured to include the following steps: based on the file comparison table, uploading data with a data size smaller than the data size of the program file to be released, and completing the step of interacting with the cloud server includes:
[0022] When the program files to be released are not newly added compared to all the program files in the basic image on the cloud, only the file comparison table is uploaded.
[0023] In a preferred example, the present application can be further configured as follows: further comprising the following steps:
[0024] After receiving the file comparison table, the cloud server downloads the preset files based on the file comparison table and performs screening and deletion, so that the downloaded files that have been deleted are generated into a complete program;
[0025] A program image is generated based on the complete program, and the program image is loaded into a cloud container.
[0026] In a preferred example, the present application can be further configured as follows: further comprising the following steps:
[0027] After receiving the file comparison table, the cloud server downloads the preset files based on the file comparison table and generates a complete program;
[0028] According to the complete program, a program image is generated and loaded into the cloud container. In a preferred example, the present application can be further configured to include the following steps:
[0029] The cloud container runs and downloads the program image, then starts the program to complete the release of the program file to be released.
[0030] In a preferred example, the present application may be further configured to include the following steps: the steps of traversing the directory hierarchy of the program file to be released in the depth direction and sequentially generating a local hash tree from the bottom layer to the upper layer include:
[0031] Calculate the hash value of each underlying file and generate the underlying hash value;
[0032] Calculate the hash values of the subdirectories or all files contained in the upper-level directory to generate the hash value of the upper-level directory;
[0033] Summarize the hash values of the bottom layer and the hash values of the upper layer to generate a local hash tree from the bottom layer to the upper layer.
[0034] In a preferred example, the present application may be further configured as follows: the step of comparing the local hash tree with the cloud hash tree generated from the bottom layer to the upper layer, which includes all program files in the base image, includes:
[0035] Compare the local hash tree with the cloud hash tree one by one, starting from the hash value corresponding to the top level of the directory hierarchy to the hash values corresponding to the lower levels;
[0036] If the hash values of the top layer are different, determine whether there are subdirectories in the next layer. If there are subdirectories in the next layer, compare the hash values of the subdirectories in the next layer of the directory hierarchy in turn. If the hash values of the subdirectories are different, determine whether there are files in the subdirectory. If there are files, recursively enter and compare the file hash values of all files in the directory at that level.
[0037] When the file hash value of the local hash tree is different from the file hash value of the cloud hash tree, and based on the file hash value of the local hash tree, if the file hash value does not have the same hash value in the cloud, then record the file name of the program file to be released corresponding to the file hash value of the local hash tree, and summarize them to form a new file list;
[0038] When the file hash value of the local hash tree is different from the file hash value of the cloud hash tree, and based on the file hash value of the cloud hash tree, if the file hash value does not have the same hash value locally, the file name corresponding to the file hash value of the cloud hash tree is recorded and summarized to form a deleted file list.
[0039] In a preferred example, the present application may be further configured as follows: the step of comparing the local hash tree with the cloud hash tree generated from the bottom layer to the upper layer, which includes all program files in the base image, includes:
[0040] Compare the local hash tree with the cloud hash tree one by one, starting from the hash value corresponding to the top level of the directory hierarchy to the hash values corresponding to the lower levels;
[0041] If the hash values of the directory names are different, and there are files in the directory, and the files in the directory at that level have not been compared, then the file name of the file that has not been compared is recorded;
[0042] If the hash values of the directory names are the same, determine whether there are subdirectories in the next level. If there are subdirectories in the next level, compare the hash values of the subdirectories corresponding to the next level of the directory hierarchy in turn. If the hash values of the subdirectories are different, determine whether there are files in the subdirectory. If there are files, recursively enter and compare the file hash values of all files in the directory at this level, and continue to determine whether there are new files or deleted files, so as to record the file names of the program files to be released corresponding to different file hash values.
[0043] In a preferred example, the present application can be further configured to include the following steps:
[0044] If the hash values of the top layers are the same, at least one different hash algorithm is used to calculate the hash values of the local hash tree and the cloud hash tree respectively;
[0045] Based on the newly calculated hash value, the local hash tree and the cloud hash tree are compared one by one from the hash value corresponding to the top level of the directory hierarchy to the hash value corresponding to the bottom level;
[0046] If the newly calculated hash values are the same, it is assumed that the local hash tree is the same as the cloud hash tree generated from the bottom layer to the upper layer in the cloud, which contains all program files in the basic image.
[0047] In a preferred example, the present application can be further configured to include the following steps:
[0048] Based on the newly added file list, obtaining the newly added program files corresponding to the newly added file list in the program files to be released;
[0049] The newly added program files are made to overwrite the program files in the base image in the program files to be released.
[0050] On the second aspect, the present application provides a device for quickly publishing program files, which has the characteristic of improving the efficiency of program file publishing.
[0051] This application is achieved through the following technical solutions:
[0052] A device for quickly publishing a program file, comprising:
[0053] The hierarchical hash tree module is used to traverse the directory hierarchy of the program files to be released in the depth direction and generate a local hash tree from the bottom to the top;
[0054] A comparison module is used to compare the local hash tree with a cloud hash tree generated from the bottom layer to the upper layer containing all program files in the base image in the cloud to obtain a comparison result;
[0055] A difference module, configured to generate a file comparison table based on the comparison result;
[0056] The packaging module is used to upload data with a data size smaller than that of the program file to be released based on the file comparison table, and complete the interaction with the cloud server.
[0057] On the third aspect, the present application provides a computer device having the characteristic of improving the efficiency of program file publishing.
[0058] This application is achieved through the following technical solutions:
[0059] A computer device includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the method for rapidly publishing a program file are implemented.
[0060] In a fourth aspect, the present application provides a computer-readable storage medium having the characteristic of improving the efficiency of program file publishing.
[0061] This application is achieved through the following technical solutions:
[0062] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the method for quickly publishing a program file.
[0063] In a fifth aspect, the present application provides a computer program product having the characteristic of improving the efficiency of program file publishing.
[0064] This application is achieved through the following technical solutions:
[0065] A computer program product includes a computer program, which implements the steps of the above-mentioned method for quickly publishing program files when executed by a processor.
[0066] In a sixth aspect, the present application provides a method for quickly publishing program files, which has the characteristic of improving the efficiency of program file publishing.
[0067] This application is achieved through the following technical solutions:
[0068] A method for quickly publishing a program file comprises the following steps:
[0069] Get files or file comparison tables from local;
[0070] After receiving the file and the file comparison table, based on the file comparison table, downloading the preset files and filtering and deleting them, and at the same time, assembling the downloaded files that have been deleted with the received files to generate a complete program;
[0071] After receiving the file and the file comparison table, downloading a preset file based on the file comparison table, and assembling the downloaded file with the received file to generate a complete program;
[0072] After receiving the file comparison table, the cloud server downloads the preset files based on the file comparison table and performs screening and deletion, so that the downloaded files that have been deleted are generated into a complete program;
[0073] After receiving the file comparison table, the cloud server downloads the preset files based on the file comparison table and generates a complete program;
[0074] Then, a program image is generated based on the complete program, and the program image is loaded into a cloud container.
[0075] In summary, this application includes at least one of the following beneficial technical effects:
[0076] 1. A method for rapidly publishing program files, based on the directory hierarchy of the program files to be published, traverses in depth and sequentially generates a local hash tree from the bottom layer to the top layer; then compares the local hash tree with a cloud hash tree generated from the bottom layer to the top layer in the cloud containing all program files in a base image, obtains a comparison result, and quickly locates the different files, avoiding the time-consuming problem of repeatedly calculating a large number of hash values when the number of files is too large, thereby improving comparison performance; then generates a file comparison table based on the comparison result; and uploads the portion of the program files to be published that corresponds to the file comparison table in the packaged file, and simultaneously uploads the file comparison table, that is, only uploads the portion of the files and the file comparison table, or only uploads the file comparison table, thereby improving program upload performance and thus improving program file publishing efficiency when the program files themselves are relatively large and need to be published repeatedly;
[0077] 2. When uploading a differential program package, all program files recorded in the newly added file list in the file comparison table are used to overwrite the program files in the base image to form a complete program package for the program files to be released. Therefore, only incremental files are uploaded when uploading program files, which improves the upload performance of program files.
[0078] 3. The local hash tree and the cloud hash tree are compared one by one from the hash value corresponding to the top layer of the directory hierarchy to the hash value corresponding to the lower layer. If the comparison results show that the hash values are the same, at least one different hash algorithm is used to calculate the hash values of the local hash tree and the cloud hash tree respectively. The local hash tree and the cloud hash tree are compared one by one again from the hash value corresponding to the top layer of the directory hierarchy to the hash value corresponding to the lower layer. Only when the hash values of the top layer are the same, the two program files are considered to be the same. Otherwise, the two program files are considered to be different, so as to solve the hash conflict problem. BRIEF DESCRIPTION OF THE DRAWINGS
[0079] Figure 1 This is an overall flow chart of a method for quickly publishing a program file in one embodiment of the present application.
[0080] Figure 2 It is a flowchart for comparing the local hash tree with the cloud hash tree.
[0081] Figure 3 It is a flowchart of packaging and uploading some files in the program file to be released that correspond to the file comparison table.
[0082] Figure 4 It is a flow chart for the release of program files.
[0083] Figure 5 This is a structural block diagram of a device for quickly publishing program files according to one embodiment of the present application. DETAILED DESCRIPTION
[0084] This specific embodiment is merely an explanation of the present application and is not a limitation of the present application. After reading this specification, those skilled in the art may make non-creative modifications to the present embodiment as needed, but as long as they are within the scope of the claims of the present application, they are protected by the patent law.
[0085] To make the purpose, technical solutions, and advantages of the embodiments of this application more clear, the technical solutions in the embodiments of this application will be clearly and completely described below in conjunction with the drawings in the embodiments of this application. Obviously, the described embodiments are part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0086] In this document, the term "and / or" simply describes a relationship between related objects, indicating that three possible relationships exist. For example, "A and / or B" can represent: A exists alone, A and B exist simultaneously, or B exists alone. Furthermore, the character " / " in this document, unless otherwise specified, generally indicates an "or" relationship between the related objects.
[0087] The embodiments of the present application are described in further detail below with reference to the accompanying drawings.
[0088] Reference Figure 1 , an embodiment of the present application provides a method for quickly publishing a program file, and the main steps of the method are described as follows.
[0089] S1: Based on the directory hierarchy of the program file to be released, traverse in the depth direction and generate a local hash tree from the bottom to the top;
[0090] S2: Compare the local hash tree with the cloud hash tree generated from the bottom layer to the top layer, including all program files in the base image, to obtain a comparison result;
[0091] S3: Generate a file comparison table based on the comparison results;
[0092] S4: Based on the file comparison table, upload data with a data size smaller than the program file to be released to complete the interaction with the cloud server.
[0093] Specifically, based on the directory hierarchy of the program to be released, a depth-first traversal is performed to generate a hash tree from the bottom layer to the upper layer, and the hash tree is the local hash tree.
[0094] The steps of generating a local hash tree from the bottom layer to the top layer include:
[0095] The hash value of each underlying file is calculated using a hash algorithm. The content of each file is calculated using the hash algorithm. The calculation result is a string of fixed length and is mapped one-to-one with the corresponding file content to generate the underlying hash value.
[0096] The same hash algorithm is then used to continue calculating the hash values of the subdirectories contained in the upper-level directory. When the subdirectories contain files, the hash values refer to the hash values of all the file contents. The hash values of all the files or directories contained in the upper-level directory are then hashed to obtain the corresponding hash values, that is, the hash values calculated for the hierarchical directories or all the files contained in the directory are then hashed to generate the hash value of the upper level. Specifically, a hash tree is calculated according to the hierarchical organization of the directory itself, where the hash of the file is calculated based on the file content, and the hash of each directory is calculated by calculating the hash value of an array composed of all the hashes of the lower level that have been calculated. The array is ordered, and in this embodiment, the elements in the array can be sorted in alphabetical order. In this embodiment, when the traversed directory contains only files, the hash value of each file is first calculated. In the process of traversing back, the hash value of each file is formed into an array. The array is then hashed and used as the hash value of the hierarchical directory contained in the upper-level directory, ultimately generating a hierarchical local hash tree. For example, assuming that the directories of the program to be released are a / x.txt and a / y.txt, first calculate the hash value of file x based on x.txt, then calculate the hash value of file y based on y.txt, and finally calculate the hash value of the upper directory a, that is, hash(hash-x, hash-y), and calculate the hash value of the array formed by all files contained in directory a.
[0097] Finally, the hash values of the bottom layer and the hash values of the upper layer are summarized to generate a local hash tree from the bottom layer to the upper layer.
[0098] For example,
[0099] / a / b / x.txt
[0100] / a / b / y.txt
[0101] / a / c / z.txt
[0102] Then generate a hash tree: a: hash_a = hash (hash_b, hash_c);
[0103] Where, b: hash_b = hash(hash_x, hash_y);
[0104] x.txt:hash_x=hash(x.txt);
[0105] y.txt:hash_y=hash(y.txt);
[0106] c:hash_c=hash(hash_z);
[0107] z.txt:hash_z=hash(z.txt).
[0108] The hash algorithm may be MD4 algorithm, MD5 algorithm or SHA-1 algorithm. In this embodiment, the hash algorithm adopts MD5 algorithm.
[0109] The hash values calculated by the hash algorithm are compared between two files. If the hash values are different, the two files are different. Therefore, once the file is modified, it can be detected.
[0110] Further, refer to Figure 2 , using the same hash algorithm, calculate the cloud hash tree from the bottom layer to the top layer generated by all program files in the cloud base image, which will not be repeated here.
[0111] S2: The steps of comparing the local hash tree with the cloud hash tree generated from the bottom layer to the top layer, including all program files in the base image, include:
[0112] When the directory levels of the local hash tree and the cloud hash tree are both one layer, if the hash values are the same, the file name of the program file to be released corresponding to the hash value is recorded, and the basic file list is summarized to download the preset files in the cloud; if the hash values are different, and when the hash value of the local hash tree is different from the hash value of the cloud hash tree, and the hash value of the local hash tree is used as the basis, if the hash value does not have the same hash value in the cloud, the file name of the program file to be released corresponding to the hash value of the local hash tree is recorded, and the new file list is summarized; and when the hash value of the local hash tree is different from the hash value of the cloud hash tree, and the hash value of the cloud hash tree is used as the basis, if the hash value does not have the same hash value locally, the file name corresponding to the hash value of the cloud hash tree is recorded, and the deleted file list is summarized.
[0113] When the directory hierarchy of the local hash tree and the cloud hash tree are both two layers, if the hash values of the top layer are the same, the file names of the program files to be released corresponding to the file hash values of all files in the hierarchy directory are recorded, and summarized to form a basic file list for downloading the preset files in the cloud; if the hash values of the top layer are different, it means that there are differences between the local program files and the cloud program files. At this time, the hash values of the files in the directory hierarchy are compared in turn; and when the file hash value of the local hash tree is different from the file hash value of the cloud hash tree, and the file hash value of the local hash tree is used as the basis, if the file hash value does not have the same hash value in the cloud, the file name of the program file to be released corresponding to the file hash value of the local hash tree is recorded, and summarized to form a new file list; and when the file hash value of the local hash tree is different from the file hash value of the cloud hash tree, and the file hash value of the cloud hash tree is used as the basis, if the file hash value does not have the same hash value locally, the file name corresponding to the file hash value of the cloud hash tree is recorded, and summarized to form a deleted file list.
[0114] S21: When the directory hierarchy of the local hash tree and the cloud hash tree has three levels, the local hash tree and the cloud hash tree are compared one by one from the hash value corresponding to the top level of the directory hierarchy to the hash value corresponding to the lower level; if the hash values of the top level are the same, the file names of the program files to be released corresponding to the file hash values of all files in the directory hierarchy are recorded;
[0115] If the hash values of the top level are different, the hash values of the subdirectories in the next level of the directory hierarchy are compared in sequence. If the hash values of the subdirectories are different, the hash values of all files in the directory at that level are recursively compared.
[0116] When the file hash value of the local hash tree is different from the file hash value of the cloud hash tree, and based on the file hash value of the local hash tree, if the file hash value does not have the same hash value in the cloud, then record the file name of the program file to be released corresponding to the file hash value of the local hash tree and summarize it to form a new file list;
[0117] When the file hash value of the local hash tree is different from the file hash value of the cloud hash tree, and based on the file hash value of the cloud hash tree, if the file hash value does not have the same hash value locally, the file name corresponding to the file hash value of the cloud hash tree is recorded and summarized to form a deleted file list.
[0118] For example, suppose there are files x and y in the local directory; and files x' and y' in the cloud directory.
[0119] When comparing, the local file x is used as the benchmark, and the hash value of the local file x' is compared with the hash value of the cloud file x' and the hash value of the cloud file y'. If the hash value of the cloud file x' equals the hash value of the cloud file x, the local file x' is added to the basic file list. If the comparison results are different, it means that the cloud file x is newly added, and the local file x is added to the newly added file list. Similarly, the local file y is compared.
[0120] Taking the cloud as the benchmark, the hash value of the cloud's x' file is compared with the hash value of the local x' file and the hash value of the local y' file respectively. If the comparison results are different, it means that the cloud's x' file needs to be deleted, and the cloud's x' file name is added to the deleted file list. Similarly, the cloud's y' file is compared again.
[0121] Therefore, for two hash trees, they are compared from the root node to the lower layer. If the hash values of the upper layer are the same, the two hash trees are exactly the same. At this time, the file names of the program files to be released corresponding to the file hash values of all files in the hierarchical directory are recorded as the basic file list for downloading preset files in the cloud.
[0122] If the hash values of the upper layer are different, the hash values of all child nodes are judged separately. If the hash values of any child nodes are different, different child nodes are recursively entered to determine whether there are new files or deleted files. If the local hash value cannot find a matching hash value in the cloud, the file corresponding to the local hash value is judged to be a new file. If the cloud hash value cannot find a matching hash value locally, the file corresponding to the cloud hash value is judged to be a deleted file.
[0123] When the directory hierarchy of the local hash tree and the cloud hash tree is greater than three levels, the local hash tree and the cloud hash tree are compared one by one from the hash value corresponding to the top level of the directory hierarchy to the hash value corresponding to the lower level. The specific comparison method between the local hash tree and the cloud hash tree can be deduced from the above method, which will not be repeated here.
[0124] The hash tree comparison of this application adopts hierarchical comparison hash, and compares the hash values corresponding to the top level of the directory hierarchy with the hash values corresponding to the lower levels one by one, which solves the problem of needing to calculate a large number of hashes when the number of files is too large, and improves the comparison performance.
[0125] Furthermore, the step of comparing the local hash tree with the cloud hash tree generated from the bottom layer to the upper layer containing all program files in the basic image can also be: S221: If the hash value of the directory name is different, and there is a file under the directory, and the file under the directory at this level has not been compared, then record the file name of the file that has not been compared.
[0126] Since the hash value is a string, if each string is the same, the hash value is the same. Otherwise, the hash value is different, that is, the local hash tree and the cloud hash tree do not have the same directory. When the file under the directory at this level has not been compared, the file name of the file that has not been compared is recorded.
[0127] S2222: If the hash values of the directory names are the same, determine whether there is a subdirectory in the next level. If there is a subdirectory in the next level, compare the hash values of the subdirectories in the next level of the directory hierarchy in turn.
[0128] S2223: When the hash values of the subdirectories are different, determine whether there are files in the subdirectory. If there are files, recursively compare the file hash values of all files in the directory at this level, and continue to determine whether there are new files or deleted files, so as to record the file names of the program files to be released corresponding to the different file hash values.
[0129] That is, if the hash values of the directory names are the same, that is, the local hash tree and the cloud hash tree have the same directory, then the hash values of the next level of the directory hierarchy are compared in turn. If the hash values are different, then at least one file in the top level is different from all the program files in the base image on the cloud. Therefore, the file names of the program files to be released corresponding to the different hash values are recorded to find the different files in the corresponding subdirectories.
[0130] Through the hierarchical hash tree, the hash values corresponding to the top level of the directory hierarchy are compared one by one with the hash values corresponding to the lower levels. When the hash values of the upper levels are found to be different, the different files can be quickly located. This solves the problem of repeatedly calculating a large number of hash values when the number of files is too large, which is time-consuming, and improves the comparison performance.
[0131] Furthermore, S3: the step of generating a file comparison table according to the comparison result includes:
[0132] Summarize the recorded file names of the files that have not been compared to form a deleted file list;
[0133] The file names of the program files to be released corresponding to the different recorded hash values are summarized to form a new file list.
[0134] The file comparison table includes basic information, a list of newly added files, or a list of deleted files.
[0135] Basic information is used to record the program files and dates of the comparison.
[0136] The newly added file list is used to record the file names of the program files to be released relative to the program files uploaded to the cloud.
[0137] The deleted file list is used to record the file names of the program files to be released that are identical to the program files uploaded to the cloud.
[0138] Among them, the newly added file list is a collection of file names of files added relative to the program files already uploaded to the cloud. When comparing the hash values of the upper directory of the hash tree, if they are the same, it means that the directory exists. Further comparison is made to see whether the hash values of the files under the directory are the same. If they are different, the file name is recorded.
[0139] The deleted file list is a collection of file names that have been deleted relative to the program files that have been uploaded to the cloud. When comparing the hash values of the upper directories in the hash tree, if they are different, it means that the directory does not exist and the files under the directory have not been compared and outdated, and the file name is recorded.
[0140] For example, the file comparison table can be a YAML file containing the following content:
[0141] base:2022-01-01.zip
[0142] delete:
[0143] -a / b.so
[0144] -c / d.so
[0145] add:
[0146] -e / f.so.
[0147] Further, refer to Figure 3 When the program files to be released are newly added compared to all the program files in the basic image on the cloud, the steps of packaging and uploading the files in the program files to be released that correspond to the file comparison table include:
[0148] S41: Based on the new file list, obtain the new program files corresponding to the new file list in the program files to be released;
[0149] S42: Make the newly added program file overwrite the program file in the base image in the program file to be released;
[0150] S43: Upload some files in the packaged program file to be released that correspond to the file comparison table.
[0151] That is, when the local server uploads the differential program package, it uses all the program files recorded in the new file list of the file comparison table to overwrite the program files in the basic image. Therefore, when uploading program files, only incremental files are uploaded, which improves the upload performance of program files.
[0152] Reference Figure 4In this embodiment, the program file to be released is developed on the development end of the local server and compiled to generate a hierarchical local hash tree, which is then compared one by one with the hierarchical cloud hash tree in the cloud, starting from the hash value corresponding to the top layer of the directory hierarchy to the hash value corresponding to the lower layer. A file comparison table is then generated based on the comparison results. Based on the file comparison table, data is uploaded with a data size smaller than that of the program file to be released, thereby completing the interaction with the cloud server.
[0153] Specifically, when the program file to be released has new additions compared to all the program files in the basic image on the cloud, the part of the files in the program file to be released that corresponds to the file comparison table is packaged and uploaded, and the file comparison table is uploaded at the same time; when the program file to be released has no new additions compared to all the program files in the basic image on the cloud, only the file comparison table is uploaded.
[0154] The cloud server receives the corresponding files or file comparison table in the program files to be released.
[0155] After receiving the files and the file comparison table, based on the file comparison table, the preset files are downloaded and filtered and deleted, and at the same time, the downloaded files that have been deleted are assembled with the received files to generate a complete program;
[0156] After receiving the file and the file comparison table, the preset file is downloaded based on the file comparison table, and the downloaded file is assembled with the received file to generate a complete program;
[0157] After receiving the file comparison table, the cloud server downloads the preset files based on the file comparison table and performs screening and deletion, so that the downloaded files that have been deleted are generated into a complete program;
[0158] After receiving the file comparison table, the cloud server downloads the preset files based on the file comparison table and generates a complete program.
[0159] Among them, the preset file is a common basic file package for all program files. Through the preset instructions, you can execute the instructions before generating the complete program and download the preset file to obtain it.
[0160] Based on the complete program, a program image is generated and loaded into a cloud container for independent operation. At the same time, a separate build service is used on the cloud server.
[0161] The cloud container runs and downloads the program image, then starts the program to complete the release of the program file to be released.
[0162] Further, refer to Figure 2 , further comprising the following steps:
[0163] S222: If the hash values of the upper layer are the same, use at least one different hash algorithm to calculate the hash values of the local hash tree and the cloud hash tree respectively;
[0164] S2221: Based on the newly calculated hash value, the local hash tree and the cloud hash tree are compared one by one from the hash value corresponding to the top level of the directory hierarchy to the hash value corresponding to the lower level;
[0165] S2222: If the newly calculated hash values are the same, it is assumed that the local hash tree is the same as the cloud hash tree generated from the bottom layer to the top layer, including all program files in the base image.
[0166] S2223: When the newly calculated hash values are different, recursively enter and compare the newly calculated hash values of all files in the directory at this level, and continue to determine whether there are new files or deleted files, so as to record the file names of the program files to be released corresponding to the different hash values.
[0167] Specifically, in order to solve the problem of inaccurate comparison results caused by hash conflicts in the comparison process of hierarchical hash trees, when the local hash tree and the cloud hash tree are compared one by one based on the MD5 algorithm according to the hash values corresponding to the top layer of the directory hierarchy to the hash values corresponding to the lower layers, and the comparison result is that the hash values are the same, at least one different hash algorithm is used to calculate the hash values of the local hash tree and the cloud hash tree respectively, and the local hash tree and the cloud hash tree are compared one by one according to the hash values corresponding to the top layer of the directory hierarchy to the hash values corresponding to the lower layers.
[0168] In this embodiment, the different hash algorithms may be SHA-1 algorithms. For example, the MD5 algorithm is first used to calculate and compare the two hash trees. If the top hash values are different, the two directories are considered to contain different files. If the top hash values are the same, the SHA-1 algorithm is then used to calculate and compare the two hash trees. Only when the top hash values are the same are the two program files considered to be the same; otherwise, the two program files are considered to contain different files, thereby resolving the hash conflict issue.
[0169] Therefore, a method for rapidly publishing program files is based on the directory hierarchy of the program files to be published, traversing in depth and sequentially generating a local hash tree from bottom to top. The local hash tree is then compared with a cloud hash tree generated from bottom to top on the cloud, containing all program files in a base image, to obtain a comparison result. A file comparison table is generated based on the comparison result. The portion of the program files to be published that corresponds to the file comparison table is packaged and uploaded, and the file comparison table is uploaded simultaneously. Consequently, only incremental files are uploaded when uploading program files, improving program upload performance and publishing efficiency when the program files themselves are relatively large and need to be published repeatedly. The cloud server can then download only incremental files, improving program download performance. By using the complete program and the local cache of the image in the image, the startup speed of the cloud container during repeated runtime is improved. This method solves the problem of locally developed programs being too large to consume a large amount of bandwidth, resulting in long upload times and long startup times when running in the cloud. Furthermore, a separate build service is used on the cloud server to avoid downloading and building the program separately for each container, saving resources.
[0170] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.
[0171] Reference Figure 5 The embodiment of the present application further provides a device for quickly publishing a program file, which corresponds one-to-one to the method for quickly publishing a program file in the above embodiment. The device for quickly publishing a program file includes:
[0172] The hierarchical hash tree module is used to traverse the directory hierarchy of the program files to be released in the depth direction and generate local hash trees from the bottom layer to the upper layer in sequence; calculate the hash value of each file in the bottom layer to generate the hash tree of the bottom layer; calculate the hash value of the subdirectory contained in the upper layer directory to generate the hash tree of the upper layer;
[0173] A comparison module is used to compare the local hash tree with the cloud hash tree generated from the bottom layer to the top layer, which contains all program files in the base image; the local hash tree and the cloud hash tree are compared one by one according to the hash value corresponding to the top layer of the directory hierarchy and the hash value corresponding to the bottom layer in turn to obtain a comparison result;
[0174] A difference module is used to generate a file comparison table based on the comparison results; the file comparison table includes a new file list for recording the file names of the added files of the program file to be released relative to the program file uploaded on the cloud, and a deleted file list for recording the file names of the same files between the program file to be released and the program file uploaded on the cloud;
[0175] The packaging module is used to upload data with a data size smaller than the program file to be released based on the file comparison table, and complete the interaction with the cloud server.
[0176] Furthermore, a device for quickly publishing a program file also includes:
[0177] The anti-collision module is used to use at least one different hash algorithm to calculate the hash values of the local hash tree and the cloud hash tree respectively before recording the file names of the to-be-released program files corresponding to the same hash values; based on the newly calculated hash values, the local hash tree and the cloud hash tree are compared one by one according to the hash values corresponding to the top layer of the directory hierarchy to the hash values corresponding to the lower layers; if the newly calculated hash values are the same, it is assumed that the local hash tree is the same as the cloud hash tree generated from the bottom layer to the top layer of the cloud containing all program files in the basic image; if the newly calculated hash values are different, the newly calculated hash values corresponding to the next layer of the directory hierarchy are compared in turn; when the newly calculated hash values are different, the newly calculated hash values of all files in the directory of the hierarchy are recursively compared, and whether there are new files or deleted files is continued to be determined, so as to record the file names of the to-be-released program files corresponding to different hash values.
[0178] The specific definition of a program file rapid publishing device can be found in the definition of a program file rapid publishing method described above and will not be repeated here. The various modules in the aforementioned program file rapid publishing device can be implemented in whole or in part through software, hardware, or a combination thereof. The aforementioned modules can be embedded in or independent of a processor in a computer device in hardware form, or can be stored in a memory in a computer device in software form, so that the processor can call and execute the corresponding operations of the aforementioned modules.
[0179] In one embodiment, a computer device is provided, which may be a server. The computer device includes a processor, memory, a network interface, and a database connected via a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of the operating system and computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external terminal via a network connection. When executed by the processor, the computer program implements a method for rapidly publishing program files.
[0180] In one embodiment, a computer-readable storage medium is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the following steps are implemented:
[0181] S1: Based on the directory hierarchy of the program file to be released, traverse in the depth direction and generate a local hash tree from the bottom to the top;
[0182] S2: Compare the local hash tree with the cloud hash tree generated from the bottom layer to the top layer, including all program files in the base image, to obtain a comparison result;
[0183] S3: Generate a file comparison table based on the comparison results;
[0184] S4: Based on the file comparison table, upload data with a data size smaller than the program file to be released to complete the interaction with the cloud server.
[0185] In one embodiment, a computer program product is provided. The computer program product includes a computer program. When the computer program is executed by a processor, a method for quickly publishing a program file is implemented.
[0186] Those skilled in the art will appreciate that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0187] Those skilled in the art will clearly understand that for the sake of convenience and brevity in description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the system can be divided into different functional units or modules to complete all or part of the functions described above.
Claims
1. A method for quickly publishing a program file, characterized in that: The following steps are involved: Based on the directory hierarchy of the program files to be released, traverse in the depth direction and generate a local hash tree from the bottom to the top; Compare the local hash tree with a cloud hash tree generated from the bottom layer to the top layer in the cloud, including all program files in the base image, to obtain a comparison result; The steps of comparing the local hash tree with the cloud hash tree generated from the bottom layer to the upper layer, including all program files in the base image, include: Compare the local hash tree with the cloud hash tree one by one, starting from the hash value corresponding to the top level of the directory hierarchy to the hash values corresponding to the lower levels; If the hash values of the top layer are different, determine whether there are subdirectories in the next layer. If there are subdirectories in the next layer, compare the hash values of the subdirectories in the next layer of the directory hierarchy in turn. If the hash values of the subdirectories are different, determine whether there are files in the subdirectory. If there are files, recursively enter and compare the file hash values of all files in the directory at that level. When the file hash value of the local hash tree is different from the file hash value of the cloud hash tree, and based on the file hash value of the local hash tree, if the file hash value does not have the same hash value in the cloud, then record the file name of the program file to be released corresponding to the file hash value of the local hash tree, and summarize them to form a new file list; When the file hash value of the local hash tree is different from the file hash value of the cloud hash tree, and based on the file hash value of the cloud hash tree, if the file hash value does not have the same hash value locally, then record the file name corresponding to the file hash value of the cloud hash tree and summarize them to form a deleted file list; If the hash values of the top layers are the same, at least one different hash algorithm is used to calculate the hash values of the local hash tree and the cloud hash tree respectively; Based on the newly calculated hash value, the local hash tree and the cloud hash tree are compared one by one from the hash value corresponding to the top level of the directory hierarchy to the hash value corresponding to the bottom level; If the newly calculated hash values are the same, it is assumed that the local hash tree is the same as the cloud hash tree generated from the bottom layer to the top layer, including all program files in the base image. generating a file comparison table according to the comparison result; Based on the file comparison table, data is uploaded with a data size smaller than that of the program file to be released, thereby completing the interaction with the cloud server.
2. A method for quickly publishing a program file according to claim 1, characterized in that: The steps of uploading data with a data size smaller than that of the program file to be released based on the file comparison table and completing the interaction with the cloud server include: When the program files to be released are newly added compared to all the program files in the basic image on the cloud, the partial files in the program files to be released corresponding to the file comparison table are packaged and uploaded, and the file comparison table is uploaded at the same time.
3. A method for quickly publishing a program file according to claim 2, characterized in that: The following steps are also included: After receiving the file and the file comparison table, the cloud server downloads the preset files based on the file comparison table and filters and deletes them, and at the same time, assembles the downloaded files that have been deleted with the received files to generate a complete program; A program image is generated based on the complete program, and the program image is loaded into a cloud container.
4. A method for quickly publishing a program file according to claim 2, characterized in that: The following steps are also included: After receiving the file and the file comparison table, the cloud server downloads a preset file based on the file comparison table, and simultaneously assembles the downloaded file with the received file to generate a complete program; A program image is generated based on the complete program, and the program image is loaded into a cloud container.
5. A method for quickly publishing a program file according to claim 1, characterized in that: The steps of uploading data with a data size smaller than that of the program file to be released based on the file comparison table and completing the interaction with the cloud server include: When the program files to be released are not newly added compared to all the program files in the basic image on the cloud, only the file comparison table is uploaded.
6. A method for quickly publishing a program file according to claim 5, characterized in that: The following steps are also included: After receiving the file comparison table, the cloud server downloads the preset files based on the file comparison table and performs screening and deletion, so that the downloaded files that have been deleted are generated into a complete program; A program image is generated based on the complete program, and the program image is loaded into a cloud container.
7. A method for quickly publishing a program file according to claim 5, characterized in that: The following steps are also included: After receiving the file comparison table, the cloud server downloads the preset files based on the file comparison table and generates a complete program; A program image is generated based on the complete program, and the program image is loaded into a cloud container.
8. A method for quickly publishing a program file according to any one of claims 6-7, characterized in that: The following steps are also included: The cloud container runs and downloads the program image, then starts the program to complete the release of the program file to be released.
9. A method for quickly publishing a program file according to claim 1, characterized in that: The steps of traversing the directory hierarchy of the program file to be released in the depth direction and sequentially generating a local hash tree from the bottom layer to the upper layer include: Calculate the hash value of each underlying file and generate the underlying hash value; Calculate the hash values of the subdirectories or all files contained in the upper-level directory to generate the hash value of the upper-level directory; Summarize the hash values of the bottom layer and the hash values of the upper layer to generate a local hash tree from the bottom layer to the upper layer.
10. A method for quickly publishing a program file according to claim 1, 2, 3 or 9, characterized in that: The steps of comparing the local hash tree with the cloud hash tree generated from the bottom layer to the upper layer, including all program files in the base image, include: Compare the local hash tree with the cloud hash tree one by one, starting from the hash value corresponding to the top level of the directory hierarchy to the hash values corresponding to the lower levels; If the hash values of the directory names are different, and there are files in the directory, and the files in the directory at that level have not been compared, then the file name of the file that has not been compared is recorded; If the hash values of the directory names are the same, determine whether there are subdirectories in the next level. If there are subdirectories in the next level, compare the hash values of the subdirectories corresponding to the next level of the directory hierarchy in turn. If the hash values of the subdirectories are different, determine whether there are files in the subdirectory. If there are files, recursively enter and compare the file hash values of all files in the directory at this level, and continue to determine whether there are new files or deleted files, so as to record the file names of the program files to be released corresponding to different file hash values.
11. A method for quickly publishing a program file according to claim 1, characterized in that: The following steps are also included: Based on the newly added file list, obtaining the newly added program files corresponding to the newly added file list in the program files to be released; The newly added program files are made to overwrite the program files in the base image in the program files to be released.
12. A device for quickly publishing program files, characterized in that: include: The hierarchical hash tree module is used to traverse the directory hierarchy of the program files to be released in the depth direction and generate a local hash tree from the bottom to the top; A comparison module is used to compare the local hash tree with a cloud hash tree generated from the bottom layer to the upper layer containing all program files in the base image in the cloud to obtain a comparison result; The steps of comparing the local hash tree with the cloud hash tree generated from the bottom layer to the upper layer, including all program files in the base image, include: Compare the local hash tree with the cloud hash tree one by one, starting from the hash value corresponding to the top level of the directory hierarchy to the hash values corresponding to the lower levels; If the hash values of the top layer are different, determine whether there are subdirectories in the next layer. If there are subdirectories in the next layer, compare the hash values of the subdirectories in the next layer of the directory hierarchy in turn. If the hash values of the subdirectories are different, determine whether there are files in the subdirectory. If there are files, recursively enter and compare the file hash values of all files in the directory at that level. When the file hash value of the local hash tree is different from the file hash value of the cloud hash tree, and based on the file hash value of the local hash tree, if the file hash value does not have the same hash value in the cloud, then record the file name of the program file to be released corresponding to the file hash value of the local hash tree, and summarize them to form a new file list; When the file hash value of the local hash tree is different from the file hash value of the cloud hash tree, and based on the file hash value of the cloud hash tree, if the file hash value does not have the same hash value locally, then record the file name corresponding to the file hash value of the cloud hash tree and summarize them to form a deleted file list; If the hash values of the top layers are the same, at least one different hash algorithm is used to calculate the hash values of the local hash tree and the cloud hash tree respectively; Based on the newly calculated hash value, the local hash tree and the cloud hash tree are compared one by one from the hash value corresponding to the top level of the directory hierarchy to the hash value corresponding to the bottom level; If the newly calculated hash values are the same, it is assumed that the local hash tree is the same as the cloud hash tree generated from the bottom layer to the top layer, including all program files in the base image. A difference module, configured to generate a file comparison table based on the comparison result; The packaging module is used to upload data with a data size smaller than that of the program file to be released based on the file comparison table, and complete the interaction with the cloud server.
13. A computer device, characterized in that: The method comprises a memory, a processor and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps of the method according to any one of claims 1 to 11.
14. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 11 are implemented.
15. A computer program product, characterized in that The invention comprises a computer program, which implements the steps of the method according to any one of claims 1 to 11 when the computer program is executed by a processor.
16. A method for quickly publishing a program file, characterized in that: The following steps are involved: Get files or file comparison tables from local; After receiving the file and the file comparison table, based on the file comparison table, downloading the preset files and filtering and deleting them, and at the same time, assembling the downloaded files that have been deleted with the received files to generate a complete program; After receiving the file and the file comparison table, downloading a preset file based on the file comparison table, and assembling the downloaded file with the received file to generate a complete program; After receiving the file comparison table, based on the file comparison table, the preset files are downloaded and filtered and deleted, so that the downloaded files that have been deleted are generated into a complete program; After receiving the file comparison table, downloading the preset files based on the file comparison table to generate a complete program; Then, a program image is generated based on the complete program, and the program image is loaded into a cloud container.
Citation Information
Patent Citations
RPKI file synchronizing method and device
CN105141681A
Cloud security product management method and device, equipment and storage medium
CN113297158A