Resource file synchronization method, device, equipment and storage medium

During the resource file synchronization process, segmented transmission technology is used to download and upload resource files from the source device in segments, and the problem of low synchronization efficiency of large data resource files is solved, and a faster synchronization process is achieved.

CN112925761BActive Publication Date: 2024-11-15BEIJING KINGSOFT CLOUD NETWORK TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202110351706.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-03-31
Publication Date
2024-11-15
Estimated Expiration
2041-03-31

AI Technical Summary

Technical Problem

Since resource files with large data volumes need to be downloaded to the server's local memory as a whole, and the server needs to segment them, the synchronization efficiency of resource files with large data volumes is low.

Method used

By interacting with the source device, it determines the transmission type it supports. If segmented transmission is supported, the resource file will be downloaded in segments from the source device and uploaded each data fragment to the target device to splice out the complete file and the data volume of the data fragment. The amount of data uploaded by the target device is less than or equal to the single time, avoiding splitting.

Benefits of technology

It shortens the download and upload time and improves the efficiency of resource file synchronization. Especially in the case of large data volume, streaming further reduces the disk write pressure of the server and improves synchronization efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112925761B_ABST
    Figure CN112925761B_ABST
Patent Text Reader

Abstract

The present invention discloses a resource file synchronization method, device, equipment and storage medium. The method includes: receiving a resource file download task from a target device; the resource file download task is used to indicate the download of a target resource file; determining the transmission type supported by the source device by performing data interaction with the source device; when the transmission type supported by the source device includes segmented transmission, downloading the target resource file from the source device in segments; uploading each data segment obtained by the segmented download to the target device, so that the target device can splice the target resource file according to the received data segments; the data volume of each data segment is less than or equal to the single upload data volume of the target device. In the present invention, since the data volume of the data segment is less than or equal to the single upload data volume of the target device, the data segment can be directly uploaded to the target device without segmentation, which shortens the download and upload time and improves the efficiency of resource file synchronization.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of Internet technology, and in particular to a resource file synchronization method, device, equipment and storage medium. Background Art

[0002] With the booming development of Internet business, the number of users and resource files on the Internet has increased dramatically. Resource files can be stored in the source device. The server can download the resource files from the source device and upload the resource files to the target device. The target device sends the resource files requested by the client to the client. If the resource files are not synchronized to the target device through the server in time, when the client requests the resource files, the target device cannot provide the resource files to the client, and the request abnormality problem occurs. To solve this problem, the target device needs to perform a resource file back-to-source operation through the server so that the resource files can be synchronized from the source device through the server. When the client requests the resource files again, the target device can provide the resource files to the client.

[0003] At present, when the target device synchronizes resource files from the source device, the server needs to download the resource files as a whole to the server's local storage, and then the server uploads the resource files to the target device. However, when synchronizing resource files with a large amount of data, due to the limitation of the target device's single upload data volume, the server needs to divide the resource files into multiple blocks in the local storage, so that the data volume of each block is smaller than the single upload data volume of the target device, and then upload the multiple blocks to the target device separately. For example: in the case where the target device only accepts a single upload of 500MB of data, in order to upload a 1GB resource file, the server needs to download the entire 1GB resource file from the source device to the local storage, divide the 1GB resource file into three blocks with data volumes of 500MB, 500MB and 24MB in the local storage, and upload the three blocks to the target device separately.

[0004] Since large amounts of resource files need to be downloaded as a whole to the server's local storage, and the server needs to segment the large amounts of resource files, the synchronization efficiency of large amounts of resource files is low. Summary of the invention

[0005] The main purpose of the embodiments of the present invention is to provide a resource file synchronization method, device, equipment and storage medium to solve the problem in the prior art that large amounts of resource files need to be downloaded as a whole to the server's local storage and the server needs to split the large amounts of resource files, resulting in low synchronization efficiency of large amounts of resource files.

[0006] In view of the above technical problems, the embodiments of the present invention are solved by the following technical solutions:

[0007] An embodiment of the present invention provides a resource file synchronization method, comprising: receiving a resource file download task from a target device; wherein the resource file download task is used to indicate downloading a target resource file; determining the transmission type supported by the source device by performing data interaction with a source device; in a case where the transmission type supported by the source device includes segmented transmission, downloading the target resource file in segments from the source device; uploading each data segment obtained by the segmented download to the target device, so that the target device splices the target resource file according to the received data segments; wherein the data volume of each data segment is less than or equal to the single upload data volume of the target device.

