File download methods, devices, equipment, and storage media

By using multiple file download instances and an optimistic locking mechanism, the problem of file download interruption was solved, thus achieving stability and integrity in file downloads.

CN119697171BActive Publication Date: 2025-11-14CHINA MERCHANTS BANK
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411602513.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-11-11
Publication Date
2025-11-14
Estimated Expiration
2044-11-11

AI Technical Summary

Technical Problem

Existing file download solutions rely on a single instance, which makes file downloads prone to interruption and failure when the instance fails.

Method used

By periodically retrieving the file segment tasks to be downloaded from the file segment information table through several file download instances, and using optimistic locking to lock the tasks, the target download start and end positions are determined. Download is then performed based on these positions, and finally, a complete download file is generated.

Benefits of technology

Even if a single instance fails, multiple instances can continue the download task, ensuring the integrity and success rate of file downloads and reducing reliance on network speed and stability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119697171B_ABST
    Figure CN119697171B_ABST
Patent Text Reader

Abstract

This application discloses a file download method, apparatus, device, and storage medium, relating to the field of file processing technology. The method includes: periodically retrieving downloadable file segments from a file segment information table corresponding to the file to be downloaded through several file download instances; locking the downloadable file segments using optimistic locking; upon successful locking, determining the target download start position and target download end position of the downloadable file segments based on the current segment position field in the file segment information table; downloading the downloadable file segments based on the target download start position and target download end position; and generating a complete downloaded file based on the completed downloadable file segments. By applying the above technical solution, the technical problem in existing file download schemes where file download is interrupted due to a failure of a file download instance, leading to file download failure, is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of document processing technology, and in particular to document download methods, apparatus, devices and storage media. Background Technology

[0002] With the rapid development of internet technology, it has provided great convenience to people's lives, allowing them to request and download various documents, videos, audio, and other data. Currently, file downloads typically involve a program downloading the file from beginning to end, or an application instance downloading the file in segments. However, because file downloads rely on a single instance, if that instance malfunctions, the download will be interrupted, resulting in download failure. Summary of the Invention

[0003] The main objective of this application is to provide a file download method, apparatus, device, and storage medium, which aims to solve the technical problem that file download schemes in the prior art will interrupt file download when a file download instance fails, resulting in file download failure.

[0004] To achieve the above objectives, this application proposes a file download method, which includes:

[0005] The download task is obtained periodically from the file segment information table corresponding to the file to be downloaded by several file download instances;

[0006] The downloadable fragment tasks are locked using optimistic locking;

[0007] Upon successful locking, the target download start position and target download end position of the task to be downloaded are determined based on the current segment position field in the file segment information table.

[0008] The download segment task is performed based on the target download start position and the target download end position;

[0009] A complete download file is generated based on the completed download segments.

[0010] In one embodiment, before the step of periodically obtaining the downloadable segment task from the file segment information table corresponding to the file to be downloaded through several file download instances, the method further includes:

[0011] Determine the file segmentation method corresponding to the file to be downloaded based on the file segmentation configuration table;

[0012] If the file is split into chunks by size, the file size of the file to be downloaded is determined based on the file information table and the file download toolkit.

[0013] Based on the file segmentation configuration table and the file size, the file to be downloaded is segmented using a preset file segmentation algorithm to obtain several file segmentation tasks;

[0014] The file sharding task is stored in the file sharding information table, and the file execution status corresponding to the file sharding task in the file sharding information table is initialized.

[0015] In one embodiment, the step of splitting the file to be downloaded into several file fragment tasks based on the file fragment configuration table and the file size using a preset file fragmentation algorithm includes:

[0016] The target chunk size corresponding to the file to be downloaded is determined according to the file chunk configuration table.

[0017] The total number of fragments is determined based on the target fragment size and the file size;

[0018] The file to be downloaded is split into several file splitting tasks based on the total number of splits using a preset file splitting algorithm.

[0019] In one embodiment, the step of splitting the file to be downloaded into several file fragment tasks based on the total number of fragments using a preset file fragmentation algorithm includes:

[0020] The fragment number corresponding to each file fragment in the file to be downloaded is determined based on the total number of fragments using a preset file fragmentation algorithm.

[0021] The download start and end positions of each file segment are determined based on the segment number and the target segment size.

[0022] The current position of each file fragment is determined based on the download start position and the download start position offset;

[0023] The fragment field information of each file fragment is generated based on the fragment number, the current fragment position, the download start position, and the download end position;

[0024] The file to be downloaded is split into several file splitting tasks based on the splitting field information.

[0025] In one embodiment, after the step of determining the file fragmentation method corresponding to the file to be downloaded based on the file fragmentation configuration table, the method further includes:

[0026] If the file is split into segments by line, then the total number of lines in the file to be downloaded is determined.

[0027] The target number of rows for the file to be downloaded is determined based on the file fragment configuration table.

[0028] The total number of shards is determined based on the target shard line count and the total number of lines in the file.

[0029] In one embodiment, after the step of downloading the task to be downloaded based on the target download start position and the target download end position, the method further includes:

[0030] When the download of the segment task is completed, the task execution status corresponding to the download segment task is updated to the execution completion status;

[0031] When the status update is complete, the current fragment position field is updated based on the target fragment size corresponding to the file to be downloaded;

[0032] When the field update is complete, return to the step of determining the target download start position and target download end position of the task to be downloaded based on the current fragment position field in the file fragment information table.

[0033] In one embodiment, the method further includes:

[0034] Real-time detection of whether there are target fragment tasks in the files to be downloaded whose execution status is failed;

[0035] If it exists, the task execution state is switched to the executing state, and the execution interruption position and execution end position of the target fragment task are determined;

[0036] The target fragment task continues to be downloaded based on the execution interruption position and the execution end position.

[0037] Furthermore, to achieve the above objectives, this application also proposes a file downloading device, the device comprising:

[0038] The task acquisition module is used to periodically obtain downloadable segment tasks from the file segment information table corresponding to the file to be downloaded through several file download instances;

[0039] The task locking module is used to lock the downloadable task segments using optimistic locking;

[0040] The download location determination module is used to determine the target download start position and target download end position of the task to be downloaded based on the current segment position field in the file segment information table when the lock is successful;

[0041] The task download module is used to download the segmented task to be downloaded based on the target download start position and the target download end position;

[0042] The download file generation module is used to generate a complete download file based on the completed download segments.

[0043] In addition, to achieve the above objectives, this application also proposes a file download device, the device comprising: a memory, a processor, and a computer program stored on the memory and executable on the processor, the computer program being configured to implement the steps of the file download method as described above.

[0044] In addition, to achieve the above objectives, this application also proposes a storage medium, which is a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, it implements the steps of the file download method described above.

[0045] This application provides a file download method. The method involves periodically retrieving downloadable file chunks from a file chunk information table corresponding to the file to be downloaded using several file download instances; locking the downloadable file chunks using optimistic locking; upon successful locking, determining the target download start position and target download end position of the downloadable file chunk based on the current chunk position field in the file chunk information table; downloading the downloadable file chunk based on the target download start position and target download end position; and generating a complete download file based on the completed downloadable file chunks. Compared to existing file download schemes that rely on a single instance, which can lead to download interruption when that instance fails, this invention obtains downloadable file chunks from several file download instances, downloads the downloadable file chunk based on its target download start position and target download end position, and finally generates a complete download file based on the completed downloadable file chunks. This solves the technical problem in existing file download schemes where download interruption occurs when a file download instance fails, leading to file download failure. Attached Figure Description

[0046] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

[0047] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0048] Figure 1 This is a flowchart illustrating an embodiment of the document download method for this application.

[0049] Figure 2 This is a diagram illustrating the file fragmentation information table used in the document download method of this application.

[0050] Figure 3 This is a flowchart illustrating the process of generating the fragment tasks to be downloaded in the document download method of this application.

[0051] Figure 4 This is a flowchart illustrating Embodiment 2 of the document download method for this application.

[0052] Figure 5 This is a diagram illustrating the file fragmentation configuration table in the document download method of this application.

[0053] Figure 6 This is a flowchart illustrating Embodiment 3 of the document download method for this application.

[0054] Figure 7 This is a flowchart illustrating the file download process in the document download method of this application.

[0055] Figure 8 This is a schematic diagram of the module structure of the file download device according to an embodiment of this application;

[0056] Figure 9 This is a schematic diagram of the device structure of the hardware operating environment involved in the file download method in this application embodiment.

[0057] The purpose, features, and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation

[0058] It should be understood that the specific embodiments described herein are merely illustrative of the technical solutions of this application and are not intended to limit this application.

[0059] To better understand the technical solution of this application, a detailed description will be provided below in conjunction with the accompanying drawings and specific implementation methods.

[0060] The main solution of this application embodiment is as follows: A number of file download instances periodically retrieve the file segment task to be downloaded from the file segment information table corresponding to the file to be downloaded; the file segment task to be downloaded is locked using optimistic locking; when the locking is successful, the target download start position and target download end position of the file segment task to be downloaded are determined according to the current segment position field in the file segment information table; the file segment task to be downloaded is downloaded based on the target download start position and target download end position.

[0061] Existing file download solutions typically download a file in segments using an application instance. However, since this method relies on a single instance, if that instance fails, the file download will be interrupted, resulting in download failure.

