Self-adaptive downloading method and device, electronic equipment and computer readable medium

Through the adaptive download method, it identifies the operating system and matches the download module, parses the download request, determines the download protocol, splits and encrypts the transmitted file fragments, solves the cross-platform and security problems of the existing download program, and achieves high efficiency and security. Multi-protocol downloads.

CN118694756APending Publication Date: 2024-09-24GUANGDONG TELEPOWER TELECOM TECH
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202410806005.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-21
Publication Date
2024-09-24

AI Technical Summary

Technical Problem

Existing download programs have limitations in function and application scope, cannot achieve seamless downloading between different devices or systems, and have low download efficiency and insufficient security, especially when facing files in multiple formats and sources. Installing multiple programs and lacking encryption technology makes data easily stolen or tampered with during transmission.

Method used

Adopting an adaptive download method, by identifying the operating system type of the user device, matching and loading the corresponding download module, parsing the download request, determining the target download protocol, establishing a communication connection, dividing the file into multiple fragments and transmitting it through multi-thread encryption, supporting Multi-threaded synchronous downloading and breakpoint resume downloading enable efficient file downloading across platforms and multiple protocols.

Benefits of technology

It enables download operations to be completed in any operating system, supports multiple download methods, improves download speed and efficiency, ensures the security and stability of data transmission, supports breakpoint resuming, and reduces user costs and complexity.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118694756A
    Figure CN118694756A
Patent Text Reader

Abstract

The invention provides a self-adaptive downloading method and device, electronic equipment and a computer readable medium, and the method comprises the steps: when user equipment initiates a downloading request through a self-adaptive downloading interface, recognizing a target operating system, matching and loading a target downloading module corresponding to the target operating system, analyzing the downloading request through the target downloading module, and transmitting the downloading request to the user equipment; determining a target downloading protocol used for downloading the target file, establishing a communication connection with a target data source according to the target downloading protocol, obtaining a target file data stream, processing the target file data stream according to the total size of the target downloading protocol and the target file data stream to obtain a plurality of file fragments, and sending the plurality of file fragments to the server; and encrypting and transmitting the plurality of file fragments to the user equipment through multiple threads, and splicing the plurality of file fragments according to the target downloading protocol to obtain a target file. According to the method, efficient, safe and cross-platform file downloading experience is realized through technical means such as intelligent system environment identification, multi-protocol support and multi-thread transmission.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of data downloading, and in particular to an adaptive downloading method, an adaptive downloading device, an electronic device and a computer-readable medium. Background Art

[0002] With the rapid development of the Internet, network downloading has become one of the main means for users to obtain network resources. In order to meet the needs of different users, a series of download programs have emerged on the market, such as Thunder, BitComet, eMule, ADM, etc. However, these traditional download programs have certain limitations in terms of function and application scope, such as only being able to adapt to specific operating system platforms, such as Windows, Linux or Android. This limits the possibility of users achieving a seamless download experience between different devices or systems, and increases the user's usage cost and complexity. In addition, these download programs usually only support specific download protocols. For example, some download programs can only download files based on the BitTorrent protocol, while others can only handle HTTP or FTP protocols. This limitation causes users to need to install multiple different download programs when facing files of multiple formats or sources, which reduces download efficiency and user experience. Furthermore, these traditional download programs are usually relatively single in download mode and do not support multi-threaded synchronous downloading. This means that when downloading large files, users need to wait for a long time, and the download process is easily interrupted due to network fluctuations, which greatly reduces the stability and efficiency of the download. In addition, during the transmission process, these download programs often lack the necessary encryption technology, which makes user data easy to be stolen or tampered with during the transmission process. Especially when dealing with sensitive information or important data, this security risk will bring great risks to users. Summary of the invention

[0003] In view of the above problems, the present invention is proposed to provide an adaptive downloading method and a corresponding adaptive downloading device, an electronic device and a computer-readable medium that overcome the above problems or at least partially solve the above problems.

[0004] The present invention discloses an adaptive downloading method, which comprises:

[0005] When the user device initiates a download request through the adaptive download interface, identifying the type of operating system currently running on the user device and determining the target operating system;

[0006] Matching and loading a target download module corresponding to the target operating system from a predefined download module library; each operating system type has a corresponding download module;

[0007] Parsing the download request by the target download module to determine the target download protocol to be used for downloading the target file;

[0008] Establishing a communication connection with a target data source according to the target download protocol, and acquiring a target file data stream;

[0009] Processing the target file data stream according to the target download protocol and the total size of the target file data stream to obtain multiple file fragments;

[0010] The multiple file fragments are encrypted and transmitted to the user device through multiple threads, and the multiple file fragments are spliced ​​according to the target download protocol to obtain the target file.

[0011] Optionally, when the user equipment initiates a download request through the adaptive download interface, identifying the type of operating system running on the user equipment and determining the target operating system includes:

