Small program increment updating and distributing system and small program increment distributing and updating method

By using a rolling hash algorithm and a distributed update module, small incremental packets are generated and the optimal transmission path is selected, which solves the problems of large incremental packet size and high download traffic in mini-program updates, and achieves efficient and low-cost version updates.

CN121635943APending Publication Date: 2026-03-10ZHUHAI FANTAI GEEK TECH CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-02-04
Publication Date
2026-03-10

AI Technical Summary

Technical Problem

Existing methods for updating mini-program versions cannot effectively handle changes within files, resulting in larger incremental packages, increased download traffic, and a poor user experience.

Method used

A rolling hash algorithm is used to perform a difference scan on the file content, generating an incremental packet with a very small size. The optimal update node is selected for transmission through a distributed update module, and the optimal update path is calculated by combining graph theory algorithm to achieve accurate incremental update.

Benefits of technology

It significantly reduces the download traffic required for updates, improves update speed and user experience, reduces development costs, and enhances the flexibility and scalability of mini-programs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121635943A_ABST
    Figure CN121635943A_ABST
Patent Text Reader

Abstract

The invention discloses an applet increment updating distribution system and an applet increment distributing and updating method.The system comprises a client side, a server side and a storage system, the server side comprises a version management module, an increment package generation module and a distributed updating module, and the version management module is used for constructing a version dependency graph based on a version metadatabase; calculating an upgrade chain from the current version to the target version, and calculating an optimal update path by using a graph theory algorithm; the incremental package generation module is used for identifying difference data blocks between the target version and the basic version based on a rolling hash algorithm, and packaging the difference data blocks to generate an incremental update package; and the distributed updating module is used for receiving a version updating request of the client, selecting an optimal updating node based on the geographic position and bandwidth of the client, and transmitting an incremental updating packet of the version to the client from the optimal updating node according to an updating path. According to the method and the device, the minimum consumption of flow during version updating is realized, and the updating speed is remarkably improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of program development, and more specifically, to a mini-program incremental update distribution system and a mini-program incremental distribution and update method. Background Technology

[0002] The version update mechanism of mini-programs is a crucial part of ensuring continuous application optimization, bug fixing, and the launch of new features. An efficient version update strategy not only improves user experience but also ensures compatibility between different versions of the mini-program, avoiding problems caused by untimely updates.

[0003] As mini-programs continue to iterate, their code size increases. Existing incremental update methods typically use file-level difference matching, which cannot effectively handle changes within the file (such as code tweaks or comment modifications), resulting in a large incremental package size and increased download traffic.

[0004] Therefore, a new update strategy is needed to reduce the download burden on users, improve update efficiency, and optimize user experience. Summary of the Invention

[0005] The main purpose of this application is to provide a mini-program incremental update distribution system, a mini-program incremental distribution and update method, which uses a rolling hash algorithm to perform differential scanning on file content, accurately matches the difference blocks between versions to generate an incremental package with a very small size, greatly reduces the download traffic required for the update, and significantly improves the update speed.

[0006] The first aspect of this application provides a mini-program incremental update distribution system, comprising: a client, a server, and a storage system. The server includes a version management module, an incremental package generation module, and a distributed update module. The version management module is used to construct a version dependency graph based on a version metadata database, calculate the upgrade chain from the current version to the target version, and calculate the optimal update path using graph theory algorithms. The incremental package generation module is used to identify the difference data blocks between the target version and the base version based on a rolling hash algorithm, and package the difference data blocks to generate an incremental update package. The distributed update module is used to receive version update requests from clients, select the optimal update node based on the client's geographical location and bandwidth, and transmit the incremental update package of the version from the optimal update node to the client according to the update path. The client sends version update requests to the server, selects the optimal update node based on bandwidth and geographical location, and obtains the incremental update package according to the incremental update path; it parses the header information of the incremental update package to obtain version metadata, uses the corresponding decompression algorithm to restore the incremental data, and obtains the difference location and changed content; it maps the base version file into memory, locates the location that needs to be modified block by block according to the difference information in the incremental update package, and performs data replacement operation; it performs digital signature verification, integrity hash verification, and malicious code scanning on the updated version, deletes the temporary directory and intermediate files after verification, writes the version information log and update log to the local database, and sends an update completion confirmation to the server; The storage system is used to divide different storage paths or namespaces according to version information, and to store incremental packages of different versions independently.

[0007] A second aspect of this application provides a method for incremental distribution of mini-programs, suitable for execution on the server side, comprising: identifying difference data blocks between the target version and the base version based on a rolling hash algorithm, packaging the difference data blocks to generate an incremental update package; constructing a version dependency graph based on a version metadata database, calculating the upgrade chain from the current version to the target version, and calculating the optimal update path using a graph theory algorithm; receiving a version update request from a client, selecting the optimal update node based on the client's geographical location and bandwidth, and transmitting the incremental update package of the version from the optimal update node to the client according to the update path.

