A data breakpoint downloading method and system

By assigning a first storage address different from the user-specified address to the target file and generating Range information for breakpoint resumption, the problem of low reliability of breakpoint resumption in existing technologies is solved, and the security and integrity of data download are improved.

CN115865900BActive Publication Date: 2025-10-21ZHONGKE MEILUO
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211520909.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-11-30
Publication Date
2025-10-21
Estimated Expiration
2042-11-30

AI Technical Summary

Technical Problem

The reliability of resuming interrupted transmissions in existing technologies is not high, mainly because the local cache location is fixed and easily tampered with, leading to errors in the Range field and thus causing the resuming transmission to fail.

Method used

The process involves assigning a first storage address to the target file, which is different from the second storage address specified by the user, and generating Range information based on changes in the downloaded data. This information is then sent to the server to retrieve the remaining data until the download of the target file is complete, at which point the data is transferred to the second storage address.

Benefits of technology

This increases the difficulty for tamperers to obtain the first storage address, reduces the possibility of address exposure, and enhances the reliability and security of resuming interrupted downloads.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115865900B_ABST
    Figure CN115865900B_ABST
Patent Text Reader

Abstract

The application provides a data breakpoint downloading method and system, and the method comprises the following steps: assigning a first storage address to a target file according to a downloading instruction of a user for the target file; requesting data of the target file from a server according to the downloading instruction, receiving downloading data returned by the server, caching the downloading data to the first storage address, and judging whether a breakpoint continuation operation is needed according to the change of the downloading data in the first storage address; if yes, generating Range information according to the data volume of the downloading data stored in the cache position, and sending the Range information to the server; receiving remaining data, taking the received remaining data as downloading data, and returning to execute the step of caching the downloading data to the first storage address; and parsing all the downloading data of the target file in the cache position, obtaining the target file, and transferring the target file to a second storage address. The application embodiment can improve the reliability of the breakpoint continuation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of breakpoint resume transmission, and in particular to a data breakpoint downloading method and system. Background Art

[0002] The principle of breakpoint downloading is based on the Range and Content-Range fields in the HTTP header, which are defined in HTTP 1.1 (Hypertext Transfer Protocol, RFC 2616). The protocol supports requesting only a portion of a resource. A Range is sent by the client to the server and can request one or more subranges of a file resource.

[0003] The Content-Range field is returned by the server to the client, indicating that the server has returned a certain range of the file (after downloading) and the total length of the file. The existing method for implementing breakpoint downloads requires local caching and maintenance of the downloaded data.

[0004] However, the inventors discovered that the local cache's storage location is fixed and public, making it relatively easy to detect. Once the data in the local cache is tampered with, the Range field returned by the client will be incorrect, causing breakpoint resume failure. Therefore, the existing technology suffers from the disadvantage of low reliability of breakpoint resume. Summary of the Invention

[0005] The technical problem to be solved by the present invention is how to provide a data breakpoint download method and system to solve the problem of low reliability of breakpoint resume transmission in the prior art.

[0006] The present invention solves the above technical problems through the following technical means:

[0007] The present invention provides a data breakpoint download method, which is applied to a client, and the method comprises:

[0008] Allocating a first storage address for the target file according to a download instruction from a user for the target file, wherein the download instruction includes a second storage address of the target file specified by the user;

[0009] Requesting the target file data from the server according to the download instruction, receiving the downloaded data returned by the server, caching the downloaded data to the first storage address, and determining whether a change in the downloaded data in the first storage address requires a breakpoint resume operation;

[0010] If so, generating Range information based on the amount of downloaded data stored in the cache location, and sending the Range information to the server, so that the server returns the remaining data corresponding to the target file; receiving the remaining data, using the received remaining data as the downloaded data, and returning to execute the step of caching the downloaded data to the first storage address until all the downloaded data of the target file is obtained, wherein the remaining data is other data in the target file except the downloaded data;