[0012] For different operating systems, detect the unique system functions or system calls in the operating system;

[0013] Based on the detection results of unique system functions or system calls, the type of operating system currently running on the user device is identified and the target operating system is determined.

[0014] Optionally, parsing the download request by the target download module to determine a target download protocol to be used for downloading the target file includes:

[0015] Parsing the download request to obtain a download protocol type feature carried by the download request;

[0016] According to the download protocol type characteristics, a target download protocol to be used for downloading the target file is determined.

[0017] Optionally, encrypting and transmitting the multiple file segments to the user device through multiple threads includes:

[0018] S1, assigning multiple file fragments to multiple threads, where each thread is responsible for the encryption transmission task of one or more file fragments;

[0019] S2, each thread performs the encryption and transmission task of the assigned file segment;

[0020] S3, after a thread completes the assigned encryption transmission task, the thread that completes the encryption transmission task detects whether there are other threads that have not completed the assigned encryption transmission tasks;

[0021] S4, for the first thread detected that has not completed the assigned encryption transmission task, the thread that has completed the encryption transmission task obtains half of the remaining data of the unfinished file segment, and encrypts and transmits it to the user device;

[0022] S5, repeating steps S3 and S4 until all file segments are encrypted and transmitted to the user device.

[0023] Optionally, encrypting and transmitting the multiple file segments to the user device through multiple threads includes:

[0024] Before starting to download the multiple file segments, a temporary storage file and a metadata file are created locally; the temporary storage file is used to store the downloaded data of the unfinished file segments; the metadata file is used to record the file path, file size, download progress and download status of the file segments;

[0025] During the download process of a certain thread, the downloaded data of the assigned file fragment is saved in real time to a temporary storage file. When the download is interrupted due to a network abnormality, the temporary storage file is stopped from being updated, and the metadata file is updated in real time to record the current downloaded size and download status;

[0026] After the network is restored, the thread reads and compares the file path, file size, and download progress in the metadata file, and slices and downloads the incomplete file fragment data.

[0027] Optionally, the method further comprises:

[0028] When a thread interrupts downloading due to non-network abnormality, the thread stops updating the temporary storage file and updates the metadata file in real time to record the current downloaded size and download status;

[0029] Other threads that have completed downloading read and compare the file path, file size and download progress in the metadata file, slice and download the unfinished file segment data, and also update the temporary storage file and metadata file in real time during the download process.

[0030] Optionally, the file fragments respectively carry a download type identifier and a unique identifier, and the multiple file fragments are spliced ​​according to a target download protocol to obtain the target file, including:

[0031] Determine the corresponding target download protocol according to the download type symbol of each file segment;

[0032] The target file is obtained by splicing the multiple file fragments according to the splicing strategy of the corresponding target download protocol and the unique identifiers of the file fragments.

[0033] The present invention also discloses an adaptive downloading device, which comprises:

[0034] A system environment identification module, used to identify the type of operating system currently running on the user device and determine the target operating system when the user device initiates a download request through the adaptive download interface;

[0035] A download module matching module, used to match and load a target download module corresponding to the target operating system from a predefined download module library; each operating system type has a corresponding download module;

[0036] A download protocol determination module, used to parse the download request through the target download module and determine the target download protocol to be used to download the target file;

[0037] A target file data stream acquisition module, used to establish a communication connection with a target data source according to the target download protocol, and acquire the target file data stream;

[0038] A target file segmentation module, used for processing the target file data stream to obtain multiple file segments according to the target download protocol and the total size of the target file data stream;

[0039] The download splicing module is used to encrypt and transmit the multiple file fragments to the user device through multi-threading, and splice the multiple file fragments according to the target download protocol to obtain the target file.

[0040] Optionally, the system environment identification module includes:

[0041] The system environment detection submodule is used to detect the unique system functions or system calls in different operating systems;

[0042] The system environment identification submodule is used to identify the type of operating system currently running on the user device and determine the target operating system based on the detection results of the unique system function or system call.

[0043] Optionally, the download protocol determination module includes:

[0044] A download request parsing submodule, used to parse the download request to obtain the download protocol type characteristics carried by the download request;

[0045] The download protocol determination submodule is used to determine the target download protocol to be used for downloading the target file according to the download protocol type characteristics.

[0046] Optionally, the download splicing module includes:

[0047] An allocation submodule, used for allocating multiple file fragments to multiple threads, wherein each thread is responsible for the encryption transmission task of one or more file fragments;

[0048] The task execution submodule is used for each thread to execute the encrypted transmission task of the assigned file fragment;

[0049] The unfinished task thread detection submodule is used to detect whether there are other threads that have not completed the assigned encryption transmission tasks after a thread completes the assigned encryption transmission tasks;