[0062] This application provides a solution that allows the acquisition of downloadable file segments through several file download instances, and the download of the downloadable file segments based on the target start and end positions of the downloadable file segments. Finally, a complete download file is generated based on the downloaded downloadable file segments, thereby solving the technical problem in the prior art where file downloading is interrupted and file downloading fails when a file download instance fails.

[0063] It should be noted that the executing entity in this embodiment can be a computing service device with data processing, network communication, and program execution functions, such as a tablet computer, personal computer, or mobile phone, or an electronic device or file download device capable of performing the above functions. The following description uses a file download device (hereinafter referred to as the device) as an example to illustrate this embodiment and the subsequent embodiments.

[0064] Based on this, embodiments of this application provide a file download method, referring to... Figure 1 , Figure 1 This is a flowchart illustrating the first embodiment of the document download method of this application.

[0065] In this embodiment, the file download method includes steps S10 to S50:

[0066] Step S10: Periodically retrieve the file segment tasks to be downloaded from the file segment information table corresponding to the file to be downloaded through several file download instances.

[0067] It should be understood that the above file download example can be a specific operation or code example of obtaining files (such as documents, pictures, videos, audio, application installation packages, etc.) from the network or other storage media to the local computer or device through some means (such as programming, using software tools or browsers, etc.). This embodiment does not limit the specific content of the file download example.

[0068] It is understood that the above file fragment information table can be a table used to configure the fragment information of the file to be downloaded. In this embodiment, the file to be downloaded can be a TXT format file. Each row corresponds to a data record in the table and also corresponds to a Java object. Each row can be separated by the "|" character. In this solution, the file data can be downloaded periodically (the content of the file is different each time it is downloaded) and each row can be parsed into a Java object and then stored in the database.

[0069] In this embodiment, refer to Figure 2 , Figure 2 This is a diagram illustrating the file fragmentation information table used in the file download method of this application. The fields and descriptions of the file fragmentation information table T_FILE_SHARDING_INFO are as follows: Figure 2 As shown, the fields in the file fragment information table may include: file ID (FILE_INFO_ID), fragmentation mode SHARDING_MODE, fragment sequence number SHARDING_SEQUENCE, planned target start download position START_POSITION, planned target end download position END_POSITION, target fragment size DEST_SIZE, offset from the target start download position START_OFFSET (usually 0), offset from the target end position END_OFFSET, actual fragment size ACTUAL_SIZE, current position CURRENT_POSITION, and file execution status EXEC_STATUS, where 0 indicates not executed, 1 indicates execution completed, 2 indicates execution in progress, and 9 indicates execution failed. In practical applications, a file to be downloaded can be divided into multiple fragments, each fragment corresponding to a fragment sequence number SHARDING_SEQUENCE; the planned target start download position START_POSITION can be a field value generated based on the file size and file configuration, but the program actually starts downloading from START_POSITION + START_OFFSET; the planned target end download position END_POSITION can be a field value generated based on the file size and file configuration, but the program actually ends downloading from END_POSITION + END_OFFSET; the target fragment size DEST_SIZE can be the fragment size configured in the configuration file; the actual fragment size ACTUAL_SIZE = (END_POSITION + END_OFFSET) - (START_POSITION + START_OFFSET); and the current position CURRENT_POSITION can be the current download position.

[0070] It should be noted that the above-mentioned file segment tasks to be downloaded can be file segment tasks in the file to be downloaded that have not been executed or have failed to execute. These file segment tasks can be tasks used to download file fragments from the file to be downloaded. In practical applications, refer to... Figure 3 , Figure 3 This is a flowchart illustrating the process of generating the downloadable fragments in the document download method of this application. For example... Figure 3As shown, to generate a file sharding task, you can first read the file sharding information table to obtain the file information, then connect to the file server to obtain the file size, and read the file sharding configuration table to configure the file sharding information. Finally, you can generate and store the file sharding information.

[0071] Step S20: Lock the downloadable fragment task using optimistic locking.

[0072] It should be noted that the optimistic locking described above can be a concurrency control mechanism. It assumes that concurrent operations will not conflict, so no lock is acquired before the operation. Upon completion of the operation, a check for conflicts is performed; if conflicts are found, appropriate handling is implemented (such as retrying or throwing an exception). In this embodiment, optimistic locking can be used to process each file segment task, enabling multiple instances to concurrently process each file segment. Even if one instance fails, another instance can take over its task. Furthermore, there is a retry mechanism even if the download process is interrupted, resuming download processing from the point of interruption for each segment. Simultaneously, the number of application instances can be horizontally scaled to improve file download efficiency without overly relying on network speed and stability, thus enabling stable and efficient downloads of extremely large files.