[0011] All downloaded data of the target file in the cache location is parsed to obtain the target file and transfer the target file to the second storage address.

[0012] Optionally, allocating a first storage address to the target file includes:

[0013] A storage address list of the client is obtained, and an address is randomly selected from the storage address list as a first storage address.

[0014] Optionally, allocating a first storage address to the target file includes:

[0015] Obtaining a storage address list of the client, and selecting a first number of addresses from the storage address list as candidate addresses according to a preset strategy;

[0016] Sending the first number to the server, so that the server divides the target file into a first number of data segments according to the first number, assigns a unique number to each data segment, and appends the number to each data packet corresponding to the data segment;

[0017] Receive the data packet corresponding to the target file returned by the server and extract the number corresponding to the data packet, traverse each candidate address according to the number, and determine whether the data packet of the downloaded data in each candidate address contains the number;

[0018] If so, using the candidate address as the first storage address corresponding to the data packet, and caching the data packet in the first storage address;

[0019] If not, delete the alternative address that has cached the downloaded data from the set of alternative addresses to obtain the remaining set of alternative addresses, and randomly select an alternative address from the remaining set of alternative addresses as the first storage address for caching the data packet; return to the step of receiving the data packets corresponding to each data segment returned by the server until all data packets corresponding to the target data are received.

[0020] Optionally, selecting a first number of addresses from the storage address list as candidate addresses according to a preset strategy includes:

[0021] Obtain the hash value of each storage address in the storage address list to obtain several hash values;

[0022] For each hash value, calculate the distance between the hash value and other hash values ​​one by one, and use the sum of the distances as the label value of the hash value;

[0023] The hash values ​​are sorted in ascending order of the label values ​​to obtain a hash value sequence; and storage addresses corresponding to the first number of sequentially ordered hash values ​​with the smallest label values ​​in the hash value sequence are used as candidate addresses.

[0024] Optionally, caching the downloaded data to the first storage address includes:

[0025] Obtain the first-order information of the target file on the server; obtain the second-order information of the client, and determine whether the first-order information is consistent with the second-order information;

[0026] If so, cache the downloaded data to the first storage address.

[0027] Optionally, caching the downloaded data to the first storage address includes:

[0028] Obtaining storage format information of the target file on the server;

[0029] The downloaded data is encapsulated using the storage format information, the downloaded data is cached to a first storage address, and a Range information reading interface for the downloaded data is provided to the file management system of the client.

[0030] Optionally, the encapsulating the downloaded data using the storage format information includes:

[0031] The downloaded data is encapsulated and the attribute information of the downloaded data is replaced with the storage format information.

[0032] Optionally, the encapsulating the downloaded data using the storage format information includes:

[0033] Establishing a virtual machine according to the storage environment information of the target file, and caching the downloaded data in the virtual machine;

[0034] The location where the downloaded data is cached in the virtual machine is used as the first storage address.

[0035] Optionally, generating Range information according to the amount of downloaded data stored in the cache location includes:

[0036] Obtaining a first hash value corresponding to the target data, and obtaining a stored second hash value from each first storage address, wherein the second hash value is a hash value for the target data obtained when the client receives the downloaded data from the server;

[0037] Determine whether the second hash value contains data identical to the first hash value;

[0038] If so, use the cache parsing method to parse the Range information of the downloaded data;

[0039] If not, a new Session is created, and the step of receiving the remaining data and using the received remaining data as the download data is executed.

[0040] The present invention also provides a data breakpoint download system, which includes a client and a server, wherein:

[0041] The client is used to execute the above-mentioned data breakpoint download method;

[0042] The server is used to return the download data to the client according to the download instruction, and return the remaining data of the target file as the download data to the client according to the Range information.

[0043] The advantages of the present invention are:

[0044] The present invention increases the difficulty for tamperers to obtain the first storage address by caching the target file at the first storage address rather than the second storage address specified by the user or the default of the download process, thereby reducing the possibility of the first storage address being exposed and ultimately improving the reliability of breakpoint resumption. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] Figure 1 A schematic diagram of a flow chart of a data breakpoint downloading method provided by an embodiment of the present invention;

[0046] Figure 2 A schematic diagram of a method for starting a session in a data breakpoint download method provided by an embodiment of the present invention;

[0047] Figure 3 A schematic structural diagram of a data breakpoint downloading system provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0048] To make the objectives, technical solutions, and advantages of the embodiments of the present invention more clear, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.

[0049] Example 1

[0050] First, it should be noted that Embodiment 1 of the present invention is preferably applicable to a client, such as a terminal device such as a mobile phone, a tablet computer, or a laptop computer.

[0051] Figure 1 A flow chart of a data breakpoint downloading method provided by an embodiment of the present invention is shown as follows: Figure 1 As shown, the method includes:

[0052] S101: Allocate a first storage address for a target file according to a download instruction from a user for the target file, wherein the download instruction includes a second storage address of the target file specified by the user.

[0053] Exemplarily, the embodiment of the present invention is described by taking a mobile phone with an iOS system as the client and a server with a Kylin Linux system as the server as an example. When the user inputs a download instruction on the mobile phone, the download instruction at least includes the identification information of the target file, and when the target file is downloaded, the target file should be stored in the second storage address of that location in the mobile phone. Normally, the second storage address can be the system default download address on the client, for example, the default download address of the download process in the mobile phone system, usually a download folder, in which the downloaded files are stored in the folder regardless of any download instruction. Alternatively, the download address is manually set by the user on the client, such as a file set by the user for storing songs, or a folder set by the user for storing pictures, but the download address needs to be manually set by the user, or needs to be manually set by the user when used for the first time.

[0054] The client sends a request to the server to download the target file according to the download instruction. The server parses the download request, obtains the identification information of the target file, finds the target file stored in the server according to the identification information, and sends the target file to the client in the form of a data packet.

[0055] When the client sends a download instruction to the server, it can assign a first storage address to the data packet of the target file to be received. It is important to emphasize that the first storage address is different from the second storage address. The first storage address is automatically set by the client system based on the download instruction. Different download instructions can correspond to different first storage addresses. Multiple download instructions can also use two or more first storage addresses.

[0056] In a specific implementation of this step, the client can use a tool to read the storage directory information of each file, take each storage directory as a storage address, and then obtain a storage address list of the client, and then randomly select one from the storage address list as the first storage address. In actual application, software such as itool or everything can be used to read information of all files on the client, and then obtain the storage directory information of each file.

[0057] S102: Request the target file data from the server according to the download instruction, receive the download data returned by the server, cache the download data to the first storage address, and determine whether the change of the download data in the first storage address requires a breakpoint resume operation. If so, execute step S103.

[0058] The client continuously receives data packets returned by the server, and then caches the data packets in the first storage address. A target file will correspond to several data packets, and the data packets are continuously sent by the server to the client. For example, the target file corresponds to 100 data packets, and the server sends the data packets one by one, and the client also receives these data packets one by one. The client regards the A data packets that have been cached in the first storage address as downloaded data as a whole. If the client has not received the 100-A data packets corresponding to the target file, it regards these data packets as the remaining data as a whole. It can be understood that the size of the data packet is determined according to the file transfer protocol, and the protocol should apply to both the client and the server.

[0059] However, in actual applications, due to the influence of device performance and network fluctuations, the transmission process of data packets may be interrupted, resulting in the failure or suspension of target file download.

[0060] Therefore, the client needs to have a process to continuously monitor the download status of the target data packet, and then determine whether a download interruption occurs according to the download status. If a download interruption occurs, step S103 needs to be executed.