[0050] The assisting execution task submodule is used to obtain half of the remaining data of the unfinished file segment for the first thread detected that has not completed the assigned encryption transmission task, and encrypt and transmit it to the user device;

[0051] The loop submodule repeatedly executes the unfinished task thread detection submodule and the assisting task execution submodule until all file segments are encrypted and transmitted to the user device.

[0052] Optionally, the download splicing module includes:

[0053] A download progress file creation submodule is used to create a temporary storage file and a metadata file locally before starting to download the multiple file fragments; the temporary storage file is used to store the downloaded data of the unfinished file fragments; the metadata file is used to record the file path, file size, download progress and download status of the file fragments;

[0054] The first download progress file update submodule is used to save the downloaded data of the allocated file fragments to a temporary storage file in real time during the download process of a certain thread. When the download is interrupted due to a network abnormality, the temporary storage file is stopped from being updated, and the metadata file is updated in real time to record the current downloaded size and download status;

[0055] The first download recovery submodule is used to thread read and compare the file path, file size and download progress in the metadata file after the network is restored, and slice and download the unfinished file segment data.

[0056] Optionally, the download splicing module further includes:

[0057] The second download progress file update submodule is used for, when a thread stops downloading due to non-network abnormality, the thread stops updating the temporary storage file, and updates the metadata file in real time to record the current downloaded size and download status;

[0058] The second download recovery submodule is used for other threads that have completed downloading to read and compare the file path, file size and download progress in the metadata file, slice and download the unfinished file fragment data, and also update the temporary storage file and metadata file in real time during the download process.

[0059] Optionally, the file fragments respectively carry a download type identifier and a unique identifier, and the download splicing module includes:

[0060] A download type identifier distinguishing submodule, used to determine the corresponding target download protocol according to the download type identifier of each file segment;

[0061] The splicing submodule is used to splice the multiple file fragments according to the splicing strategy of the corresponding target download protocol and the unique identifier of the file fragment to obtain the target file.

[0062] The present invention also discloses an electronic device, comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;

[0063] The memory is used to store computer programs;

[0064] The processor is used to implement the adaptive downloading method of the present invention when executing the program stored in the memory.

[0065] The present invention also discloses one or more computer-readable media, on which instructions are stored. When executed by one or more processors, the processors are enabled to execute the adaptive downloading method according to the present invention.

[0066] The present invention includes the following advantages:

[0067] The adaptive download method of the present invention, when the user device initiates a download request through the adaptive download interface, identifies the type of operating system currently running on the user device to determine the target operating system, matches and loads the target download module corresponding to the target operating system from the predefined download module library, parses the download request through the target download module, determines the target download protocol to be used to download the target file, establishes a communication connection with the target data source according to the target download protocol, and obtains the target file data stream, processes the target file data stream according to the target download protocol and the total size of the target file data stream to obtain multiple file fragments, encrypts and transmits the multiple file fragments to the user device through multi-threading, and splices the multiple file fragments according to the target download protocol to obtain the target file. The present invention designs an adaptive download interface, so that the user device can call the interface to complete the download operation in any system, not only multiple operating systems but also multiple download methods are integrated, and multi-threading technology and encryption technology are used to achieve a safe and fast download experience. Specifically, it can automatically identify the operating system and automatically identify the download method, and encrypt the transmission and start multi-threaded download to improve the download speed. If a network interruption occurs, temporary files can be saved, and when some threads download abnormally, other threads take over the download task, support breakpoint continuation, and splice file blocks after the transmission is completed. BRIEF DESCRIPTION OF THE DRAWINGS

[0068] Figure 1 is a flowchart of the steps of an adaptive downloading method provided by an embodiment of the present invention;

[0069] Figure 2 is a structural block diagram of an adaptive downloading device provided by an embodiment of the present invention;

[0070] Figure 3 is a block diagram of an electronic device provided by an embodiment of the present invention;

[0071] Figure 4 It is a schematic diagram of a computer-readable medium provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0072] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.

[0073] Reference Figure 1 , shows a flowchart of a step of an adaptive downloading method provided in an embodiment of the present invention, which may specifically include the following steps:

[0074] Step 101, when a user device initiates a download request through an adaptive download interface, identifying the type of operating system currently running on the user device and determining a target operating system;

[0075] Step 102, matching and loading a target download module corresponding to the target operating system from a predefined download module library; each operating system type has a corresponding download module;

[0076] Step 103, parsing the download request through the target download module to determine the target download protocol to be used for downloading the target file;

[0077] Step 104, establishing a communication connection with a target data source according to the target download protocol, and acquiring a target file data stream;

[0078] Step 105, processing the target file data stream according to the target download protocol and the total size of the target file data stream to obtain multiple file segments;

[0079] Step 106: encrypt and transmit the multiple file segments to the user device through multiple threads, and splice the multiple file segments according to the target download protocol to obtain the target file.