[0073] It should be understood that in this embodiment, the device can scan the file segment information table every 5 seconds through a multi-instance application to extract the unexecuted or failed download segment tasks in the file segment information table, and use optimistic locking to lock the task so that other application instances cannot obtain or modify the task.

[0074] Step S30: Upon successful locking, determine the target download start position and target download end position of the task to be downloaded based on the current fragment position field in the file fragment information table.

[0075] It is understandable that the aforementioned current fragment position field can be the field in the file fragment information table used to indicate the current download position of the file to be downloaded, that is, the current position field CURRENT_POSITION in the file fragment information table.

[0076] It should be noted that the target download start position can be the position where the download of the segment to be downloaded begins. In this embodiment, the program can start downloading the segment to be downloaded from START_POSITION+START_OFFSET. The target download end position can be the position where the download of the segment to be downloaded ends. In this embodiment, the program can end downloading the segment to be downloaded from END_POSITION+END_OFFSET.

[0077] Step S40: Download the segment task to be downloaded based on the target download start position and the target download end position.

[0078] In this embodiment, the device can determine the start position of file download based on the CURRENT_POSITION field of the file segmentation configuration table, and determine the end position of file download based on END_POSITION+END_OFFSET. Finally, the file is downloaded according to the file segmentation download method, and then the application processes the downloaded data (for example, for TXT files, each line of data downloaded is converted into a Java object and then stored in the database).

[0079] Step S50: Generate a complete download file based on the completed download segments.

[0080] In practical applications, after all the downloadable fragments of the file to be downloaded have been downloaded, the downloaded data can be merged to obtain a single, completed file.

[0081] This embodiment provides a file download method. The method discloses that a number of file download instances periodically retrieve downloadable chunks from a file chunk information table corresponding to the file to be downloaded; optimistic locking is used to lock the downloadable chunks; upon successful locking, the target download start position and target download end position of the downloadable chunk are determined based on the current chunk position field in the file chunk information table; the download of the downloadable chunk is performed based on the target download start position and target download end position; and a complete download file is generated based on the completed downloadable chunks. Compared to existing file download schemes that rely on a single instance, where a failure of that instance leads to file download interruption, this embodiment obtains downloadable chunks through several file download instances and downloads them based on their target download start and end positions, ultimately generating a complete download file based on the completed downloadable chunks. This solves the technical problem in existing file download schemes where a failure of a file download instance leads to file download interruption and failure.

[0082] Based on the first embodiment of this application, in the second embodiment of this application, the content that is the same as or similar to that in the first embodiment described above can be referred to the above description, and will not be repeated hereafter. Based on this, please refer to... Figure 4 , Figure 4 This is a flowchart illustrating Embodiment 2 of the document download method for this application.

[0083] In this embodiment, before step S10, the file download method further includes steps S01 to S04:

[0084] Step S01: Determine the file segmentation method corresponding to the file to be downloaded based on the file segmentation configuration table.

[0085] It should be noted that the above file sharding configuration table can be a table used for sharding information in the configuration file.

[0086] It is understandable that the above file fragmentation method can be used for the fragmentation of the file to be downloaded.

[0087] In this embodiment, refer to Figure 5 , Figure 5 This is a diagram illustrating the file fragmentation configuration table in the file download method of this application. The specific fields and meanings of the file fragmentation configuration table T_FILE_SHARDING_CONF are as follows: Figure 5 As shown, the fields in the file sharding configuration table can include: file type (FILE_TYPE), sharding mode (SHARDING_MODE), shard size (SHARDING_SIZE), relative start offset (START_OFFSET), and relative end offset (END_OFFSET). The file type (FILE_TYPE) is a custom value used to indicate the type of file, such as POLICY for policy files and PRODUCT for insurance product files. The sharding mode (SHARDING_MODE) specifies the sharding method used for downloading files, such as NOT_SHARDING for downloading without sharding, SHARDING_BY_LENGTH for sharding by size, and SHARDING_BY_LINE for sharding by line count. For the shard size (SHARDING_SIZE), if sharding is by size, the unit is bits (B), for example, 104857600 means each shard is 100MB; if sharding is by line count, the unit is lines.

[0088] It should be noted that in this embodiment, the END_OFFSET field represents an extra portion downloaded for that segment. This is crucial in certain scenarios, as it prevents missing data due to line breaks. For example, if a line in a TXT file corresponds to a Java object, without END_OFFSET, and the final position of the segment is not the last character of a line in the file, the data obtained from the last line of the segment will be incomplete, causing problems for the Java object processing program. However, by adding END_OFFSET in this solution, it is guaranteed that the line containing the target end position END_POSITION will be downloaded completely. The incompleteness of the extra lines following this line is irrelevant because the next segment starts downloading from the END_POSITION position of the current segment. However, it is essential to ensure that the program's data processing is idempotent, meaning that multiple processings of the same line of data will yield the same result.