[0008] Furthermore, based on the rolling hash algorithm, the difference data blocks between the target version and the base version are identified, and the difference data blocks are packaged into incremental update packages. This includes: initializing the rolling hash calculator, setting the base value to 256 and the modulus to 1000000007; performing a sliding window scan on the file content to calculate the hash value of the current data block; comparing the hash value of the current data block with the corresponding position in the base version, and recording the position information and specific content of the difference block when a hash value mismatch is found; compressing the difference block using the Zstandard compression algorithm, adjusting the compression parameters according to the data characteristics to obtain binary incremental packages, and generating a unique digital signature for each binary incremental package.

[0009] Furthermore, a version dependency graph is constructed based on the version metadata database, and the upgrade chain from the current version to the target version is calculated. The optimal update path is calculated using graph theory algorithms, including: registering the mini-program version and storing the metadata of the mini-program version in the version metadata database. The metadata includes the version unique identifier, base version number, target version number, update time, change log, and version-related dependent modules; constructing a version dependency graph based on the version metadata database, where nodes represent different versions and edges represent dependencies between versions; and using Dijkstra's algorithm to calculate the optimal path from the current version to the target version based on the version dependency graph.

[0010] Furthermore, the optimal path from the current version to the target version is calculated using Dijkstra's algorithm based on the version dependency graph. This involves: creating a graph structure where nodes are version IDs and edge weights are bandwidth consumption and update risk; adding nodes and edges one by one based on version information from the base version to the target version in the version metadata database; initializing the distance of the starting node to 0 and other nodes to infinity, and using a priority queue to store unprocessed nodes; iteratively processing each node, updating the distances of its neighboring nodes, and recording its predecessor node; stopping the algorithm when the target version is reached; and backtracking from the target version to the current version to construct a complete optimal upgrade chain.

[0011] Thirdly, a method for incremental updates of mini-programs is provided, suitable for execution on the client side, including: sending a version update request to the server, selecting the optimal update node based on bandwidth and geographical location, and obtaining the incremental update package according to the incremental update path; parsing the header information of the incremental update package, obtaining version metadata, using the corresponding decompression algorithm to restore the incremental data, and obtaining the difference location and changed content; mapping the base version file into memory, locating the location to be modified block by block according to the difference information in the incremental update package, and performing data replacement operation; performing digital signature verification, integrity hash verification, and malicious code scanning on the updated version, deleting the temporary directory and intermediate files after verification, writing the version information log and update log to the local database, and sending an update completion confirmation to the server.

[0012] Furthermore, before sending a version update request to the server, the process also includes: checking available storage space, memory usage, CPU load status, and network connection stability; checking whether the current version is complete, whether the version number matches, and whether the relevant dependent components are functioning correctly; and performing a complete backup of the current version file after the checks are passed.

[0013] Furthermore, the incremental update method for mini-programs also includes: identifying abnormal situations such as network connection interruption, insufficient storage space, file access failure, and data verification errors, and recording the context information of the abnormality; when a network interruption is detected, automatically saving the downloaded data block information and resuming download from the breakpoint after the network is restored, using a backoff algorithm to perform the re-download operation; monitoring resource usage during the update process in real time, setting a limit threshold for CPU usage, and dynamically adjusting process priority or pausing some operations based on the limit threshold; directly mapping files to memory, loading data blocks in pages, using distributed locks to coordinate the execution order of multiple update tasks, and employing read-write lock mechanisms and deadlock detection mechanisms for access to shared resources.

[0014] A fourth aspect of this disclosure provides an electronic device comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores a computer program executable by the at least one processor, the computer program being executed by the at least one processor to cause the at least one processor to perform the steps of the incremental distribution method for mini-programs described in the second aspect and the incremental update method for mini-programs described in the third aspect.

[0015] Fifthly, this application provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the steps of the incremental distribution method for mini-programs described in the second aspect and the incremental update method for mini-programs described in the third aspect.

[0016] As can be seen from the above solutions, the incremental update distribution system and method for mini-programs provided in this application, through binary incremental update technology, solve the problems of traffic waste, low update efficiency, and poor user experience in traditional mini-program updates. Through precise incremental package generation, high-compression incremental package distribution, parallel downloading, and intelligent caching mechanisms, this solution achieves minimized traffic consumption and a significant improvement in update speed. This not only helps reduce development costs but also enhances the flexibility and scalability of mini-programs, bringing a better user experience to developers and users. Attached Figure Description