[0008] The method of determining the transmission type supported by the source device by performing data interaction with the source device includes: sending a segment download request to the source device; receiving a response message returned by the source device; and determining the transmission type supported by the source device according to the transmission type field of the response message.

[0009] Among them, before downloading the target resource file in segments from the source device, it also includes: determining the data volume of the target resource file by interacting with the source device; determining the number of data fragments of the target resource file according to the data volume of the target resource file and the single upload data volume corresponding to the target device; determining the data range corresponding to each data fragment in the target resource file according to the number of data fragments of the target resource file; downloading the target resource file in segments from the source device includes: downloading each data fragment from the source device according to the data range corresponding to each data fragment in the target resource file.

[0010] Among them, downloading each data fragment from the source device according to the data range corresponding to each data fragment in the target resource file includes: establishing a communication connection with the source device for each data fragment, and downloading the data fragment from the source device according to the data range corresponding to the data fragment in the target resource file during the process of maintaining the communication connection with the source device; uploading each data fragment obtained by the segmented download to the target device includes: establishing a communication connection with the target device for each data fragment, and uploading the data fragment to the target device during the process of maintaining the communication connection with the target device.

[0011] The step of uploading each data segment obtained by segmented downloading to the target device includes: in the process of downloading each data segment, each time a data packet of the data segment is obtained by downloading, uploading the data packet to the target device.

[0012] Among them, uploading each data fragment obtained by segmented downloading to the target device includes: when uploading each data fragment of the target resource file to the target device, carrying the task identifier corresponding to the resource file download task, so that the target device aggregates the data fragments with the task identifier and splices out the target resource file.

[0013] The method further includes: comparing the data download bandwidth of the source device and the disk write speed of the target device; when the data download bandwidth is greater than or equal to the disk write speed, controlling the download speed of the data fragment to be less than or equal to the disk write speed; when the data download bandwidth is less than the disk write speed, controlling the upload speed of the data fragment to be less than or equal to the data download bandwidth.

[0014] An embodiment of the present invention also provides a resource file synchronization device, comprising: a receiving module, used to receive a resource file download task from a target device; wherein the resource file download task is used to indicate the downloading of a target resource file; a determining module, used to determine the transmission type supported by the source device by interacting with the source device; a segmented downloading module, used to download the target resource file in segments from the source device when the transmission type supported by the source device includes segmented transmission; a segmented uploading module, used to upload each data segment obtained by the segmented download to the target device, so that the target device splices the target resource file according to the received data segments; wherein the data amount of each data segment is less than or equal to the single upload data amount of the target device.

[0015] An embodiment of the present invention further provides a resource file synchronization device, which includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program implements any of the resource file synchronization methods described above when executed by the processor.

[0016] An embodiment of the present invention further provides a computer-readable storage medium, on which a resource file synchronization program is stored. When the resource file synchronization program is executed by a processor, any of the resource file synchronization methods described above is implemented.

[0017] The beneficial effects of the embodiments of the present invention are as follows:

[0018] In an embodiment of the present invention, after receiving a resource file download task, the transmission type supported by the source device is first determined. When it is determined that the source device supports segmented transmission, the target resource file is downloaded in segments, and the downloaded data segments are uploaded to the target device. Since the data volume of the data segments is less than or equal to the single upload data volume of the target device, the data segments can be directly uploaded to the target device without segmentation, which shortens the download and upload time and improves the efficiency of resource file synchronization. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:

[0020] Figure 1 is a flow chart of a resource file synchronization method according to an embodiment of the present invention;

[0021] Figure 2 is a flow chart of a resource file synchronization method according to an embodiment of the present invention;

[0022] Figure 3 is a schematic diagram of the architecture of a resource file synchronization system according to an embodiment of the present invention;

[0023] Figure 4 is a flow chart of a resource file synchronization method according to an embodiment of the present invention;

[0024] Figure 5 is a structural diagram of a resource file synchronization device according to an embodiment of the present invention;

[0025] Figure 6 is a structural diagram of a resource file synchronization device according to an embodiment of the present invention. DETAILED DESCRIPTION

[0026] In order to make the purpose, technical solutions and advantages of the present invention more clear, the present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments.

[0027] According to an embodiment of the present invention, a resource file synchronization method is provided. The execution subject of the embodiment of the present invention is a server. The server is used to download a target resource file from a source device and upload the target resource file to a target device, so that the target resource file is synchronized from the source device to the target device. Figure 1 FIG. 4 is a flowchart of a resource file synchronization method according to an embodiment of the present invention.