[0089] Step S02: If the file segmentation method is size-based segmentation, then determine the file size of the file to be downloaded based on the file information table and the file download toolkit.

[0090] It should be understood that the above-mentioned method of splitting files by size can be a way of splitting the file to be downloaded into chunks according to the size of the file.

[0091] It is understood that the aforementioned file information table can be a table used to store information about the file itself, which may record information such as the server SERVERNAME where each file is located, the file type FILE_TYPE, the file path PATHNAME, the file name FILENAME, and the file's unique ID (corresponding to the FILE_IND_ID in the file sharding table). This embodiment does not impose any restrictions on this. The aforementioned file download toolkit is the file download SDK (Software Development Kit).

[0092] Step S03: Based on the file segmentation configuration table and the file size, the file to be downloaded is segmented using a preset file segmentation algorithm to obtain several file segmentation tasks.

[0093] It should be noted that the above-mentioned preset file fragmentation algorithm can be an algorithm used to fragment the file to be downloaded. In this embodiment, the purpose of the preset file fragmentation algorithm can be to generate the fragmentation sequence number SHARDING_SEQUENCE, the target download start position START_POSITION, and the target download end position END_POSITION of the file fragmentation information table.

[0094] Specifically, step S03 includes:

[0095] Step S031: Determine the target fragment size corresponding to the file to be downloaded according to the file fragment configuration table.

[0096] It should be noted that the target fragment size mentioned above can be the size of each fragment in the file to be downloaded.

[0097] Step S032: Determine the total number of fragments based on the target fragment size and the file size.

[0098] It is understandable that the total number of fragments mentioned above can be the number of fragments in the file to be downloaded. In this embodiment, the target fragment size corresponding to the file to be downloaded can first be determined according to the DEST_SIZE field of the file fragment configuration table, and the file size of the file to be downloaded can be divided by the target fragment size to obtain the total number of fragments N of the file to be downloaded.

[0099] Step S033: The file to be downloaded is split into several file splitting tasks based on the total number of splits using a preset file splitting algorithm.

[0100] Further, step S033 includes: determining the segment number corresponding to each file segment in the file to be downloaded based on the total number of segments using a preset file segmentation algorithm; determining the download start position and download end position of each file segment based on the segment number and the target segment size; determining the current segment position of each file segment according to the download start position and the download start position offset; generating segmentation field information of each file segment based on the segment number, the current segment position, the download start position, and the download end position; and splitting the file to be downloaded according to the segmentation field information to obtain several file segmentation tasks.

[0101] It should be understood that the aforementioned segment number is the sequence number corresponding to each segment in the file to be downloaded; the aforementioned download start position and download end position are the positions where the download of each segment in the file to be downloaded begins and ends, respectively. In this embodiment, the device can integrate the segment number, current segment position, download start position, and download end position corresponding to each segment in the file to be downloaded to generate segment field information corresponding to each segment. Subsequently, the file to be downloaded can be directly split based on the segment field information to obtain several file segment tasks.

[0102] In practical applications, the preset file segmentation algorithm first uses the total file size divided by the target segment size field DEST_SIZE in the file segmentation configuration table to obtain the total number of file segments N. The segment number is calculated using the formula (N-1), where N is the Nth segment. For example, the first segment is 0, the second segment is 1, and the Nth segment is N-1. The target download start position for each segment is calculated using the formula (N-1)*DEST_SIZE, and the target download start and end positions for each segment are calculated using the formula (N*DEST_SIZE). In addition, the current segment position can be START_POSITION+START_OFFSET. At this point, each field of each segment in the file to be downloaded has been determined. Then, this information is integrated to obtain the segment field information corresponding to each segment. Finally, the file to be downloaded is split based on the segment field information to obtain several file segmentation tasks.

[0103] Step S04: Store the file sharding task in the file sharding information table, and initialize the file execution status corresponding to the file sharding task in the file sharding information table.

[0104] It should be understood that after splitting the file to be downloaded into several file chunks, the chunk tasks can be stored in the file chunk information T_FILE_SHARDING_INFO table, and the file execution status corresponding to the file chunk tasks can be initialized so that the initial status of each chunk in the file to be downloaded is EXEC_STATUS = 0 (i.e., not executed).

[0105] Furthermore, after step S01, the method further includes: if the file fragmentation method is a line-by-line fragmentation method, then determining the total number of lines in the file to be downloaded; determining the target fragment line count corresponding to the file to be downloaded according to the file fragmentation configuration table; and determining the total number of fragments based on the target fragment line count and the total number of lines in the file.