[0017] The accompanying drawings, which form part of this application, are used to provide a further understanding of the application and to make other features, objects, and advantages of the application more apparent. The illustrative embodiments and descriptions of this application are used to explain the application and do not constitute an undue limitation of the application. In the drawings: Figure 1 This application provides a schematic diagram of the structure of the mini-program incremental update distribution system. Figure 2 A diagram illustrating the incremental update distribution process for mini-programs; Figure 3 A schematic flowchart of the incremental distribution method for mini-programs provided in this application. Figure 4 A flowchart illustrating the incremental update method for the mini-program provided in this application; Figure 5 This is a schematic block diagram of an electronic device according to embodiments of the present disclosure. Detailed Implementation

[0018] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.

[0019] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate for the embodiments of this application described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0020] To address the problems of wasted network resources, high storage consumption, and poor user experience in existing update methods, this application combines a binary differential algorithm with an intelligent incremental package management mechanism to achieve efficient and low-cost updates for mini-programs.

[0021] Figure 1 This is a structural diagram of the mini-program incremental update distribution system provided in this application. Figure 1 As shown, the WeChat Mini Program incremental update distribution system includes a client, a server, and a storage system. The server includes a version management module, an incremental package generation module, and a distributed update module. The version management module constructs a version dependency graph based on a version metadata database, calculates the upgrade chain from the current version to the target version, and uses graph theory algorithms to calculate the optimal update path. The incremental package generation module identifies the difference data blocks between the target version and the base version based on a rolling hash algorithm, packages these difference data blocks into incremental update packages, and receives version update requests from clients. Based on the client's geographical location and bandwidth, it selects the optimal update node and transmits the incremental update package from the optimal update node to the client according to the update path. The storage system is used to divide storage paths or namespaces according to version information, storing incremental packages of different versions independently. In case of merge failures, update errors, or other issues, the storage structure supports a complete backtracking path, assisting in troubleshooting and recovery operations.

[0022] The client sends version update requests to the server, selects the optimal update node based on bandwidth and geographical location, and obtains the incremental update package according to the incremental update path. It parses the header information of the incremental update package to obtain version metadata, uses the corresponding decompression algorithm to restore the incremental data, and obtains the differences and changes. It maps the base version file into memory, locates the necessary modifications block by block based on the difference information in the incremental update package, and performs data replacement operations. The updated version undergoes digital signature verification, integrity hash verification, and malicious code scanning. Upon successful verification, it deletes the temporary directory and intermediate files, writes the version information log and update log to the local database, and sends an update completion confirmation to the server.

[0023] Specifically, the version management module maintains software version metadata, including the version's unique identifier, base version number, target version number, update time, change log, and related dependency module information. Registering a mini-program version stores its metadata in a version metadata database. The base version number (baseVersion) indicates the base version that this version depends on, facilitating version evolution tracking. The target version number (targetVersion) indicates the target version that the current version has been updated to. The update time (updateTimestamp) records the timestamp of the version release, aiding in version time management and auditing. Change logs describe the specific content of this update, allowing developers to understand changes between versions. Dependent modules (dependentModules) list other modules or libraries that the current version depends on, ensuring compatibility between versions. A version dependency graph is constructed based on the version metadata database. Nodes in the version dependency graph represent different versions, and edges represent dependencies between versions. When a version update is needed, Dijkstra's algorithm is applied to calculate the optimal upgrade path from the current version to the target version in the multi-version dependency graph. This ensures minimal bandwidth required for the update, reduces potential update risks, and minimizes the possibility of failure by prioritizing verified version paths. The Dijkstra algorithm includes: creating a graph structure where nodes are version IDs and edge weights are bandwidth consumption and update risk; adding nodes and edges one by one based on version information from the base version to the target version in the version metadata database; initializing the distance of the starting node to 0 and the distance of other nodes to infinity, and using a priority queue to store unprocessed nodes; iteratively processing each node, updating the distance of its neighboring nodes, and recording its predecessor node; stopping the algorithm when the target version is reached; and backtracking from the target version to the current version to construct a complete optimal upgrade chain.

[0024] The corresponding code implementation is as follows: cpp struct VersionMetadata { string versionId; string baseVersion; string targetVersion; vector <string>changeLogs; time_t updateTimestamp; vector <string>dependentModules; }; class VersionManager { private: unordered_map<string, VersionMetadata>versionRegistry; public: void registerVersion(const VersionMetadata&metadata) { versionRegistry[metadata.versionId] = metadata; } vector <string>calculateUpgradeChain( const string¤tVersion, const string&targetVersion ) { / / Implement version chain calculation logic vector <string>upgradeChain; / / Complex graph theory algorithms for calculating the shortest path return upgradeChain; } }; The incremental update generation module is primarily responsible for calculating the differences between the target version and the base version, and generating a minimal incremental update package based on these differences. For example, it uses a rolling hash algorithm to perform a sliding window scan and hash calculation on the file content, comparing it with the base version to locate the changed parts, thus generating the incremental update package. First, by locating the files that need updating, it identifies the changed parts within the entire file. For the identified changed files, it performs binary block-level difference matching on the internal data to ensure that only the minimally modified parts of the file are transmitted. All update content and its modification traces are stored as a version map. This version map not only points to the updated files but also records the specific modified parts and update paths. A linked list or graph structure is used to record the update paths between versions, ensuring that every step from the old version to the new version can be accurately traced back and applied.