[0028] Step S110, receiving a resource file download task from a target device; wherein the resource file download task is used to instruct downloading a target resource file.

[0029] The target device is used to store resource files and provide resource files to the client.

[0030] In the resource file downloading task, it includes but is not limited to: information of the target resource file.

[0031] Information about the target resource file, including but not limited to: the name of the target resource file.

[0032] Types of target resource files include but are not limited to: video resource files, image resource files, and text resource files.

[0033] Step S120: determining the transmission type supported by the source device by performing data interaction with the source device.

[0034] In one embodiment, a communication message is received from the source device; a transmission type field in a message header of the communication message is queried; and a transmission type supported by the source device is determined according to the transmission type field in the message header.

[0035] In another embodiment, a segment download request is sent to the source device; a response message returned by the source device is received; and a transmission type supported by the source device is determined according to a transmission type field of the response message.

[0036] The segment download request is used to request to download the target resource file from the source device in segments.

[0037] The transmission type field is used to record the identifier corresponding to the transmission type. Further, the transmission type field includes a preset first identifier, and determines that the transmission type supported by the source device includes segmented transmission. The transmission type field includes a preset second identifier, and determines that the transmission type supported by the source device does not include segmented transmission.

[0038] Specifically, the segment download request may be a Range request. The transmission type field is located in the message header of the response message. The first identifier may be "Accept-Ranges: bytes". The second identifier may be "Accept-Ranges: none".

[0039] Step S130: download the target resource file from the source device in segments when the transmission type supported by the source device includes segmented transmission.

[0040] Segmented downloading means that only part of the data of the target resource file is obtained each time, and the part of the data is used as a data fragment of the target resource file.

[0041] Starting from the start position of the target resource file, a data segment of a preset data size is downloaded each time until the target resource file is downloaded. The preset data size is less than or equal to the single upload data size of the target device.

[0042] The single upload data volume corresponding to the target device refers to the maximum amount of data that the target device can receive at one time. The single upload data volume corresponding to the target device can be pre-stored in the server and can be obtained by the server from the target device side.

[0043] Specifically, before downloading the target resource file in segments from the source device, determine the data volume of the target resource file by interacting with the source device; determine the number of data segments of the target resource file based on the data volume of the target resource file and the single upload data volume corresponding to the target device; determine the data range corresponding to each data segment in the target resource file based on the number of data segments of the target resource file; downloading the target resource file in segments from the source device includes: downloading each data segment from the source device based on the data range corresponding to each data segment in the target resource file.

[0044] Furthermore, the number of data segments of the target resource file is determined according to the ratio of the data volume of the target resource file to the single upload data volume corresponding to the target device. When the ratio is an integer, the ratio is directly used as the number of data segments. When the ratio is not an integer, the integer closest to the ratio and greater than the ratio is used as the data segment data. For example: if the ratio is 2.1, 3 is determined as the data segment data.

[0045] Furthermore, the target resource file is equally divided into the number of data segments, and a data range corresponding to each of the equally divided data segments in the target resource file is determined.

[0046] Step S140: Upload each data segment obtained by segmented downloading to the target device, so that the target device can splice the target resource file according to the received data segments.

[0047] The data volume of each data segment is less than or equal to the single upload data volume of the target device.

[0048] In the process of downloading the data segments in segments, each data segment downloaded in segments is completely uploaded to the target device; or each data segment obtained by the segment download is uploaded to the target device in a streaming manner.

[0049] In one implementation, each data segment of the target resource file may be downloaded one by one; after each data segment is downloaded, the data segment is uploaded to the target device until all data segments of the target resource file are uploaded.

[0050] In another embodiment, each data segment of the target resource file may be downloaded one by one; in the process of downloading each data segment, each time a data packet of the data segment is downloaded, the data packet is uploaded to the target device, which is data streaming transmission.

[0051] After receiving all the data segments of the target resource file, the target device can splice all the data segments into the target resource file. In this way, when the client requests the target resource file, the target device can normally send the target resource file to the client.

[0052] In this embodiment, after receiving the resource file download task, the transmission type supported by the source device is first determined. When it is determined that the source device supports segmented transmission, the target resource file is downloaded in segments, and the downloaded data segments are uploaded to the target device. Since the data size of the data segment is less than or equal to the single upload data size of the target device, the data segment can be directly uploaded to the target device without segmentation, which shortens the download and upload time and improves the efficiency of resource file synchronization.