[0080] The adaptive download method of the present invention can realize efficient file downloading across platforms and with multi-protocol support. An adaptive download interface is designed, so that the user device can complete the download operation in any system by calling the interface to input a link or a file path, and interact through a unified API interface, thereby realizing the decoupling of functions and the reuse of codes, and facilitating expansion and maintenance. Specifically, when the user device initiates a download request through the adaptive download interface, the system will first identify the type of operating system currently running on the user device, and match the download modules that can be run under the system accordingly, and load the corresponding target download module from the predefined download module library. These download modules are optimized and packaged for codes that can run on operating systems such as Linux, Windows, Android, and macOS, respectively, to ensure the smooth operation of the code in different system environments, and provide users with a wide range of compatibility platforms.

[0081] Among them, the download module can include a P2P download module and a client-server download module. The P2P download module is one of the main download modes in the multi-mode multi-threaded technical architecture of the present invention. The module is responsible for identifying and processing download tasks such as BT and magnetic links, including parsing seed files, connecting to peer networks, downloading file blocks, etc., to achieve efficient distributed downloading. HTTP / HTTPS and FTP / SFTP protocols are used to process file transfer download functions. Users can directly download files by entering URL links, and the client-server download module is responsible for establishing connections with servers, sending download requests, receiving file data, and other operations.

[0082] The download request may carry information such as a link or file address. Subsequently, the target download module will parse the download request and determine which download protocol to use to download the target file. The download protocol may include BT download, magnetic link, HTTP / HTTPS, FTP / SFTP, etc. Once the target download protocol is determined, a communication connection with the target data source will be established, and the data stream of the target file will be obtained. Specifically, if the target download protocol is the BT download protocol, the BT download resource will be connected; if the target download protocol is the magnetic link download protocol, the magnetic link download resource will be connected; if the target download protocol is the HTTP / HTTPS protocol, the HTTP / HTTPS download resource will be connected; if the target download protocol is the FTP / SFTP protocol, the FTP / SFTP download resource will be connected.

[0083] Connecting to BT download resources and connecting to magnetic link download resources can be implemented through the P2P download module. Specifically, the P2P download module can call the bencode parser to parse the address file, extract the file information, Tracker information, and hash values ​​of each file contained therein, establish communication with the Tracker server to obtain the Peers list and download. Connecting to HTTP / HTTPS download resources and connecting to FTP / SFTP download resources can be implemented through the client-server download module. Specifically, conditional judgment can be added in the client-server download module. If it is HTTP protocol, the net / http package in the standard library of the Go language is used to establish an HTTP connection with the target file server; if it is HTTPS, the TLSClientConfig property in the Transport field is set before sending the http.Get request; if it is FTP, the ftp package in the standard library of the Go language is used; if it is SFTP, the third-party library github.com / pkg / sftp package is used. All methods use the adapter mode to unify the common interface name. The adapter mode allows the creation of an intermediate layer to unify the implementation of different interfaces into a common interface and implement the adapter according to specific needs. In the process of processing the response, the data returned by the server is encrypted and transmitted through the Xtkhttp communication protocol through the io.Copy function of the Go language.

[0084] After obtaining the target file data stream, the adaptive download interface can divide the target file into multiple file fragment download tasks according to the target download protocol and the total size of the target file. Specifically, the fragment download tasks of each thread can be averaged according to the total size of the target file data stream, and then the target file data stream can be divided into fragments according to the download method of the target download protocol. Each file fragment will be assigned a unique identifier and download type identifier, so that each fragment can be correctly identified and tracked even in asynchronous and different source downloads. During the transmission process, the file fragments are transmitted in a multi-threaded manner, and the Xtkhttp communication protocol is used to ensure the security and concealment of the transmission.

[0085] After the file segments are transferred, the adaptive download interface can merge the files according to the segment order of the original file and the merge strategy of the target download protocol. The entire adaptive download method achieves an efficient, secure, and cross-platform file download experience through technical means such as intelligent recognition of system environment, multi-protocol support, and multi-threaded transmission.

[0086] In one embodiment of the present invention, when a user device initiates a download request through an adaptive download interface, identifying the type of operating system running on the user device and determining a target operating system includes:

[0087] For different operating systems, detect the unique system functions or system calls in the operating system;

[0088] Based on the detection results of unique system functions or system calls, the type of operating system currently running on the user device is identified and the target operating system is determined.

[0089] When the user device initiates a download request through the adaptive download interface, the adaptive download interface can distinguish and identify the system environment based on some unique system functions, etc. Specifically, for different operating systems, the unique system functions or system calls in the operating system are detected, and the type of operating system currently running on the user device is identified based on the detection results of the unique system functions or system calls, and the target operating system is determined. Taking Windows and Linux systems as examples, the getpid() system call in the Linux system and the GetCurrentProcessId() function in the Windows system are similar in function, but the calling methods are different. The software can determine the running operating system by detecting the return values ​​of these function calls. If the GetCurrentProcessId() system call in the Linux system is matched, the download module that can be run under the system will be called. If the getpid() function call in the Windows system is matched, the download module that can be run under the system will be called.