[0061] S103: Generate Range information according to the amount of downloaded data stored in the cache location, and send the Range information to the server so that the server returns the remaining data corresponding to the target file; receive the remaining data and use the received remaining data as downloaded data, and return to execute the step of caching the downloaded data to the first storage address until all the downloaded data of the target file is obtained, wherein the remaining data is other data in the target file except the downloaded data.

[0062] First, Range information is typically used in the request header to specify the first and last byte positions. The general format is: Range:(unit=first byte pos)-[last byte pos]. If the target file contains 10,000 bytes, each data packet contains 100 bytes. If A data packets have been cached, then 100A bytes are cached at the first storage address. Therefore, the Range information for the downloaded data includes: first byte pos is byte 100A+1, and last byte pos is byte 10,000.

[0063] After the client sends the Range information to the server, the server returns a partial response Content-Range to the client, which must describe the range covered by the response and the length of the entire entity. General format: Content-Range: bytes (unit first byte pos) - [last byte pos] / [entity legth]

[0064] Then the client interacts with the server again, and the server sends B packets of the target file to the client, and the client caches these B packets as download data to the first storage address. After the client downloads all 100 packets, the complete cache file of the target file can be obtained.

[0065] Secondly, in another embodiment of this step, when generating Range information based on the amount of downloaded data stored in the cache location, the client needs to obtain a first hash value corresponding to the target data. The first hash value can be a string returned by the server when sending a download request to the server, used by the client to verify whether the target file to be downloaded is complete.

[0066] In actual applications, to prevent the client from not receiving the first hash value, the server will include the first hash value in a data packet sent to the client, so that the downloaded data includes several hash values. In actual applications, to avoid the impact of inserting the first hash value in every data packet on the effective data packet capacity, the server can extract one data packet out of every 10 data packets and insert the first hash value into this data packet. This not only ensures that the client can receive the first hash value, but also reduces the hash value string from occupying too much of the effective data packet capacity.

[0067] Because the client may have multiple download data corresponding to multiple target files, in this embodiment of the present invention, the hash value obtained from the downloaded data is referred to as the second hash value. The second hash value is stored in the data packet, and the downloaded data is composed of multiple data packets. Therefore, the second hash value can be directly parsed from the downloaded data using cache parsing methods.

[0068] The client has downloaded other files before, and each file has a second hash value. Therefore, the client can parse out more than one second hash value. If the client fails to parse out any second hash value, the second hash value is empty.

[0069] Figure 2 A schematic diagram of a Session startup method in a data breakpoint download method provided by an embodiment of the present invention is shown as follows: Figure 2 As shown, the client determines in real time whether there is data identical to the first hash value in the second hash value; if the judgment result is yes, it means that the client has received the download data for the target file, indicating that breakpoint downloading is required. The premise of breakpoint downloading is to obtain the Range information of the download data. Therefore, the cache parsing method is used to parse the Range information of the download data, and then the breakpoint resume operation is performed according to the Range information.

[0070] If the above judgment result is no, it means that although the client has obtained the second hash value, the obtained second hash value is not the hash value of the target file, that is, the target file has not been downloaded. Therefore, it is necessary to establish a new session to complete the download operation for the target file.

[0071] For the target file whose download is interrupted, if a new Session is directly established, it will be downloaded again, which will result in too long download time for the target file and waste of traffic. Therefore, it is necessary to obtain Range information, and then restart the previous Session according to the Range information, or establish a new Session to continue downloading the target file. By applying the embodiment of the present invention, the hash value comparison method can be used to determine whether to directly start the breakpoint resume method or to establish a new download task, thereby avoiding repeated downloading of the downloaded data, reducing time consumption, and saving traffic.

[0072] S104: parsing all downloaded data of the target file in the cache location, obtaining the target file and transferring the target file to the second storage address.

[0073] The client parses the cache file to restore the target file, and then transfers the target file to the second storage address.