[0025] The rolling hash algorithm maintains a sliding window and calculates the hash value of the data within that window sequentially. By appropriately designing the hash function and update strategy, it can efficiently track changes in data blocks without recalculating the hash of the entire window each time. Specifically, the rolling hash calculator is initialized with a base value of 256 to encode characters and avoid hash collisions. The modulus (MOD) uses a large prime number, 1000000007, to ensure the uniformity of hash calculations and reduce the risk of overflow. A sliding window scan is performed on the file content to calculate the hash value of the current data block. The window size is typically 4KB or 8KB, adjusted according to the file size and change characteristics. The hash value of the current data block is compared with the corresponding position in the base version. When a hash value mismatch is found, the location information and specific content of the difference block are recorded. The rolling hash difference identification algorithm is detailed below: cpp class RollingHash { private: const int BASE = 256; const int MOD = 1000000007; long long hash = 0; long long pow = 1; public: void update(char newChar, char oldChar, int windowSize) { / / Calculate the new window hash value hash = (hash BASE + newChar - oldChar pow) % MOD; If (hash < 0), then hash += MOD; } long long getHash() { return hash; } }; class DiffAlgorithm { public: vector <chunk>generateIncrementalDiff( const vector<uint8_t>&baseVersion, const vector<uint8_t>&targetVersion ) { vector <chunk>diffChunks RollingHash; / / Calculate the difference blocks using a sliding window for (int windowStart = 0; windowStart <targetVersion.size();windowStart++) { long long chunkHash = rollingHash.getHash(); if (isSignificantChange(chunkHash)) { Chunk chunk = extractDiffChunk(targetVersion, windowStart); diffChunks.push_back(chunk); } } return diffChunks; } }; In the code above, the RollingHash class is responsible for updating and retrieving the window's hash value. The update method calculates the change in the window's hash value based on the rolling update. Specifically, it removes old characters from the window, adds new characters, and calculates the new hash value using a formula: hash =(hash BASE + newChar - oldChar pow) % MOD; Here, `pow` is the power of the current window, `BASE` is the character encoding radix, `MOD` is the modulus to prevent overflow, `newChar` is the new character, and `oldChar` is the old character. When updating the hash value, the window size remains constant, and the hash is updated each time a new character is added or an old character is removed. `getHash` retrieves the hash value of the current window and compares it with the base version to determine if differences exist. The main function of `generateIncrementalDiff` is to perform a sliding window scan of the file, calculate differences using a rolling hash, extract all difference blocks, collect all difference blocks, and generate an incremental update package. `isSignificantChange` is used to determine if the hash value has changed significantly, deciding whether the window contains differences. `extractDiffChunk` is used to extract and store difference blocks, recording the position and content of the difference blocks.

[0026] After acquiring all the differential data, the Zstandard compression algorithm is used to compress the differential data to reduce transmission bandwidth and time. Compression parameters are adjusted based on data characteristics to obtain binary incremental packets, and a unique digital signature is generated for each binary incremental packet. First, a compression context (ZSTD_CCtx) is created, and appropriate compression parameters, including compression level, window size, and compression strategy, are set according to the actual situation. These parameters are automatically adjusted based on data characteristics to achieve a balance between compression ratio and speed. During compression, the differential data is divided into 64KB blocks for processing, which improves compression efficiency and facilitates subsequent transmission and updates. The specific incremental packet compression strategy is as follows: cpp class DiffCompress { public: / / Using the Zstandard compression algorithm vector<uint8_t> compressDiffPackage(const vector <chunk>&diffChunks) { ZSTD_CCtx cctx = ZSTD_createCCtx(); ZSTD_compressionParameters params = ZSTD_makeCompressionParameters( ZSTD_CLEVEL_DEFAULT, ZSTD_WINDOWLOG_DEFAULT, ZSTD_STRATEGY_BTLAZY2 ); / / Compression parameter optimization ZSTD_CCtx_setParametersUsingCCtxParams(cctx, params); / / Perform compression vector<uint8_t> compressedData = ZSTD_compress(diffChunks.data(), diffChunks.size(),compressionLevel); return compressedData; } }; In the code above, the compression strategy (ZSTD_STRATEGY_BTLAZY2) indicates that a "delayed dictionary matching + binary tree" approach is used for compressed searching, suitable for scenarios with high data similarity, such as compressing dissimilar data. Compared to more aggressive strategies (such as BTULTRA2), BTLAZY2 combines speed and compression efficiency. It compresses all dissimilar data into a vector.<uint8_t> A byte array of type [type]. If the data volume is large, iterative compression using a 64KB block strategy can be combined to improve memory utilization efficiency.