[0090] In one embodiment of the present invention, the target download module parses the download request and determines the target download protocol to be used for downloading the target file, including:

[0091] Parsing the download request to obtain a download protocol type feature carried by the download request;

[0092] According to the download protocol type characteristics, a target download protocol to be used for downloading the target file is determined.

[0093] In an embodiment of the present invention, the target download module can parse the download request and identify the target communication protocol to be used to download the target file: specifically, the target download module can identify the characteristics of various download protocol types, such as the ".torrent" file of BT (BitTorrent), the "Magnet:" prefix of the magnetic link (Magnet URI), the "http: / / " or "https: / / " prefix of HTTP / HTTPS, and the specific format of protocols such as FTP / SFTP. By accurately detecting these characteristics, the target download module can import the corresponding download method and prepare for the subsequent file download process. Such a design enables the download module to flexibly handle different types of download requests, whether it is a peer-to-peer network download based on BitTorrent, or a download through a traditional HTTP / HTTPS or FTP / SFTP server, providing users with more convenient and diverse download options.

[0094] In one embodiment of the present invention, encrypting and transmitting the plurality of file segments to the user device through multiple threads includes:

[0095] S1, assigning multiple file fragments to multiple threads, where each thread is responsible for the encryption transmission task of one or more file fragments;

[0096] S2, each thread performs the encryption and transmission task of the assigned file segment;

[0097] S3, after a thread completes the assigned encryption transmission task, the thread that completes the encryption transmission task detects whether there are other threads that have not completed the assigned encryption transmission tasks;

[0098] S4, for the first thread detected that has not completed the assigned encryption transmission task, the thread that has completed the encryption transmission task obtains half of the remaining data of the unfinished file segment, and encrypts and transmits it to the user device;

[0099] S5, repeating steps S3 and S4 until all file segments are encrypted and transmitted to the user device.

[0100] In an embodiment of the present invention, in order to achieve efficient file transfer, a multi-threaded encryption transmission strategy is adopted, which is implemented through coroutines in the Go language. Specifically, the target file is divided into multiple file fragments, and these fragments are assigned to multiple coroutines for concurrent processing. Each coroutine is responsible for the encryption transmission task of one or more file fragments. Once a coroutine completes its assigned encryption transmission task, it will not end immediately, but will check the progress of other coroutines. If it is found that a coroutine has not completed its task, the coroutine will take over and help transmit half of the remaining data. This collaborative mechanism ensures that the overall file transfer speed can be maintained at a high level even in the presence of network delays or fluctuations. It not only greatly improves the speed and efficiency of file downloads, but also ensures the integrity and security of data during transmission.

[0101] In one embodiment of the present invention, encrypting and transmitting the plurality of file segments to the user device through multiple threads includes:

[0102] Before starting to download the multiple file segments, a temporary storage file and a metadata file are created locally; the temporary storage file is used to store the downloaded data of the unfinished file segments; the metadata file is used to record the file path, file size, download progress and download status of the file segments;

[0103] During the download process of a certain thread, the downloaded data of the assigned file fragment is saved in real time to a temporary storage file. When the download is interrupted due to a network abnormality, the temporary storage file is stopped from being updated, and the metadata file is updated in real time to record the current downloaded size and download status;

[0104] After the network is restored, the thread reads and compares the file path, file size, and download progress in the metadata file, and slices and downloads the incomplete file fragment data.

[0105] The embodiment of the present invention creates a temporary storage file and a metadata file before starting the download. The temporary storage file can be used to store the data of the downloaded part of the file fragment that has not been downloaded completely, and the metadata file can be used to record the file information, download progress and status of the file fragment, and specifically can include the following information: file path, file size, downloaded size, download status (for example: completed, downloading, download failed, etc.).

[0106] During the download process, each thread will update the temporary storage file in real time, that is, save the downloaded data of the assigned file fragment to the temporary storage file in real time. If a thread interrupts the download due to network problems during the download process, the thread stops updating the temporary storage file and updates the metadata file in real time to record the current downloaded size and download status. After the network is restored, the download is resumed, and the temporary file continues to be updated in real time during the download process to ensure that the size recorded in the metadata file is consistent with the current file size actually downloaded. The specific implementation logic is: if the transmission process of the thread responsible for downloading fragments a and b is interrupted due to network reasons (judgment error type: network abnormality), the file size, downloaded size, download status and other information are recorded in the metadata file and the temporary file is suspended. After the network is restored, the progress information of the a fragment data and the download task information of the file fragment are compared, and the remaining data of the a fragment is downloaded in slices. By recording the download progress and file task information, it is possible to avoid repeated downloading of the completed part, effectively improve the user's download experience, and save the user's time and traffic.