[0053] In this embodiment, streaming transmission can be performed, downloading and uploading at the same time, that is, downloading a data packet and uploading a data packet, so that the data packet can avoid being written to the server's disk, further shortening the download and upload time, and further improving the synchronization efficiency of the target resource file.

[0054] In order to make the present invention clearer, a more specific implementation is provided below to further describe the resource file synchronization method of the present invention. In this embodiment, only a large number of resource files are downloaded in segments. Resource files with large data volumes refer to files with data volumes that are larger than the single upload data volume of the target device.

[0055] like Figure 2 FIG. 1 is a flow chart of a resource file synchronization method according to an embodiment of the present invention.

[0056] Step S210, receiving a resource file download task from a target device; wherein the resource file download task is used to instruct downloading a target resource file.

[0057] Step S220: determining the transmission type supported by the source device and the data volume of the target resource file by performing data interaction with the source device.

[0058] A segmented download request is sent to a source device, in which the name of a target resource file is carried, so that the source device can query whether a target resource file with the name is stored; a response message is received from the source device, in which the response message includes at least the following information: transmission types supported by the source device, whether the target resource file is stored, and the amount of data of the target resource file.

[0059] In this embodiment, for ease of understanding, it is assumed that the source device stores the target resource file. In fact, the server interacts with a source device for data. If the source device does not store the target resource file, the server interacts with the next source device for data to determine whether the next source device stores the target resource file, and so on, until it is determined that a source device stores the target resource file.

[0060] Step S230, determining whether the data volume of the target resource file is greater than the single upload data volume of the target device; if yes, executing step S240; if not, executing step S290.

[0061] Step S240, determining whether the transmission type supported by the source device includes segmented transmission; if yes, executing step S250; if not, executing step S290.

[0062] The execution order of step S230 and step S240 is only used to illustrate the present embodiment, but is not used to limit the present embodiment. Step S240 may be executed first, and then step S230.

[0063] Step S250, when the transmission type supported by the source device includes segmented transmission, determine the number of data segments of the target resource file according to the data volume of the target resource file and the single upload data volume corresponding to the target device.

[0064] Determine the ratio of the data volume of the target resource file to the single upload data volume corresponding to the target device; when the ratio is not an integer, take the integer closest to the ratio and greater than the ratio as the number of data fragments of the target resource file.

[0065] Step S260: determining, according to the number of data segments in the target resource file, a data range corresponding to each data segment in the target resource file.

[0066] The target resource file is equally divided into the number of data segments, and a data range corresponding to each of the equally divided data segments in the target resource file is determined.

[0067] For example, if the target resource file has a data size of 6M and a data segment number of 3, then the first data segment is the first 2M, the second data segment is the middle 2M, and the third data segment is the last 2M.

[0068] Step S270: download each of the data segments from the source device according to the data range corresponding to each of the data segments in the target resource file.

[0069] For each of the data segments, a communication connection is established with the source device, and in the process of maintaining the communication connection with the source device, the data segment is downloaded from the source device according to the data range corresponding to the data segment in the target resource file.

[0070] For example: the first data segment of the target resource file is the first 2M, the second data segment is the middle 2M, and the third data segment is the last 2M; then first establish a communication connection with the source device to download the first 2M data segment; then establish a second communication connection with the source device to download the middle 2M data segment; finally establish a third communication connection with the source device to download the last 2M data segment.

[0071] Step S280: during the process of downloading each of the data segments, each time a data packet of the data segment is downloaded, the data packet is uploaded to the target device.

[0072] For each data segment, a communication connection is established with the target device, and while maintaining the communication connection with the target device, the data segment is uploaded to the target device. Furthermore, while maintaining the communication connection with the target device, a data packet of the data segment is downloaded and uploaded to the target device.

[0073] Specifically, when establishing a communication connection with the source device, a communication connection is established with the target device; after the last data packet of the current data segment is uploaded to the target device, the communication connection with the target device is disconnected.

[0074] Step S290: download the target resource file as a whole from the source device, divide the target resource file into multiple data segments, and upload the multiple data segments to the target device respectively.

[0075] In this embodiment, in order to facilitate the target device to splice out the target resource file, when uploading each data fragment of the target resource file to the target device, the task identifier corresponding to the resource file download task is carried so that the target device can aggregate the data fragments with the task identifier and splice out the target resource file.