[0027] A distributed update module receives version update requests from clients, selects the optimal update node based on the client's geographical location and bandwidth, and transmits the incremental update package from the optimal update node to the client according to the update path. In one embodiment of this disclosure, a list and sequence of update paths are maintained to track the version chain. The acquisition of update packages adopts a distributed update scheduling mechanism and performs intelligent scheduling based on factors such as bandwidth and geographical location. Specifically, as shown below: cpp class UpdateScheduler { public: struct UpdateNode { string nodeId; / / Unique identifier for the node string region; / / Geographical region where the node is located int bandwidth; / / Bandwidth available to the node vector <string>supportedVersions; / / A list of versions supported by this node, used to determine whether the target version can be obtained from this node. }; UpdatePackage selectOptimalUpdateNode( const vector <updatenode>&availableNodes, const string¤tVersion ) { / / Optimal node selection based on bandwidth and geographical location UpdateNode bestNode = selectNodeByMetrics(availableNodes); return fetchUpdatePackage(bestNode, currentVersion); } UpdatePackage fetchUpdatePackage( const UpdateNode&node, const string¤tVersion ) { / / Get the update package from the best node } }; The main function of the `UpdateScheduler` class is to select the optimal update node based on multiple conditions (such as bandwidth and geographical location). This approach dynamically selects the server node closest to the target device, accelerating the transmission process, avoiding bandwidth bottlenecks, and improving the overall system update efficiency. The `selectNodeByMetrics` function selects the optimal node based on multiple parameters, including bandwidth, geographical location, and the list of supported versions for each node. When selecting the optimal node, it prioritizes nodes with higher bandwidth and closer geographical proximity to the target user to reduce network latency, avoid bandwidth bottlenecks in cross-regional transmission, improve transmission speed, and ensure that the selected node supports incremental updates for the current version. If it does not support it, it returns alternative nodes. In large-scale distributed systems (such as IoT devices and cloud services), this solution effectively reduces the size of update packages, improves update efficiency, and can dynamically adjust update strategies based on actual network conditions. It can allocate independent storage space for incremental packages of different versions, ensuring independent storage of data for different versions and subsequent version tracking operations.

[0028] The client sends version update requests to the server, selects the optimal update node based on bandwidth and geographical location, and obtains the incremental update package according to the incremental update path. It parses the header information of the incremental update package to obtain version metadata, uses the corresponding decompression algorithm to restore the incremental data, and obtains the differences and changes. It maps the base version file into memory, locates the necessary modifications block by block based on the difference information in the incremental update package, and performs data replacement operations. The updated version undergoes digital signature verification, integrity hash verification, and malicious code scanning. Upon successful verification, it deletes the temporary directory and intermediate files, writes the version information log and update log to the local database, and sends an update completion confirmation to the server.

[0029] The working mechanism of digital signature verification (validateDigitalSignature) includes: 1. Signature generation (server-side): Calculate the SHA-256 hash value (fixed 32 bytes) for the entire incremental packet. Sign the hash value using the RSA private key to obtain a digital signature (e.g., 256 bytes). Append this signature to the end of the incremental packet or include it in the metadata. 2. Signature verification (client-side): The client extracts the signature and packet content. Decrypt the signature using the built-in RSA public key to obtain the hash value at the time of signing. The client recalculates the SHA-256 hash value of the current packet and compares the two to see if they match. The integrity hash verification process includes: After unpacking, the client recalculates the hash value of each part. The calculated result is compared with the recorded hash value. If any part is inconsistent, it indicates that the data has been corrupted or transmitted incorrectly. The system scans data for known malicious signatures (Virus Signatures) to check for malicious scripts, executable instructions, destructive commands, etc. (such as shell injection, PE files, etc.). It can integrate with third-party virus scanning engines (such as ClamAV, Yara) or provide a "sandbox mode" to verify whether the updated content behaves abnormally at runtime. The specific incremental package security verification is as follows: cpp class SecurityValidator { public: bool validateDiffPackage(const vector<uint8_t> &diffPackage) { / / Multiple security checks Bool signatureValid= validateDigitalSignature(diffPackage); bool integrityValid = validateIntegrity(diffPackage); bool malwareValid = scanForMalware(diffPackage); return signatureValid&&integrityValid&&malwareValid; } private: bool validateDigitalSignature(const vector<uint8_t> &package) { / / Digital signature verification } bool validateIntegrity(const vector<uint8_t> &package) { / / Integrity hash verification } bool scanForMalware(const vector<uint8_t> &package) { / / Simple virus scan } }; In the code above, the execution order is as follows: validateDigitalSignature(...) stops if the signature verification fails, validateIntegrity(...) verifies the integrity of the package content, and scanForMalware(...) checks for potential security risks. Only when all three return true is the entire package considered valid.