[0107] In one embodiment of the present invention, the method further comprises:

[0108] When a thread interrupts downloading due to non-network abnormality, the thread stops updating the temporary storage file and updates the metadata file in real time to record the current downloaded size and download status;

[0109] Other threads that have completed downloading read and compare the file path, file size and download progress in the metadata file, slice and download the unfinished file segment data, and also update the temporary storage file and metadata file in real time during the download process.

[0110] In an embodiment of the present invention, if a problem occurs in a thread or connection during the download process, other threads or connections can continue to work, and the overall download process will not be interrupted, thereby improving the reliability of the download. The specific implementation logic is: if the transmission process of the thread responsible for downloading segment a is abnormally interrupted (non-network abnormality), the thread that has completed the download of segment b copies the data of segment a, and by comparing the progress information of the data of segment a and the information of the task, the remaining data of segment a is downloaded in slices. This method ensures that the overall download process will not be interrupted, ensures the continuity and integrity of the download task, improves the reliability of the download, and by recording the download progress and the download task information of the file fragment, it is possible to avoid repeated downloading of the completed part, effectively improve the user's download experience, and save the user's time and traffic. In addition, in the process of downloading the remaining data of segment a, the thread responsible for segment b also updates the temporary storage file and metadata file in real time, so that when the thread responsible for segment b also encounters these abnormalities, it can resume the download after recovery.

[0111] In one embodiment of the present invention, the file fragments respectively carry a download type identifier and a unique identifier, and the multiple file fragments are spliced ​​according to the target download protocol to obtain the target file, including:

[0112] Determine the corresponding target download protocol according to the download type symbol of each file segment;

[0113] The target file is obtained by splicing the multiple file fragments according to the splicing strategy of the corresponding target download protocol and the unique identifiers of the file fragments.

[0114] After all file segments are downloaded, the file merging work can be completed according to the segment sequence of the original file. Specifically, after all segments are downloaded, the download type symbol of each segment is identified, and the target file merging work is completed using the splicing strategy of the target download protocol corresponding to the download type symbol.

[0115] Specifically, the splicing strategy for each download method is as follows: (1) The fragment splicing strategy of BT download method: BT download is a P2P download method. The file is divided into multiple blocks and provided by different peer nodes. When merging fragments, it is first necessary to determine the order and source of each block based on the information in the seed file. Each block has a hash value to verify the integrity of the block. When merging, it is necessary to check the hash value of each block one by one to ensure the correctness of the block. Finally, according to the determined block order, the content of each block is merged into the final file one by one. (2) The fragment splicing strategy of HTTP / HTTPS download method: When merging fragments, the starting position and end position of the downloaded file are specified through HTTP Range request to achieve fragment merging. (3) The fragment splicing strategy of FTP / SFTP download method: FTP / SFTP download method may require additional login authentication processing. Therefore, before merging fragments, it is necessary to ensure the validity of the login authentication, and then complete the splicing according to the starting position and end position of the downloaded file.

[0116] The adaptive download method of the present invention, when the user device initiates a download request through the adaptive download interface, identifies the type of operating system currently running on the user device to determine the target operating system, matches and loads the target download module corresponding to the target operating system from the predefined download module library, parses the download request through the target download module, determines the target download protocol to be used to download the target file, establishes a communication connection with the target data source according to the target download protocol, and obtains the target file data stream, processes the target file data stream according to the target download protocol and the total size of the target file data stream to obtain multiple file fragments, encrypts and transmits the multiple file fragments to the user device through multi-threading, and splices the multiple file fragments according to the target download protocol to obtain the target file. The present invention designs an adaptive download interface, so that the user device can call the interface to complete the download operation in any system, not only multiple operating systems but also multiple download methods are integrated, and multi-threading technology and encryption technology are used to achieve a safe and fast download experience. Specifically, it can automatically identify the operating system and automatically identify the download method, and encrypt the transmission and start multi-threaded download to improve the download speed. If a network interruption occurs, temporary files can be saved, and when some threads download abnormally, other threads take over the download task, support breakpoint continuation, and splice file blocks after the transmission is completed.

[0117] It should be noted that, for the sake of simplicity, the method embodiments are described as a series of action combinations, but those skilled in the art should be aware that the embodiments of the present invention are not limited by the order of the actions described, because according to the embodiments of the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.

[0118] Reference Figure 2 , shows a structural block diagram of an adaptive downloading device provided in an embodiment of the present invention, which may specifically include the following modules:

[0119] The system environment identification module 201 is used to identify the type of operating system currently running on the user equipment and determine the target operating system when the user equipment initiates a download request through the adaptive download interface;

[0120] A download module matching module 202, used to match and load a target download module corresponding to the target operating system from a predefined download module library; each operating system type has a corresponding download module;