[0076] Furthermore, after receiving the resource file download task from the target device, the task identifier corresponding to the resource file download task is obtained by interacting with the target device; in the process of uploading data fragments, each time after establishing a communication connection with the target device, the task identifier is first sent to the target device so that the target device can store the data fragments and the task identifier in correspondence. In this way, the target device can aggregate the data fragments with the same task identifier, and splice the data fragments according to the order in which the data fragments are received to obtain the target resource file.

[0077] In this embodiment, in order to protect the source device and reduce the download and upload pressure of resource files, the data download bandwidth of the source device and the disk write speed of the target device can be compared during the resource file synchronization process of the embodiment of the present invention; when the data download bandwidth is greater than or equal to the disk write speed, the download speed of the data fragment is controlled to be less than or equal to the disk write speed; when the data download bandwidth is less than the disk write speed, the upload speed of the data fragment is controlled to be less than or equal to the data download bandwidth.

[0078] In this embodiment, a large number of target resource files are downloaded in segments, and resource files with small data volumes are downloaded as a whole, avoiding the overall download of target resource files with large data volumes. In addition, a process transmission method is used to download and upload data packets of target resource files, avoiding the segmentation of target resource files in the local storage of the server, thereby shortening the resource file synchronization time and improving the resource file synchronization efficiency.

[0079] A more specific application scenario is provided below to further describe the resource file synchronization method of the embodiment of the present invention. In this embodiment, the source device stores a target resource file, and the data volume of the target resource file is greater than the single upload data volume of the target device.

[0080] like Figure 3 FIG. 1 is a schematic diagram of the architecture of a resource file synchronization system according to an embodiment of the present invention.

[0081] The resource file synchronization system at least includes: a source device, a target device and a server, wherein the server is used to connect the source device and the target device respectively through a network.

[0082] The server includes but is not limited to: download module (Download Worker), upload module (UploadWorker), streaming module (Range Worker), local disk and speed limiter (Limiter).

[0083] The download module is used to download the target resource file from the source device to the local storage of the server.

[0084] The upload module is used to upload the target resource file stored locally on the server to the target device.

[0085] The streaming transmission module is used to download the target resource file from the source device in segments, and during the segment download process, the downloaded data packet is uploaded to the target device in a streaming transmission manner.

[0086] Local disk, used to cache downloaded data packages.

[0087] The speed limiter is used to control the upload speed and download speed. Further, when the data download bandwidth on the source device side is greater than or equal to the disk write speed of the target device, the download speed is controlled to be less than or equal to the disk write speed; when the data download bandwidth on the source device side is less than the disk write speed of the target device, the upload speed is controlled to be less than or equal to the data download bandwidth.

[0088] The following is a detailed description of the working mode of each module in the server. Figure 4 FIG. 1 is a flow chart of a resource file synchronization method according to an embodiment of the present invention.

[0089] Step S410: The target device receives a resource acquisition request from a client, wherein the resource acquisition request is used to request to obtain a target resource file.

[0090] Step S420: When the target device fails to obtain the target resource file, it sends a resource file download task to the server.

[0091] When the target device obtains the target resource file, it sends the target resource file to the client.

[0092] Step S430: After receiving the resource file download task, the streaming module of the server sends a task identifier acquisition request to the target device.

[0093] The task identifier acquisition request is used to request to acquire the task identifier corresponding to the target resource file.

[0094] The task identifier may be a task ID (Identity Document) corresponding to the target resource file.

[0095] Step S440: After receiving the task identifier acquisition request, the target device generates a task identifier for the target resource file and sends the task identifier to the streaming module of the server.

[0096] Step S450: After receiving the task identifier, the streaming module of the server establishes a communication connection with the source device and sends a segment download request to the source device, where the segment download request includes the name of the target resource file.

[0097] The segment download request may be an HTTP (Hyper Text Transfer Protocol) Head request. Further, the segment download request is a Range request.

[0098] Range request can be used to obtain partial data in the target resource file in segments.

[0099] In one embodiment, the data range that needs to be acquired for the first time can be directly carried in the segment download request. Further, the data range that needs to be acquired for the first time can be determined according to the single upload data volume of the target device. For example, if the single upload data volume is 1M, then the data range that needs to be acquired for the first time is the first 1024 bytes of the target resource file. In this case, when sending the segment download request, a communication connection is established with the target device for streaming transmission.