[0074] The present invention increases the difficulty for tamperers to obtain the first storage address by caching the target file at the first storage address rather than the second storage address specified by the user or the default of the download process, thereby reducing the possibility of the first storage address being exposed and ultimately improving the reliability of breakpoint resumption.

[0075] Furthermore, to improve system performance, the first storage address is an address in RAM. This allows direct operations on data in RAM, avoiding the need to save and maintain downloaded data locally and simplifying the implementation of breakpoint downloads. This avoids duplicate caching of local data, reduces system consumption, and improves performance.

[0076] Example 2

[0077] Based on the first embodiment of the present invention, the second embodiment of the present invention further provides another method for obtaining the first storage address:

[0078] S201 (not shown in the figure): obtaining a storage address list of a client, and selecting a first number of addresses from the storage address list as candidate addresses according to a preset strategy.

[0079] Specifically, the hash value of each storage address in the storage address list can be obtained to obtain several hash values; for example, storage address 1 corresponds to hash value 1, storage address 2 corresponds to hash value 2, storage address 3 corresponds to hash value 3, storage address 4 corresponds to hash value 4, and so on. The following takes hash value 1 as an example for explanation.

[0080] Then, the distance 1 between hash value 1 and hash value 2, the distance 2 between hash value 1 and hash value 3, the distance 3 between hash value 1 and hash value 4, and the distance 4 between hash value 1 and hash value 5 are calculated. In practical applications, hash values ​​are strings of a certain length and can be calculated using the Hamilton distance or Manhattan distance calculation method. Furthermore, when the hash algorithm used by the client is updated, resulting in a length inconsistency between the previously calculated hash value 2 and the currently calculated hash value 1, the updated hash algorithm can be used to perform a secondary hash on hash value 1 and hash value 2, respectively, to obtain the secondary hash value 1 of hash value 1 and the secondary hash value 2 of hash value 2, and then calculate the Hamilton distance between the secondary hash values ​​1 and 2, thereby achieving compatibility with different hash values.

[0081] Then, we sum distance 1, distance 2, distance 3, and distance 4 to get the tag value 1 for hash value 1. Using the above method, we can calculate the tag value 1 for hash value 1, the tag value 2 for hash value 2, the tag value 3 for hash value 3, the tag value 4 for hash value 4, and the tag value 5 for hash value 5.

[0082] The hash values ​​are sorted in ascending order of the label value to obtain a hash value sequence: the resulting hash value sequence is: hash value 1, hash value 2, hash value 3, hash value 4. In this hash value sequence, the label value of hash value 1 is the smallest; the label value of hash value 2 is larger than the label value of hash value 1 but smaller than the label value of hash value 3; the label value of hash value 3 is larger than the label value of hash value 2 but smaller than the label value of hash value 4; and the label value of hash value 4 is the largest.

[0083] When the first number is 2, storage address 1 corresponding to hash value 1, storage address 2 corresponding to hash value 2, and storage address 3 corresponding to hash value 3 are selected as candidate addresses. These three candidate addresses constitute a candidate address set.

[0084] It should be emphasized that the first number can be 3 or other positive integers.

[0085] S202 (not shown): Send the first number to the server, so that the server divides the target file into a first number of data segments according to the first number, sets a unique number for each data segment, and appends the number to each data packet corresponding to the data segment.

[0086] The client sends the first number to the server, and the server divides the target file into three data segments, such as data segment 1, data segment 2, and data segment 3. Data segment 1 contains 33 data packets, data segment 2 contains 33 data packets, and data segment 3 contains 34 data packets. It is understood that when the target file is divided, the division is not performed evenly, and the embodiment of the present invention does not limit how the target file is divided.

[0087] The client inserts the number "1" into one or more of the 33 data packets contained in data segment 1, inserts the number "2" into one or more of the 33 data packets contained in data segment 2, and inserts the number "3" into one or more of the 34 data packets contained in data segment 3. Generally, numbers can be inserted into all data packets.