[0121] A download protocol determination module 203, configured to parse the download request through the target download module and determine a target download protocol to be used for downloading the target file;

[0122] The target file data stream acquisition module 204 is used to establish a communication connection with the target data source according to the target download protocol and acquire the target file data stream;

[0123] A target file segmentation module 205 is used to process the target file data stream according to the target download protocol and the total size of the target file data stream to obtain multiple file segments;

[0124] The download splicing module 206 is used to encrypt and transmit the multiple file segments to the user device through multiple threads, and splice the multiple file segments according to the target download protocol to obtain the target file.

[0125] Optionally, the system environment identification module includes:

[0126] The system environment detection submodule is used to detect the unique system functions or system calls in different operating systems;

[0127] The system environment identification submodule is used to identify the type of operating system currently running on the user device and determine the target operating system based on the detection results of the unique system function or system call.

[0128] Optionally, the download protocol determination module includes:

[0129] A download request parsing submodule, used to parse the download request to obtain the download protocol type characteristics carried by the download request;

[0130] The download protocol determination submodule is used to determine the target download protocol to be used for downloading the target file according to the download protocol type characteristics.

[0131] Optionally, the download splicing module includes:

[0132] An allocation submodule, used for allocating multiple file fragments to multiple threads, wherein each thread is responsible for the encryption transmission task of one or more file fragments;

[0133] The task execution submodule is used for each thread to execute the encrypted transmission task of the assigned file fragment;

[0134] The unfinished task thread detection submodule is used to detect whether there are other threads that have not completed the assigned encryption transmission tasks after a thread completes the assigned encryption transmission tasks;

[0135] The assisting execution task submodule is used to obtain half of the remaining data of the unfinished file segment for the first thread detected that has not completed the assigned encryption transmission task, and encrypt and transmit it to the user device;

[0136] The loop submodule repeatedly executes the unfinished task thread detection submodule and the assisting task execution submodule until all file segments are encrypted and transmitted to the user device.

[0137] Optionally, the download splicing module includes:

[0138] A download progress file creation submodule is used to create a temporary storage file and a metadata file locally before starting to download the multiple file fragments; the temporary storage file is used to store the downloaded data of the unfinished file fragments; the metadata file is used to record the file path, file size, download progress and download status of the file fragments;

[0139] The first download progress file update submodule is used to save the downloaded data of the allocated file fragments to a temporary storage file in real time during the download process of a certain thread. When the download is interrupted due to a network abnormality, the temporary storage file is stopped from being updated, and the metadata file is updated in real time to record the current downloaded size and download status;

[0140] The first download recovery submodule is used to thread read and compare the file path, file size and download progress in the metadata file after the network is restored, and slice and download the unfinished file segment data.

[0141] Optionally, the download splicing module further includes:

[0142] The second download progress file update submodule is used for, when a thread stops downloading due to non-network abnormality, the thread stops updating the temporary storage file, and updates the metadata file in real time to record the current downloaded size and download status;

[0143] The second download recovery submodule is used for other threads that have completed downloading to read and compare the file path, file size and download progress in the metadata file, slice and download the unfinished file fragment data, and also update the temporary storage file and metadata file in real time during the download process.

[0144] Optionally, the file fragments respectively carry a download type identifier and a unique identifier, and the download splicing module includes:

[0145] A download type identifier distinguishing submodule, used to determine the corresponding target download protocol according to the download type identifier of each file segment;

[0146] The splicing submodule is used to splice the multiple file fragments according to the splicing strategy of the corresponding target download protocol and the unique identifier of the file fragment to obtain the target file.

[0147] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0148] In addition, an embodiment of the present invention further provides an electronic device, such as Figure 3 As shown, it includes a processor 301, a communication interface 302, a memory 303 and a communication bus 304, wherein the processor 301, the communication interface 302, and the memory 303 communicate with each other through the communication bus 304.

[0149] Memory 303, used for storing computer programs;

[0150] The processor 301 is used to implement the adaptive downloading method described in the above embodiment when executing the program stored in the memory 303.

[0151] The communication bus mentioned in the above terminal can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.

[0152] The communication interface is used for communication between the above terminal and other devices.

[0153] The memory may include a random access memory (RAM) or a non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.

[0154] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.

[0155] like Figure 4 As shown, in another embodiment provided by the present invention, a computer-readable storage medium 401 is further provided, in which instructions are stored. When the computer-readable storage medium is run on a computer, the computer executes the adaptive downloading method described in the above embodiment.

[0156] In another embodiment of the present invention, a computer program product including instructions is provided. When the computer program product is run on a computer, the computer executes the adaptive downloading method described in the above embodiment.

[0157] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented by software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present invention is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from one website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or data center that includes one or more available media integrated. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk Solid State Disk (SSD)), etc.