[0100] In another embodiment, the segmented download request is only used to determine whether the source device supports segmented downloading and the data volume of the target resource file. Then, after obtaining the response message, if it is determined that the source device supports segmented downloading, a request can be made to establish a communication connection with the source device, and the segmented download request can be sent again, carrying the data range that needs to be obtained for the first time in the segmented download request sent again.

[0101] Step S460: After the source device finds the target resource file according to the segment download request, the source device returns a response message to the streaming module of the server, which carries the data volume of the target resource file and an identification of whether the source device supports segment transmission.

[0102] Step S470, the streaming transmission module of the server determines whether the source device supports segmented transmission according to the response message; if yes, execute step S480; if not, execute step S490.

[0103] Step S480, when the streaming transmission module of the server determines that the source device supports segmented transmission, it downloads the data segments of the target resource file from the source device in segments according to the data volume of the target resource file and the single upload data volume of the target device, and in the segmented downloading process, it carries the task identifier and uploads the data segment currently being downloaded to the target device in a streaming transmission manner, so that the target device splices the data segments according to the task identifier to obtain the target resource file.

[0104] According to the data volume of the target resource file and the single upload data volume of the target device, the number of data segments into which the target resource file can be divided can be determined. The number of data segments is the number of communication connections that need to be established with the source device.

[0105] Each time the streaming module downloads a data segment, it establishes a communication connection with the source device and a communication connection with the target device. The streaming module downloads the data packet of the data segment based on the communication connection established with the source device, and uploads the data packet to the target device based on the communication connection established with the target device. Furthermore, each time a communication connection is established with the source device, a segment download request is sent to the source device, and the segment download request carries the data range that needs to be downloaded this time. Each time a communication connection is established with the target device, a data upload request is sent to the target device, and the data upload request carries the task identifier and the amount of data that needs to be uploaded this time.

[0106] Each time the process transmission module uploads a data fragment, it needs to send a data sending request to the target device before uploading the first data packet of the data fragment. The data sending request carries the data amount of the data fragment and the task identifier corresponding to the target resource file.

[0107] Step S490, when the streaming transmission module of the server determines that the source device does not support segmented transmission, it switches to the download module, the download module downloads the complete target resource file from the source device, the upload module switches the target resource file into multiple blocks, and uploads the multiple blocks to the target device separately, and each block carries a task identifier, so that the target device can splice the multiple blocks according to the task identifier to obtain the target resource file.

[0108] The download module writes the target resource file to the local disk and then stores it to the server local storage.

[0109] The upload module switches the target resource file stored in the local storage of the server into multiple blocks, and uploads the multiple blocks to the target device respectively. The data volume of each block is less than or equal to the single upload data volume of the target device.

[0110] After the server completes uploading the target resource file, the target device splices the data fragments (chunks) into the target resource file according to the order in which the data fragments (chunks) are received and the task identifier.

[0111] In this embodiment, if the target device needs to synchronize multiple target resource files, the server can use the resource file synchronization method of the embodiment of the present invention to synchronize the multiple target resource files in parallel.

[0112] Since the writing speed of the local disk is fixed when the server downloads data from the source device to the local device, the download speed of the server cannot be greater than the disk writing speed. For example: if the single-task download speed of the server is 20MB / s and the disk writing speed is 100MB / s, then the number of tasks downloaded at the same time cannot be greater than 5. Therefore, the overall download and upload speed of the server will be affected by the disk writing speed. However, by adopting the streaming transmission method of this embodiment, the overall data volume of the data fragment will not exceed the single upload data volume of the target device, and when downloading a data packet and uploading a data packet, the data packet will not be written to the local disk and will not be affected by the disk writing speed. Neither will the download and upload time be increased due to disk writing, nor will the number of parallel tasks of the server be affected by the disk writing speed, so that the number of tasks and disk writing are decoupled.

[0113] The embodiment of the present invention solves the bottleneck problem of the server local disk through streaming transmission, decouples the relationship between the number of tasks and the disk, improves the return speed of resource files, and controls the overall download speed during the download and upload process to avoid system failures caused by mismatching download and upload speeds, thereby reducing the maintenance cost of the system.

[0114] The embodiment of the present invention also provides a resource file synchronization device. The resource file synchronization device is set on the server side. Figure 5 FIG. 4 is a structural diagram of a resource file synchronization device according to an embodiment of the present invention.