[0088] After completing the above operations, the server sends the 33 data packets contained in data segment 1, the 33 data packets contained in data segment 2, and the 34 data packets contained in data segment 3 to the client in sequence.

[0089] S203 (not shown): receiving a data packet corresponding to the target file returned by the server and extracting a number corresponding to the data packet, traversing each candidate address according to the number, and determining whether the data packet of the downloaded data in each candidate address contains the number.

[0090] After receiving data packet a in data segment 1 of the target file, the client extracts the corresponding data packet number from the data packet. For example, if the number read is "1," the client traverses each candidate address: storage address 1 and storage address 2. If the number in the data packet at storage address 1 is "1," step S204 is executed. If not, step S205 is executed.

[0091] S204 (not shown in the figure): using the candidate address as the first storage address corresponding to the data packet, and caching the data packet in the first storage address.

[0092] The candidate address with the same cached data packet number as the target file data packet number is used as the first storage address, that is, storage address 1 is used as the first storage address, and the data packet received in step S203 is cached in the storage address.

[0093] S205 (not shown in the figure): Delete the alternative address that has cached the downloaded data from the set of alternative addresses to obtain the remaining set of alternative addresses, and randomly select an alternative address from the remaining set of alternative addresses as the first storage address for caching the data packet; return to the step of receiving the data packets corresponding to each data segment returned by the server until all data packets corresponding to the target data are received.

[0094] If a data packet exists in storage address 1 and the data packet number in storage address 1 is not 1, storage address 1 is removed from the candidate address set, and then each candidate address in the candidate address set is traversed according to the above method. For example, if a data packet numbered 1 is cached in candidate address 2, the data packet numbered 1 is cached in candidate address 2. In this case, candidate address 2 should also be removed from the candidate address set.

[0095] If no data packet is cached in either candidate address 3 or candidate address 4, candidate address 3 and candidate address 4 are used as the remaining candidate address set, and one candidate address is randomly selected from the two and used as the first storage address.

[0096] Then, the next data packet is received, and step S203 is performed on the next data packet until all data packets are received. In actual applications, this may be data packet a+1 in data segment 1 or data packet b in data segment 2. The embodiment of the present invention does not limit the order in which the data packets are received.

[0097] By applying the embodiment of the present invention, the target file is split. When the client receives data packets of different data segments, the caches belonging to different data segments are stored in different first storage addresses. Even if one of the first storage addresses is discovered, the tamperer can only obtain part of the data packets but not the other data packets. Compared with the technical solution of caching all data packets of the target file in the same first storage address, embodiment 2 of the present invention further reduces the risk of cache address exposure and improves data security.

[0098] Example 3

[0099] Based on embodiment 1 of the present invention, embodiment 3 of the present invention caches the downloaded data to the first storage address. The method includes:

[0100] Obtain the first-base information of the target file on the server; obtain the second-base information of the client, and determine whether the first-base information is consistent with the second-base information; if so, cache the downloaded data to the first storage address.

[0101] In the prior art, the client needs to calculate the Range data and interact with the server. The method and steps are relatively cumbersome and prone to errors. If the Range calculation is wrong, the files spliced ​​together by the breakpoint download will be invalid. For example, when the client receives the data packet of the target file from the server, it will also request the server for the first-order information of the target file. For example, when the target file is stored in the server, if the server uses the Linux system, its first-order information is 1024. When the client is Android, its second-order information is 1024, and when the client is iOS, its second-order information is 1000. This may cause the breakpoint resume to fail.

[0102] To solve the above problem, the embodiment of the present invention first identifies the difference in base numbers between the server and the client, and then caches the file when the base numbers are consistent. This can shield errors caused by base number differences and improve the reliability of breakpoint resuming.