[0158] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0159] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0160] The above description is only a preferred embodiment of the present invention and is not intended to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.

Claims

1. An adaptive downloading method, characterized in that: The method comprises: When the user device initiates a download request through the adaptive download interface, identifying the type of operating system currently running on the user device and determining the target operating system; Matching and loading a target download module corresponding to the target operating system from a predefined download module library; each operating system type has a corresponding download module; Parsing the download request by the target download module to determine the target download protocol to be used for downloading the target file; Establishing a communication connection with a target data source according to the target download protocol, and acquiring a target file data stream; Processing the target file data stream according to the target download protocol and the total size of the target file data stream to obtain multiple file fragments; The multiple file fragments are encrypted and transmitted to the user device through multiple threads, and the multiple file fragments are spliced ​​according to the target download protocol to obtain the target file.

2. The method according to claim 1, characterized in that When the user device initiates a download request through the adaptive download interface, the type of operating system running on the user device is identified and the target operating system is determined, including: For different operating systems, detect the unique system functions or system calls in the operating system; Based on the detection results of unique system functions or system calls, the type of operating system currently running on the user device is identified and the target operating system is determined.

3. The method according to claim 1, characterized in that Parsing the download request by the target download module to determine the target download protocol to be used for downloading the target file includes: Parsing the download request to obtain a download protocol type feature carried by the download request; According to the download protocol type characteristics, a target download protocol to be used for downloading the target file is determined.

4. The method according to claim 1, characterized in that: The method encrypts and transmits the plurality of file segments to the user device through multiple threads, comprising: S1, assigning multiple file fragments to multiple threads, where each thread is responsible for the encryption transmission task of one or more file fragments; S2, each thread performs the encryption and transmission task of the assigned file segment; S3, after a thread completes the assigned encryption transmission task, the thread that completes the encryption transmission task detects whether there are other threads that have not completed the assigned encryption transmission tasks; S4, for the first thread detected that has not completed the assigned encryption transmission task, the thread that has completed the encryption transmission task obtains half of the remaining data of the unfinished file segment, and encrypts and transmits it to the user device; S5, repeating steps S3 and S4 until all file segments are encrypted and transmitted to the user device.

5. The method according to claim 1, characterized in that The method encrypts and transmits the plurality of file segments to the user device through multiple threads, comprising: Before starting to download the multiple file segments, a temporary storage file and a metadata file are created locally; the temporary storage file is used to store the downloaded data of the unfinished file segments; the metadata file is used to record the file path, file size, download progress and download status of the file segments; During the download process of a certain thread, the downloaded data of the assigned file fragment is saved in real time to a temporary storage file. When the download is interrupted due to a network abnormality, the temporary storage file is stopped from being updated, and the metadata file is updated in real time to record the current downloaded size and download status; After the network is restored, the thread reads and compares the file path, file size, and download progress in the metadata file, and slices and downloads the incomplete file fragment data.

6. The method according to claim 5, characterized in that The method further comprises: When a thread interrupts downloading due to non-network abnormality, the thread stops updating the temporary storage file and updates the metadata file in real time to record the current downloaded size and download status; Other threads that have completed downloading read and compare the file path, file size and download progress in the metadata file, slice and download the unfinished file segment data, and also update the temporary storage file and metadata file in real time during the download process.

7. The method according to claim 1, characterized in that The file fragments respectively carry a download type identifier and a unique identifier, and the multiple file fragments are spliced ​​according to the target download protocol to obtain the target file, including: Determine the corresponding target download protocol according to the download type symbol of each file segment; The target file is obtained by splicing the multiple file fragments according to the splicing strategy of the corresponding target download protocol and the unique identifiers of the file fragments.

8. An adaptive downloading device, characterized in that: The device comprises: A system environment identification module, used to identify the type of operating system currently running on the user device and determine the target operating system when the user device initiates a download request through the adaptive download interface; A download module matching module, used to match and load a target download module corresponding to the target operating system from a predefined download module library; each operating system type has a corresponding download module; A download protocol determination module, used to parse the download request through the target download module and determine the target download protocol to be used to download the target file; A target file data stream acquisition module, used to establish a communication connection with a target data source according to the target download protocol, and acquire the target file data stream; A target file segmentation module, used for processing the target file data stream to obtain multiple file segments according to the target download protocol and the total size of the target file data stream; The download splicing module is used to encrypt and transmit the multiple file fragments to the user device through multi-threading, and splice the multiple file fragments according to the target download protocol to obtain the target file.

9. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; The memory is used to store computer programs; The processor is used to implement the adaptive downloading method according to any one of claims 1 to 7 when executing the program stored in the memory.

10. One or more computer-readable media having instructions stored thereon, which, when executed by one or more processors, enable the processors to perform the adaptive downloading method according to any one of claims 1 to 7.

Citation Information

Cited By

  • File interaction method and system and server

    CN119316413A