[0115] The resource file synchronization device includes: a receiving module 510, a determining module 520, a segment downloading module 530 and a segment uploading module 540.

[0116] The receiving module 510 is used to receive a resource file download task from a target device; wherein the resource file download task is used to instruct to download a target resource file.

[0117] The determination module 520 is configured to determine the transmission type supported by the source device by performing data interaction with the source device.

[0118] The segment downloading module 530 is configured to download the target resource file from the source device in segments when the transmission type supported by the source device includes segment transmission.

[0119] The segmented upload module 540 is used to upload each data segment obtained by segmented downloading to the target device, so that the target device can splice the target resource file according to the received data segments; wherein the data volume of each data segment is less than or equal to the single upload data volume of the target device.

[0120] The functions of the device described in the embodiment of the present invention have been described in the above method embodiment. Therefore, for details not provided in the description of the embodiment of the present invention, reference may be made to the relevant description in the above embodiment and will not be repeated here.

[0121] This embodiment provides a resource file synchronization device. Figure 6 FIG. 4 is a structural diagram of a resource file synchronization device according to an embodiment of the present invention.

[0122] In this embodiment, the resource file synchronization device includes, but is not limited to: a processor 610 and a memory 620 .

[0123] The processor 610 is used to execute the resource file synchronization program stored in the memory 620 to implement the above-mentioned resource file synchronization method.

[0124] Specifically, the processor 610 is used to execute the resource file synchronization program stored in the memory 620 to implement the following steps: receiving a resource file download task from a target device; wherein the resource file download task is used to indicate the download of a target resource file; determining the transmission type supported by the source device by interacting with the source device; when the transmission type supported by the source device includes segmented transmission, downloading the target resource file in segments from the source device; uploading each data segment obtained by the segmented download to the target device, so that the target device splices the target resource file according to the received data segments; wherein the data amount of each data segment is less than or equal to the single upload data amount of the target device.

[0125] The method of determining the transmission type supported by the source device by performing data interaction with the source device includes: sending a segment download request to the source device; receiving a response message returned by the source device; and determining the transmission type supported by the source device according to the transmission type field of the response message.

[0126] Among them, before downloading the target resource file in segments from the source device, it also includes: determining the data volume of the target resource file by interacting with the source device; determining the number of data fragments of the target resource file according to the data volume of the target resource file and the single upload data volume corresponding to the target device; determining the data range corresponding to each data fragment in the target resource file according to the number of data fragments of the target resource file; downloading the target resource file in segments from the source device includes: downloading each data fragment from the source device according to the data range corresponding to each data fragment in the target resource file.

[0127] Among them, downloading each data fragment from the source device according to the data range corresponding to each data fragment in the target resource file includes: establishing a communication connection with the source device for each data fragment, and downloading the data fragment from the source device according to the data range corresponding to the data fragment in the target resource file during the process of maintaining the communication connection with the source device; uploading each data fragment obtained by the segmented download to the target device includes: establishing a communication connection with the target device for each data fragment, and uploading the data fragment to the target device during the process of maintaining the communication connection with the target device.

[0128] The step of uploading each data segment obtained by segmented downloading to the target device includes: in the process of downloading each data segment, each time a data packet of the data segment is obtained by downloading, uploading the data packet to the target device.

[0129] Among them, uploading each data fragment obtained by segmented downloading to the target device includes: when uploading each data fragment of the target resource file to the target device, carrying the task identifier corresponding to the resource file download task, so that the target device aggregates the data fragments with the task identifier and splices out the target resource file.

[0130] The method further includes: comparing the data download bandwidth of the source device and the disk write speed of the target device; when the data download bandwidth is greater than or equal to the disk write speed, controlling the download speed of the data fragment to be less than or equal to the disk write speed; when the data download bandwidth is less than the disk write speed, controlling the upload speed of the data fragment to be less than or equal to the data download bandwidth.

[0131] The embodiment of the present invention also provides a computer-readable storage medium. The computer-readable storage medium here stores one or more programs. The computer-readable storage medium may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a read-only memory, a flash memory, a hard disk or a solid-state drive; the memory may also include a combination of the above-mentioned types of memory.

[0132] When one or more programs in the computer-readable storage medium can be executed by one or more processors, the resource file synchronization method described above can be implemented. Since the resource file synchronization method has been described in detail above, it will not be described in detail here.

[0133] The above description is only an embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent substitution, improvement, etc. made within the spirit and principle of the present invention shall be included in the scope of the claims of the present invention.