[0103] Furthermore, the storage format of the same target file on the server and client may be different. Different storage formats correspond to different encoding methods, so the number of bytes will also be different. That is to say, the Range information returned by the client may be misaligned with the byte sequence number read from the target file by the server. In order to solve the errors caused by the file format, the embodiment of the present invention adds the following steps. First, the storage format information of the target file on the server is obtained; then, the downloaded data is encapsulated and the attribute information of the downloaded data is replaced with the storage format information, the downloaded data is cached to the first storage address, and the Range information reading interface of the downloaded data is provided to the client's file management system.

[0104] For example, if the target file is in format A on the server, the client will also store the downloaded data in format A after receiving the target file data packet. This will mask errors in the calculation of the range information due to the format. The client will then perform cache parsing on the downloaded file based on format A to obtain accurate range information.

[0105] In another specific real-time method of an embodiment of the present invention, using the storage format information to encapsulate the downloaded data may include the following steps: establishing a virtual machine based on the storage environment information of the target file, caching the downloaded data in the virtual machine; and using the location where the downloaded data is cached in the virtual machine as the first storage address.

[0106] To further mitigate potential parsing errors, a virtual machine can be created on the client. The target file storage format, system version number, system type, and hardware format in the virtual machine are consistent with those on the server. Storing and parsing downloaded files in the virtual machine ensures the most accurate range information, thus avoiding discrepancies between client and server range information. This improves the reliability of resuming downloads.

[0107] Finally, due to sudden network disconnection, network fluctuations, etc., the range of files returned by the server differs from the range of downloaded files actually stored locally, resulting in inconsistency between the two. The above method of the embodiment of the present invention can also shield the differences caused by network problems.

[0108] Example 4

[0109] Corresponding to any one of Embodiments 1-3 of the present invention, Embodiment 4 provides a data breakpoint download system, the system comprising a client and a server, wherein:

[0110] The client is used to execute the method as claimed in claim 1;

[0111] The server is used to return the download data to the client according to the download instruction, and return the remaining data of the target file as the download data to the client according to the Range information.

[0112] Example 5

[0113] Figure 3 A schematic diagram of a data breakpoint download system provided by an embodiment of the present invention is shown in FIG. Figure 3 As shown, the system consists of download view, downloader, cache parsing, session management, thread management, state management and tool classes.

[0114] Download view: used to display the progress and status of a download, and to interact with the user, such as providing the user with control operations such as starting downloads, pausing downloads, and canceling downloads.

[0115] Downloader: The main part of the file download operation. It connects and interacts with the server and transfers the target file stored on the server to the client.

[0116] Cache parsing: System caches typically contain data in specific formats, such as XML and Plist. System cache parsing primarily parses this type of data to obtain breakpoint information and provide data support for session recovery. The structure and format of cache files may vary between different system versions, and the cache parsing module masks these differences.

[0117] Session management: used to manage download sessions, including creation, restoration, and destruction of download sessions.

[0118] Thread Management: For multiple download tasks running in parallel, multiple download threads are started and managed accordingly. For multiple download tasks running simultaneously, multiple threads are started and managed through the thread manager. There is a maximum number of concurrent threads, which is determined by the hardware and system.

[0119] Status Management: Manages download status, including: Not Started, Downloading, Paused, Canceled, and Completed. Different operations cause download status changes, which require synchronization through the status manager.

[0120] Tools: Provide basic functional services for other parts, such as communication, hash value calculation, list control, etc.

[0121] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present invention.

Claims