[0030] Before the update begins, the client performs an environment check, detecting available storage space, memory usage, CPU load, and network connection stability. This verifies that the storage space is sufficient to accommodate the update package and the data from the application incremental package. Checking CPU, memory load, and network connection stability ensures the system has sufficient resources for the update. The client also checks if the current version is complete, if the version number matches, and if all dependencies are functioning correctly, confirming that the current version matches the target version and ensuring that the target version's dependencies and update files are correct. After passing these checks, a full backup of the current version files is performed for rollback in case of update failure.

[0031] After the update is complete, the system performs a comprehensive verification: It calculates the updated file hash value and compares it with the target version hash value to ensure the file is not corrupted. Basic functional tests are performed on key components to ensure the updated software functions correctly. Temporary files and cached data generated during the update process are deleted to free up storage space. The system version history is updated, the update log is saved, and relevant services are notified that the update is complete.

[0032] Because various errors may occur during the update process, the system first identifies common errors such as network interruptions, insufficient storage space, file access failures, and data verification errors, and records the context information of the exceptions. Based on the error type, an appropriate recovery strategy is selected. For example, if a download is interrupted, the system will retry the download. If a data verification error occurs, the system will roll back to the previous version. If an application update error occurs, the system will restore the system to its state before the update. To handle incremental update failures, the complete state information of the current version is recorded before the update begins, serving as a recovery point. If an error occurs, a rollback is performed based on the recovery point to ensure a return to a stable state before the update. The rollback process is executed strictly in sequence to prevent file inconsistencies.

[0033] When a network interruption is detected, the system automatically saves the information of downloaded data blocks and resumes downloading from the point of interruption once the network connection is restored. A backoff algorithm is used to perform re-download operations, gradually increasing the retry interval with each retrieval, up to a maximum of 5 retries, to avoid resource waste caused by frequent retries. During the update process, resource usage is monitored in real time, and a CPU utilization limit threshold is set. Process priorities are dynamically adjusted or some operations are paused based on the limit threshold to avoid excessive consumption of computing resources. Files are directly mapped to memory, and data blocks are loaded in pages to ensure efficient memory use and reserve sufficient space to ensure the smooth completion of the update process. Distributed locks are used to coordinate the execution order of multiple update tasks, ensuring that resource access between different update tasks does not conflict. For shared resources, a read-write lock mechanism is used, allowing multiple read operations to execute concurrently, while write operations exclusively occupy resources. A deadlock detection mechanism ensures that the system will not fall into a deadlock state due to resource contention.

[0034] Figure 2 This is a diagram illustrating the incremental update distribution process for a mini-program. (Refer to...) Figure 2 As shown, the client requests an update check (including current version information), the server queries the version chain and calculates the update path; the storage system / version management module returns the update path information (a list of Diff packages), and the server returns the update information to the client. The client requests the required incremental package, the server pulls it from the storage system and returns the Diff package, and the client merges the Diff packages and completes the update.