[0106] It should be understood that the above-mentioned fragmentation method based on line count can be a method of fragmenting the file to be downloaded according to the number of lines in the file; the total number of lines in the file is the total number of lines in the file to be downloaded; the target number of fragment lines can be the number of lines in each fragment of the file to be downloaded. In this embodiment, if the fragmentation method of the file to be downloaded is based on line count, the total number of lines in the file to be downloaded can be used in a preset file fragmentation algorithm to use the target number of lines in each fragment in the file fragmentation configuration table to obtain the total number of fragments N of the file to be downloaded.

[0107] In this embodiment, the method of determining the file segmentation method corresponding to the file to be downloaded based on the file segmentation configuration table is disclosed. If the file segmentation method is size-based segmentation, the file size of the file to be downloaded is determined based on the file information table and the file download toolkit. Based on the file segmentation configuration table and the file size, the file to be downloaded is segmented using a preset file segmentation algorithm to obtain several file segmentation tasks. The file segmentation tasks are stored in the file segmentation information table, and the file execution status corresponding to the file segmentation tasks in the file segmentation information table is initialized, so that the file to be downloaded can be segmented into multiple segmentation tasks for download. Since each segment in this embodiment is processed using optimistic locking, multiple instances can be used to process file segments concurrently, thereby improving the efficiency and success rate of file download.

[0108] Based on the first and / or second embodiments of this application, in the third embodiment of this application, the content that is the same as or similar to the above embodiments can be referred to the above description, and will not be repeated hereafter. Based on this, please refer to... Figure 6 , Figure 6 This is a flowchart illustrating Embodiment 3 of the document download method for this application.

[0109] In this embodiment, before step S40, the method further includes steps S60 to S80:

[0110] Step S60: When the download of the segment task is completed, update the task execution status corresponding to the download segment task to the execution completion status.

[0111] It should be understood that the above-mentioned task execution status can be the current execution status of each segment in the task to be downloaded. In this embodiment, the task execution status of the segment can include: execution completed, execution failed, and not executed. In this embodiment, the device can update the task execution status of the segment task to the execution completed status by updating the EXEC_STATUS field in the file segment information table to 1.

[0112] Step S70: When the status update is complete, update the current fragment position field based on the target fragment size corresponding to the file to be downloaded.

[0113] It should be noted that after updating the task execution status of the task to be downloaded to the completed status, the current fragment position field CURRENT_POSITION in the file fragment information table can be updated, where CURRENT_POSITION = original CURRENT_POSITION + size of the current download.

[0114] Step S80: When the field update is complete, return to the step of determining the target download start position and target download end position of the task to be downloaded based on the current fragment position field in the file fragment information table.

[0115] Furthermore, the method also includes: real-time detection of whether there is a target fragment task in the file to be downloaded whose execution status is "execution failed"; if so, switching the execution status of the task to "execution in progress" and determining the execution interruption position and execution end position of the target fragment task; and continuing to download the target fragment task based on the execution interruption position and the execution end position.

[0116] It should be noted that if a network interruption or execution failure occurs during the download of a file, the download can resume from the interrupted point. At the same time, other instances are executing other segments without interference, thus enabling multiple instances to download and process the same file in parallel.

[0117] In the specific implementation, refer to Figure 7 , Figure 7 This is a schematic diagram of the file download process in the document download method of this application. For example... Figure 7As shown, during file download, a multi-instance application first scans the file segment information table every 5 seconds, retrieving segments whose execution status is "not executed" or "failed," and changing their execution status to "in execution." Simultaneously, an optimistic lock is used to lock these segments, preventing other application instances from accessing or modifying them. Then, the start and end download positions of each segment are determined based on the file segment configuration table. The segment is then downloaded according to the file segmentation download method, based on these positions. The application processes the downloaded data (e.g., when downloading a TXT file, each line of data is converted into a Java object and stored in the database). After each download is complete, the current segment position field in the file segment information table is updated, and the task execution status is updated to "completed."

[0118] In this embodiment, when the download of the segment to be downloaded is completed, the execution status of the corresponding task is updated to the execution completed status; when the status update is complete, the current segment position field is updated based on the target segment size of the file to be downloaded; when the field update is complete, the process returns to the step of determining the target download start position and target download end position of the segment to be downloaded based on the current segment position field in the file segment information table. This allows the download to continue from the interrupted position even if a network interruption or execution failure occurs during the file download process, thereby reducing the dependence on network speed and stability and improving the success rate of file download.