1. A data breakpoint download method, characterized in that: Applied to a client, the method includes: Allocating a first storage address for the target file according to a download instruction from a user for the target file, wherein the download instruction includes a second storage address of the target file specified by the user; Requesting the target file data from the server according to the download instruction, receiving the downloaded data returned by the server, caching the downloaded data to the first storage address, and determining whether a change in the downloaded data in the first storage address requires a breakpoint resume operation; If so, generating Range information based on the amount of downloaded data stored in the cache location, and sending the Range information to the server, so that the server returns the remaining data corresponding to the target file; receiving the remaining data and using the received remaining data as the downloaded data, and returning to execute the step of caching the downloaded data to the first storage address until all the downloaded data of the target file is obtained, wherein the remaining data is other data in the target file except the downloaded data; Parsing all downloaded data of the target file in the cache location, obtaining the target file and transferring the target file to the second storage address; The allocating a first storage address to the target file includes: Obtaining a storage address list of the client, and selecting a first number of addresses from the storage address list as candidate addresses according to a preset strategy; Sending the first number to the server, so that the server divides the target file into a first number of data segments according to the first number, assigns a unique number to each data segment, and appends the number to each data packet corresponding to the data segment; Receive the data packet corresponding to the target file returned by the server and extract the number corresponding to the data packet, traverse each candidate address according to the number, and determine whether the data packet of the downloaded data in each candidate address contains the number; If so, using the candidate address as the first storage address corresponding to the data packet, and caching the data packet in the first storage address; If not, delete the alternative address that has cached the downloaded data from the set of alternative addresses to obtain the remaining set of alternative addresses, and randomly select an alternative address from the remaining set of alternative addresses as the first storage address for caching the data packet; return to the step of receiving the data packets corresponding to each data segment returned by the server until all data packets corresponding to the target data are received.

2. A data breakpoint downloading method according to claim 1, characterized in that: The selecting a first number of addresses from the storage address list as candidate addresses according to a preset strategy includes: Obtain the hash value of each storage address in the storage address list to obtain several hash values; For each hash value, calculate the distance between the hash value and other hash values ​​one by one, and use the sum of the distances as the label value of the hash value; The hash values ​​are sorted in ascending order of the label values ​​to obtain a hash value sequence; and storage addresses corresponding to the first number of sequentially ordered hash values ​​with the smallest label values ​​in the hash value sequence are used as candidate addresses.

3. A data breakpoint downloading method according to claim 1, characterized in that: The step of caching the downloaded data to the first storage address further includes: Obtain the first-order information of the target file on the server; obtain the second-order information of the client, and determine whether the first-order information is consistent with the second-order information; If so, cache the downloaded data to the first storage address.

4. A data breakpoint downloading method according to claim 3, characterized in that: The step of caching the downloaded data to the first storage address includes: Obtaining storage format information of the target file on the server; The downloaded data is encapsulated using the storage format information, the downloaded data is cached to a first storage address, and a Range information reading interface for the downloaded data is provided to the file management system of the client.

5. A data breakpoint downloading method according to claim 4, characterized in that: The step of encapsulating the downloaded data using the storage format information includes: The downloaded data is encapsulated and the attribute information of the downloaded data is replaced with the storage format information.

6. A data breakpoint downloading method according to claim 4, characterized in that: The step of encapsulating the downloaded data using the storage format information includes: Establishing a virtual machine according to the storage environment information of the target file, and caching the downloaded data in the virtual machine; The location where the downloaded data is cached in the virtual machine is used as the first storage address.

7. A data breakpoint downloading method according to claim 1, characterized in that: Generating Range information according to the amount of downloaded data stored in the cache location includes: Obtaining a first hash value corresponding to the target data, and obtaining a stored second hash value from each first storage address, wherein the second hash value is a hash value for the target data obtained when the client receives the downloaded data from the server; Determine whether the second hash value contains data identical to the first hash value; If so, use the cache parsing method to parse the Range information of the downloaded data; If not, a new Session is created, and the step of receiving the remaining data and using the received remaining data as the download data is executed.

8. A data breakpoint download system, characterized in that: The system includes a client and a server, wherein: The client is used to execute the method according to any one of claims 1 to 7; The server is used to return the download data to the client according to the download instruction, and return the remaining data of the target file as the download data to the client according to the Range information.

Citation Information

Patent Citations

  • Method and system for loading resources based on multi-mode mobile terminal

    CN101635916A

  • File transfer method and device

    CN108040115A