[0035] Figure 3 A schematic flowchart illustrating the incremental distribution method for mini-programs provided in this application. (Refer to...) Figure 3 As shown, a rolling hash algorithm is used to accurately identify file differences between the target and base versions. The hash algorithm efficiently locates and extracts the difference data blocks between versions by calculating the hash value of the file content. These difference data blocks are packaged into incremental update packages, ensuring that only the changed parts are transmitted in each update, thereby reducing bandwidth consumption and update latency. A dependency graph between versions is constructed based on the version metadata database. The dependency graph describes the upgrade relationships between different versions, helping the system calculate the upgrade chain from the current version to the target version. Each edge in the graph represents a path from one version to another, using graph theory algorithms (such as Dijkstra's algorithm or A*). The search function is used to calculate the optimal update path, ensuring an efficient and redundant upgrade process. When a client requests a version update, the system selects the most suitable update path based on received client information (such as the current version and target version) and environmental conditions (such as geographical location and bandwidth). By selecting the optimal update node, the system can ensure more efficient transmission of incremental packets, avoiding network bottlenecks or high latency. Finally, the incremental update packet is transmitted from the selected update node to the client.

[0036] Figure 4 A flowchart illustrating the incremental update method for the mini-program provided in this application. (Refer to...) Figure 4 As shown, the client initiates a version update request to the server. The system selects the optimal update node based on the client's bandwidth and geographical location. Selecting the optimal node ensures efficient transmission of the update package, avoids high latency and insufficient bandwidth, and improves the user's download experience. The client obtains the incremental update package from the server and parses the packet header information. During parsing, the client can obtain version metadata, such as the target version and base version. Based on the data in the incremental update package, the client uses the corresponding decompression algorithm to recover the incremental data, extracting the differences and changes. At this point, the client knows which data needs to be updated and the specific locations of this data.

[0037] The client maps the base version file into memory, allowing it to locate the parts that need updating without replacing the entire file. Based on the differences in the incremental update package, the client locates the necessary modifications block by block and performs the data replacement operation. This on-demand update method significantly reduces update time and resource consumption.

[0038] After the update is complete, the client performs digital signature verification on the updated version: checking the source and integrity of the incremental update package to prevent tampering. Integrity hash verification: comparing the hash value of the updated version to ensure the files are not corrupted. Malicious code scanning: performing a security scan to ensure the update package does not carry malware. If all verifications pass, the client deletes temporary directories and intermediate files, freeing up storage space and ensuring a clean and thorough update process. The client writes version information and change logs to a local database to ensure update records are traceable. Finally, the client sends an update completion confirmation to the server, notifying the server that the update operation has been successfully completed.

[0039] Figure 5 This is a schematic block diagram of an electronic device according to embodiments of the present disclosure. (As shown) Figure 5 As shown, the electronic device 500 may include a processor 510 and a memory 520 storing a computer program. When the computer program is executed by the processor 510, the electronic device 500 is made capable of performing actions such as... Figure 1 The steps of method 100 shown.

[0040] In embodiments of this disclosure, processor 510 may be, for example, a central processing unit (CPU), a microprocessor, a digital signal processor (DSP), a processor based on a multi-core processor architecture, etc. Memory 520 may be any type of memory implemented using data storage technologies, including but not limited to random access memory, read-only memory, semiconductor-based memory, flash memory, disk storage, etc.

[0041] Furthermore, in embodiments of this disclosure, the electronic device 500 may also include an input device 530, such as a keyboard or mouse. Additionally, the electronic device 500 may also include an output device 540, such as a display.

[0042] In other embodiments of this disclosure, a computer-readable storage medium storing a computer program is also provided, wherein the computer program, when executed by a processor, is capable of performing the following functions: Figure 3 The incremental distribution method for mini-programs shown below and Figure 4 The steps of the incremental update method for mini-programs are shown below.

[0043] In summary, the incremental distribution and update methods for mini-programs provided in this application, through binary incremental update technology, solve the problems of wasted traffic, low update efficiency, and poor user experience inherent in traditional mini-program updates. By achieving precise incremental package generation, high-compression incremental package distribution, parallel downloading, and intelligent caching mechanisms, this solution minimizes traffic consumption and significantly improves update speed. This not only helps reduce development costs but also enhances the flexibility and scalability of mini-programs, bringing a better user experience to both developers and users.

[0044] It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases the steps shown or described may be executed in a different order than that shown here.

[0045] Obviously, those skilled in the art should understand that the various units or steps of this application described above can be implemented using general-purpose computing devices. They can be centralized on a single computing device or distributed across a network of multiple computing devices. Optionally, they can be implemented using computer-executable program code, thereby storing them in a storage device for execution by a computing device, or fabricating them separately as individual integrated circuit modules, or fabricating multiple modules or steps into a single integrated circuit module. Thus, this application is not limited to any particular combination of hardware and software.

[0046] The above description is merely a preferred embodiment of this application and is not intended to limit this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.< / updatenode> < / string> < / chunk> < / chunk> < / chunk> < / string> < / string> < / string> < / string>

Claims

1. An applet incremental update distribution system, characterized by, Comprise: Client, server and storage system, the server includes version management module, incremental package generation module, distributed update module, the version management module, for constructing version dependency graph based on version metadata database, calculating the upgrade chain from the current version to the target version, using graph theory algorithm to calculate the optimal update path; the incremental package generation module, for identifying the difference data block between the target version and the base version based on the rolling hash algorithm, packing the difference data block to generate incremental update package; The distributed update module is used for receiving the version update request of the client, selecting the optimal update node based on the geographical position and bandwidth of the client, and transmitting the incremental update package of the version to the client from the optimal update node according to the update path; The client is used for sending version update request to the server, selecting the optimal update node based on bandwidth and geographical position, obtaining incremental update package according to incremental update path; parsing the header information of the incremental update package, obtaining version metadata, using corresponding decompression algorithm to recover incremental data, obtaining difference position and change content; The base version file is mapped to the memory, the difference information in the incremental update package is located to the position needing to be modified block by block, and the data replacement operation is executed; the updated version is verified by digital signature, integrity hash check and malicious code scanning, and after verification, the temporary directory and intermediate file are deleted, the version information log and update log are written to the local database, and the update completion confirmation is sent to the server; The storage system is used for dividing different storage paths or naming spaces according to version information, and independently storing incremental packages of different versions.

2. An applet incremental distribution method, adapted to be executed on a server, characterized in that, Comprise: Identifying the difference data block between the target version and the base version based on the rolling hash algorithm, packing the difference data block to generate incremental update package; Constructing version dependency graph based on version metadata database, calculating the upgrade chain from the current version to the target version, and using graph theory algorithm to calculate the optimal update path; And Receiving the version update request of the client, selecting the optimal update node based on the geographical position and bandwidth of the client, and transmitting the incremental update package of the version to the client from the optimal update node according to the update path.

3. The applet incremental distribution method according to claim 2, wherein, The difference data block between the target version and the base version is identified based on the rolling hash algorithm, and the difference data block is packed to generate incremental update package, comprising: Initialize the rolling hash calculator, set the base value to 256, and the modulus to 1000000007; The file content is scanned by sliding window, and the hash value of the current data block is calculated; The hash value of the current data block is compared with the corresponding position of the base version, and when the hash value is found to be unmatched, the position information and specific content of the difference block are recorded; The difference block is compressed using Zstandard compression algorithm, the compression parameters are adjusted according to the data characteristics to obtain binary incremental package, and a unique digital signature is generated for each binary incremental package.

4. The applet incremental distribution method according to claim 2, wherein, The version dependency graph is constructed based on version metadata database, the upgrade chain from the current version to the target version is calculated, and the optimal update path is calculated by using graph theory algorithm, comprising: Registering the applet version, storing the metadata of the applet version in a version metadata database, the metadata including a version unique identifier, a base version number, a target version number, an update time, a change log, and version-related dependent modules; Building a version dependency graph based on the version metadata database, the nodes of the version dependency graph representing different versions and the edges representing the dependency relationships between the versions; Calculating an optimal path from a current version to a target version based on the version dependency graph using a Dijkstra algorithm.

5. The applet incremental distribution method according to claim 4, wherein, The calculation of the optimal path from the current version to the target version based on the version dependency graph using the Dijkstra algorithm includes: Creating a graph structure with version IDs as nodes and bandwidth consumption and update risk as edge weights, adding nodes and edges one by one according to the version information from the base version to the target version in the version metadata database; Initializing the distance of the starting node as 0 and the distances of other nodes as infinity, and storing unprocessed nodes in a priority queue; Looping through each node to update the distances of its adjacent nodes and record its predecessor node, and stopping the algorithm when the target version is processed; Backtracking from the target version to the current version to build a complete optimal upgrade chain.

6. An applet incremental update method, adapted to be executed at a client, characterized by, The method includes: Sending a version update request to a server, selecting an optimal update node based on bandwidth and geographic location, and obtaining an incremental update package according to an incremental update path; Parsing the header information of the incremental update package to obtain version metadata, restoring the incremental data using a corresponding decompression algorithm to obtain the difference position and change content; Mapping the base version file to memory, positioning to the modified position according to the difference information in the incremental update package, and performing a data replacement operation; and Performing digital signature verification, integrity hash check, and malicious code scanning on the updated version, deleting temporary directories and intermediate files after verification, writing version information logs and update logs to a local database, and sending an update completion confirmation to the server.

7. The applet incremental update method according to claim 6, wherein, Before the version update request is sent to the server, the method further includes: Detecting available storage space, memory usage, CPU load state, and network connection stability; Checking whether the current version is complete, whether the version number matches, and whether the related dependent components are normal; Performing a complete backup of the current version file after the check.

8. The applet incremental update method according to claim 6, wherein, The method further includes: Identifying abnormal situations including network connection interruption, insufficient storage space, file access failure, and data verification error, and recording the context information of the abnormality; When a network interruption is detected, automatically saving the downloaded data block information, and continuing the download from the breakpoint after the network is restored, and performing a re-download operation using a backoff algorithm; Monitoring the resource usage during the update process in real time, setting a CPU usage limit threshold, and dynamically adjusting the process priority or pausing part of the operation according to the limit threshold; Mapping the file directly to the memory, loading the data block in pages, using a distributed lock to coordinate the execution order of multiple update tasks, and using a read-write lock mechanism and a deadlock detection mechanism for access to shared resources.

9. An electronic device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, The processor implements the steps of the applet incremental distribution method according to any one of claims 2 to 5 and the applet incremental updating method according to any one of claims 6 to 8 when the processor executes the program.

10. A computer-readable storage medium having stored thereon a computer program, characterized in that, The computer program implements the steps of the applet incremental distribution method according to any one of claims 2 to 5 and the applet incremental updating method according to any one of claims 6 to 8 when the processor executes the program.

Citation Information

Patent Citations

  • Distributed system software upgrading method and system and related components

    CN112486541A

  • SD card-based power distribution terminal upgrading method, system, equipment and medium

    CN120560689A

  • Electronic gas meter remote upgrading system and method

    CN120935150A

  • Software upgrading link determination method, system, equipment and medium

    CN121255237A