[0119] It should be noted that the above examples are only for understanding this application and do not constitute a limitation on the method of downloading the documents of this application. Any simple modifications based on this technical concept are within the protection scope of this application.

[0120] This application also provides a file download device; please refer to [reference needed]. Figure 8 The file download device includes:

[0121] The task acquisition module 10 is used to periodically acquire downloadable segment tasks from the file segment information table corresponding to the file to be downloaded through several file download instances;

[0122] The task locking module 20 is used to lock the downloadable segment task using optimistic locking;

[0123] The download location determination module 30 is used to determine the target download start position and target download end position of the task to be downloaded based on the current segment position field in the file segment information table when the lock is successful;

[0124] The task download module 40 is used to download the segment task to be downloaded based on the target download start position and the target download end position;

[0125] The download file generation module 50 is used to generate a complete download file based on the completed download segments.

[0126] The file download device provided in this application, employing the file download method described in the above embodiments, can solve the technical problem in existing file download schemes where file download is interrupted due to a failure in the download instance, leading to file download failure. Compared with the prior art, the beneficial effects of the file download device provided in this application are the same as those of the file download method provided in the above embodiments, and other technical features in the file download device are the same as those disclosed in the methods of the above embodiments, and will not be repeated here.

[0127] This application provides a file download device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, which are executed by the at least one processor to enable the at least one processor to perform the file download method in Embodiment 1 above.

[0128] The following is for reference. Figure 9 The diagram illustrates a structural schematic of a file download device suitable for implementing embodiments of this application. The file download device in this application may include, but is not limited to, mobile terminals such as mobile phones, laptops, digital radio receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Description), PMPs (Portable Media Players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 9 The file download device shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of this application.

[0129] like Figure 9As shown, the file download device may include a processing unit 1001 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1002 or a program loaded from a storage device 1003 into a random access memory (RAM) 1004. The RAM 1004 also stores various programs and data required for the operation of the file download device. The processing unit 1001, ROM 1002, and RAM 1004 are interconnected via a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Typically, the following systems can be connected to the I / O interface 1006: input devices 1007 including, for example, a touchscreen, touchpad, keyboard, mouse, image sensor, microphone, accelerometer, gyroscope, etc.; output devices 1008 including, for example, a liquid crystal display (LCD), speaker, vibrator, etc.; storage devices 1003 including, for example, magnetic tape, hard disk, etc.; and communication devices 1009. Communication device 1009 allows the file download device to communicate wirelessly or wiredly with other devices to exchange data. Although file download devices with various systems are shown in the figures, it should be understood that implementation or possession of all the systems shown is not required. More or fewer systems may be implemented alternatively.

[0130] Specifically, according to the embodiments disclosed in this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device, or installed from storage device 1003, or installed from ROM 1002. When the computer program is executed by processing device 1001, it performs the functions defined in the methods of the embodiments disclosed in this application.

[0131] The file download device provided in this application, employing the file download method described in the above embodiments, can solve the technical problem of file downloading. Compared with the prior art, the beneficial effects of the file download device provided in this application are the same as those of the file download method provided in the above embodiments, and other technical features of the file download device are the same as those disclosed in the previous embodiment method, and will not be repeated here.

[0132] It should be understood that the various parts disclosed in this application can be implemented using hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics can be combined in any suitable manner in one or more embodiments or examples.

[0133] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

[0134] This application provides a computer-readable storage medium having computer-readable program instructions (i.e., a computer program) stored thereon, the computer-readable program instructions being used to execute the file download method described in the above embodiments.

[0135] The computer-readable storage medium provided in this application may be, for example, a USB flash drive, but is not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections having one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, system, or device. The program code contained on the computer-readable storage medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination thereof.

[0136] The aforementioned computer-readable storage medium may be included in the file download device; or it may exist independently and not be assembled into the file download device.

[0137] The aforementioned computer-readable storage medium carries one or more programs. When these programs are executed by a file download device, the file download device: periodically retrieves downloadable segment tasks from a file segment information table corresponding to the file to be downloaded through several file download instances; locks the downloadable segment tasks using optimistic locking; upon successful locking, determines the target download start position and target download end position of the downloadable segment task based on the current segment position field in the file segment information table; and downloads the downloadable segment task based on the target download start position and download end position.

[0138] Computer program code for performing the operations of this application can be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, and C++, and conventional procedural programming languages ​​such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a Local Area Network (LAN) or a Wide Area Network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0139] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0140] The modules described in the embodiments of this application can be implemented in software or hardware. The names of the modules do not necessarily limit the functionality of the unit itself.