Claims

1. A resource file synchronization method, characterized in that: Applied to a server, the server is used to download a target resource file from a source device and upload the target resource file to a target device, so that the target resource file is synchronized from the source device to the target device, including: Receiving a resource file download task from a target device; wherein the resource file download task is used to instruct downloading a target resource file; By interacting with the source device for data, determine the transmission type supported by the source device; In a case where the transmission type supported by the source device includes segmented transmission, downloading the target resource file from the source device in segments; Uploading each data segment obtained by segmented downloading to the target device, so that the target device can splice the target resource file according to each received data segment; wherein the data volume of each data segment is less than or equal to the single upload data volume of the target device; The uploading each data segment obtained by the segmented download to the target device comprises: in the process of downloading each data segment, each time a data packet of the data segment is downloaded, uploading the data packet to the target device; In the case that the transmission type supported by the source device does not include segmented transmission, the target resource file is downloaded from the source device as a whole, the target resource file is divided into multiple data segments, and the multiple data segments are uploaded to the target device respectively.

2. The method according to claim 1, characterized in that By exchanging data with the source device, determine the transmission types supported by the source device, including: Sending a segment download request to the source device; receiving a response message returned by the source device; The transmission type supported by the source device is determined according to the transmission type field of the response message.

3. The method according to claim 1, characterized in that Before downloading the target resource file from the source device in segments, the method further includes: Determine the data volume of the target resource file by performing data interaction with the source device; Determine the number of data segments of the target resource file according to the data volume of the target resource file and the single upload data volume corresponding to the target device; Determine, according to the number of data segments in the target resource file, a data range corresponding to each data segment in the target resource file; Downloading the target resource file from the source device in segments includes: Each of the data segments is downloaded from the source device according to a data range corresponding to each of the data segments in the target resource file.

4. The method according to claim 3, characterized in that Downloading each of the data segments from the source device according to a data range corresponding to each of the data segments in the target resource file includes: For each of the data segments, a communication connection is established with the source device, and in the process of maintaining the communication connection with the source device, the data segment is downloaded from the source device according to the data range corresponding to the data segment in the target resource file; Uploading each data segment obtained by segment downloading to the target device includes: For each of the data segments, a communication connection is established with the target device, and while maintaining the communication connection with the target device, the data segment is uploaded to the target device.

5. The method according to any one of claims 1 to 4, characterized in that Uploading each data segment obtained by segment downloading to the target device includes: When uploading each data segment of the target resource file to the target device, the task identifier corresponding to the resource file download task is carried so that the target device aggregates the data segments with the task identifier and splices out the target resource file.

6. The method according to any one of claims 1 to 4, characterized in that Also includes: comparing the data download bandwidth of the source device and the disk write speed of the target device; When the data download bandwidth is greater than or equal to the disk writing speed, controlling the download speed of the data segment to be less than or equal to the disk writing speed; When the data download bandwidth is less than the disk write speed, the upload speed of the data segment is controlled to be less than or equal to the data download bandwidth.

7. A resource file synchronization device, characterized in that: Applied to a server, the server is used to download a target resource file from a source device and upload the target resource file to a target device, so that the target resource file is synchronized from the source device to the target device, including: A receiving module, used for receiving a resource file download task from a target device; wherein the resource file download task is used for instructing to download a target resource file; A determination module, used to determine the transmission type supported by the source device by interacting with the source device; A segment downloading module, configured to download the target resource file from the source device in segments when the transmission type supported by the source device includes segment transmission; The segmented uploading module is used to upload each data segment obtained by segmented downloading to the target device, so that the target device can splice the target resource file according to each received data segment; wherein the data volume of each data segment is less than or equal to the single upload data volume of the target device; the uploading of each data segment obtained by segmented downloading to the target device comprises: in the process of downloading each data segment, each time a data packet of the data segment is downloaded, the data packet is uploaded to the target device; In the case that the transmission type supported by the source device does not include segmented transmission, the target resource file is downloaded from the source device as a whole, the target resource file is divided into multiple data segments, and the multiple data segments are uploaded to the target device respectively.

8. A resource file synchronization device, characterized in that: The resource file synchronization device comprises: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program implements the resource file synchronization method according to any one of claims 1 to 6 when executed by the processor.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a resource file synchronization program, and when the resource file synchronization program is executed by a processor, the resource file synchronization method according to any one of claims 1 to 6 is implemented.