[0141] The readable storage medium provided in this application is a computer-readable storage medium that stores computer-readable program instructions (i.e., a computer program) for executing the above-described file download method. This solves the technical problem in existing file download schemes where file downloads are interrupted due to a malfunction, leading to download failure. Compared to the prior art, the beneficial effects of the computer-readable storage medium provided in this application are the same as those of the file download method provided in the above embodiments, and will not be repeated here.

[0142] The above description is only a part of the embodiments of this application and does not limit the patent scope of this application. All equivalent structural transformations made under the technical concept of this application and using the contents of the specification and drawings of this application, or direct / indirect applications in other related technical fields, are included in the patent protection scope of this application.

Claims

1. A file download method, characterized in that, The method includes: The download task is obtained periodically from the file segment information table corresponding to the file to be downloaded by several file download instances; The downloadable fragment tasks are locked using optimistic locking; Upon successful locking, the target download start position and target download end position of the task to be downloaded are determined based on the current segment position field in the file segment information table. The download segment task is performed based on the target download start position and the target download end position; A complete download file is generated based on the completed download segments.

2. The method as described in claim 1, characterized in that, Before the step of periodically retrieving the downloadable segment task from the file segment information table corresponding to the file to be downloaded through several file download instances, the method further includes: Determine the file segmentation method corresponding to the file to be downloaded based on the file segmentation configuration table; If the file is split into chunks by size, the file size of the file to be downloaded is determined based on the file information table and the file download toolkit. Based on the file segmentation configuration table and the file size, the file to be downloaded is segmented using a preset file segmentation algorithm to obtain several file segmentation tasks; The file sharding task is stored in the file sharding information table, and the file execution status corresponding to the file sharding task in the file sharding information table is initialized.

3. The method as described in claim 2, characterized in that, The step of splitting the file to be downloaded into several file fragment tasks based on the file fragment configuration table and the file size using a preset file fragmentation algorithm includes: The target chunk size corresponding to the file to be downloaded is determined according to the file chunk configuration table. The total number of fragments is determined based on the target fragment size and the file size; The file to be downloaded is split into several file splitting tasks based on the total number of splits using a preset file splitting algorithm.

4. The method as described in claim 3, characterized in that, The step of splitting the file to be downloaded into several file fragment tasks based on the total number of fragments using a preset file fragmentation algorithm includes: The fragment number corresponding to each file fragment in the file to be downloaded is determined based on the total number of fragments using a preset file fragmentation algorithm. The download start and end positions of each file segment are determined based on the segment number and the target segment size. The current position of each file fragment is determined based on the download start position and the download start position offset; The fragment field information of each file fragment is generated based on the fragment number, the current fragment position, the download start position, and the download end position; The file to be downloaded is split into several file splitting tasks based on the splitting field information.

5. The method as described in claim 2, characterized in that, After the step of determining the file fragmentation method corresponding to the file to be downloaded based on the file fragmentation configuration table, the method further includes: If the file is split into segments by line, then the total number of lines in the file to be downloaded is determined. The target number of rows for the file to be downloaded is determined based on the file fragment configuration table. The total number of shards is determined based on the target shard line count and the total number of lines in the file.

6. The method according to any one of claims 1 to 5, characterized in that, After the step of downloading the segment task to be downloaded based on the target download start position and the target download end position, the method further includes: When the download of the segment task is completed, the task execution status corresponding to the download segment task is updated to the execution completion status; When the status update is complete, the current fragment position field is updated based on the target fragment size corresponding to the file to be downloaded; When the field update is complete, return to the step of determining the target download start position and target download end position of the task to be downloaded based on the current fragment position field in the file fragment information table.

7. The method according to any one of claims 1 to 5, characterized in that, The method further includes: Real-time detection of whether there are target fragment tasks in the files to be downloaded whose execution status is failed; If it exists, the task execution state is switched to the executing state, and the execution interruption position and execution end position of the target fragment task are determined; The target fragment task continues to be downloaded based on the execution interruption position and the execution end position.

8. A file download device, characterized in that, The device includes: The task acquisition module is used to periodically obtain downloadable segment tasks from the file segment information table corresponding to the file to be downloaded through several file download instances; The task locking module is used to lock the downloadable task segments using optimistic locking; The download location determination module is used to determine the target download start position and target download end position of the task to be downloaded based on the current segment position field in the file segment information table when the lock is successful; The task download module is used to download the segmented task to be downloaded based on the target download start position and the target download end position; The download file generation module is used to generate a complete download file based on the completed download segments.

9. A file download device, characterized in that, The device includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the file download method as described in any one of claims 1 to 7.

10. A storage medium, characterized in that, The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, it implements the steps of the file download method as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Method for downloading media segment, terminal and computer-readable storage medium

    CN107040615A

  • Charging pile system evaluation method and system and computer storage medium

    CN115333797A