Data replacement method, server, update system and computer-readable storage medium
By recording gaps in the game resource package and using the linked list storage mechanism, putting new resource files into the gaps and generating differential packages for updates, the problem of large system resource consumption in the existing technology is solved, and the efficiency of game resource replacement and user download speed are improved.
Patent Information
- Application Number
- CN202111615599.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-27
- Publication Date
- 2025-09-02
- Estimated Expiration
- 2041-12-27
AI Technical Summary
The existing game resource replacement method will consume a lot of system resources, affecting game performance and user experience.
By recording the gaps left after deleting the files to be replaced in the resource package in the linked list, and putting new resource files into these gaps when needed, generating differential packages for updates, the need to replace the entire resource package is avoided.
It reduces the consumption of system resources, improves the efficiency of game resource replacement and user download speed, and simplifies the update work on the user side.
Smart Images

Figure CN114404991B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing technology, and in particular to a data replacement method, a server, an update system, and a computer-readable storage medium. Background Art
[0002] A game engine is a pre-programmed, editable computer game system or the core component of some interactive, real-time graphics applications. These systems provide game designers with the tools necessary to create games and generate game resource packages (data packets). Game resource files are numerous, with a high number of small files in the KB range. If randomly scattered across disks, the sheer number of fragmented files would significantly slow file access and copying. Therefore, game resource files are typically concatenated together to form a larger resource package.
[0003] However, game resources may change, requiring resource replacement. Since most game resource packages generated by game engines are read-only, there are currently two common methods for replacing game resources. One is to directly replace the entire resource package, while the other is to generate a new package and then compare binary data to create a differential package that represents the differences between the old and new packages. However, both methods consume significant system resources. Summary of the Invention
[0004] In view of this, an object of the present invention is to provide a data replacement method, a server, an update system and a computer-readable storage medium, which can improve the problem that the existing data resource replacement method consumes a large amount of system resources.
[0005] In order to achieve the above objectives, the technical solutions adopted in the embodiments of the present invention are as follows.
[0006] In a first aspect, the present invention provides a data replacement method, which adopts the following technical solution.
[0007] A data replacement method, comprising:
[0008] Delete the files to be replaced in the resource package;
[0009] For each gap left in the resource package after deleting the file to be replaced, basic information of the gap is recorded in a linked list, and the linked list is stored in a storage file, wherein the basic information includes length, starting position, and ending position, and each storage file corresponds to one resource package;
[0010] When a new resource file is to be added to the target resource package, the linked list in the storage file corresponding to the target resource package is retrieved to find a gap that meets the space requirements of the new resource file, and the new resource file is placed in the gap of the target resource package.
[0011] In a feasible embodiment, the method further includes:
[0012] When the data replacement of any resource package is completed, the old resource package that has not deleted the files to be replaced is compared with the resource package after the replacement is completed, and a list of deleted resource files and newly added resource files is counted. A pre-merge is performed and merge information is recorded; wherein the merge information includes the insertion position of the new resource file, the new resource file, and the start and end positions of the deleted resource files;
[0013] The merge information and the new packet header are placed in a differential packet, and the version numbers of the old resource packet and the replaced resource packet are written into the differential packet.
[0014] In a feasible embodiment, the method further includes:
[0015] If no space that satisfies the space requirement of the new resource file is found, the new resource file is placed after the tail position of the target resource package.
[0016] In a feasible implementation, the step of deleting the file to be replaced in the resource package includes:
[0017] Determine whether the resource package needs to be updated. If so, delete the file to be replaced in the resource package.
[0018] In a feasible implementation, the step of determining whether the resource package needs to be updated includes:
[0019] Comparing the file information of the new resource file with the file information of the resource package, if the new resource file is newer than the resource package and the summary information is consistent, then determining that the resource package needs to be updated;
[0020] The file information includes a timestamp and MD5.
[0021] In a feasible implementation manner, the step of recording the basic information of the gap in a linked list includes:
[0022] If there are continuous gaps, merge the continuous gaps;
[0023] After the merging is completed, the basic information of the gaps with the same length interval is stored in the same node of the linked list.
[0024] In a feasible implementation manner, the step of finding a gap that meets the space requirement of the new resource file and placing the new resource file into the gap of the target resource package includes:
[0025] Finding a gap that meets the new resource demand space, and obtaining the minimum gap from the gaps that meet the demand space according to the length;
[0026] The new resource file is placed into the minimum gap of the target resource bundle.
[0027] In a second aspect, the present invention provides a server that adopts the following technical solution.
[0028] A server includes a processor and a memory, wherein the memory stores machine-executable instructions that can be executed by the processor, and the processor can execute the machine-executable instructions to implement the data replacement method as described in the first aspect.
[0029] In a third aspect, the present invention provides a data updating system, which adopts the following technical solution.
[0030] A data updating system includes a server and a plurality of user terminals, wherein the server and the plurality of user terminals are in communication connection, and the server includes a deletion module, a replacement module, and a packaging module;
[0031] The deletion module is configured to delete the file to be replaced in the resource package, record basic information of each gap left in the resource package after deleting the file to be replaced in a linked list, and store the linked list in a storage file, wherein the basic information includes length, starting position, and ending position. Each storage file corresponds to one resource package.
[0032] The replacement module is configured to retrieve a linked list in a storage file corresponding to the target resource package when a new resource file is to be added to the target resource package, find a gap that satisfies the space required by the new resource file, and place the new resource file into the gap in the target resource package;
[0033] The packaging module, when the data replacement of any of the resource packages is completed, compares the old resource package that has not deleted the files to be replaced with the resource package after the replacement is completed, calculates a list of deleted resource files and added new resource files, performs a pre-merge, records the merge information, puts the merge information and the new package header into a differential package, and writes the version numbers of the old resource package and the resource package after the replacement into the differential package; wherein the merge information includes the insertion position of the new resource file, the new resource file, and the start and end positions of the deleted resource files;
[0034] The user terminal is used to download the differential package from the server to update data.
[0035] The fourth invention, the present invention provides a computer-readable storage medium, adopting the following technical solution.
[0036] A computer-readable storage medium stores a computer program, wherein the computer program, when executed by a processor, implements the data replacement method as described in the first aspect.
[0037] The data replacement method, server, update system and computer-readable storage medium provided by the embodiments of the present invention are as follows: when a resource package needs to be updated, after deleting the files to be replaced in the resource package, the gaps left in the resource package due to the deletion of the files to be replaced are recorded in a linked list, and the linked list is stored in a storage file corresponding to the resource package; when a new resource file is to be added to the target resource package, a suitable gap is found from the linked list of the corresponding storage file, and the new resource file is placed in the gap of the target resource package, thereby completing the data replacement without replacing the entire resource package or consuming a large amount of resources to calculate the data of the new resource package; only the data of the new resource file to be replaced needs to be calculated, thereby improving the problem that the existing data resource replacement method consumes a large amount of system resources.
[0038] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, preferred embodiments are specifically listed below and described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following is a brief introduction to the drawings required for use in the embodiments. It should be understood that the following drawings only illustrate certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can be obtained based on these drawings without paying any creative work.
[0040] Figure 1 A block diagram of a server provided by an embodiment of the present invention is shown.
[0041] Figure 2 A flow chart showing some steps of a data replacement method provided in an embodiment of the present invention is shown.
[0042] Figure 3 A schematic diagram showing the structure of a resource package for deleting files to be replaced is shown.
[0043] Figure 4 FIG. 4 shows a schematic diagram of the structure of the resource package after the replacement is completed.
[0044] Figure 5 A flow chart showing another part of the steps of the data replacement method provided in an embodiment of the present invention is shown.
[0045] Figure 6 Shown Figure 2 or Figure 5 Schematic diagram of the process of some sub-steps of S101.
[0046] Figure 7 Shown Figure 6 Schematic diagram of the process of some sub-steps of S101-1.
[0047] Figure 8 Shown Figure 2 or Figure 5 Flow chart of the sub-steps of step S103.
[0048] Figure 9 Shown Figure 2 or Figure 5 Schematic diagram of the process of some sub-steps of S106.
[0049] Figure 10 A block diagram of a data updating system provided by an embodiment of the present invention is shown.
[0050] Icon: 100 - server; 110 - memory; 120 - processor; 130 - communication module; 140 - data update system; 150 - user end; 160 - deletion module; 170 - replacement module; 180 - packaging module. DETAILED DESCRIPTION
[0051] The following will be combined with the accompanying drawings to clearly and completely describe the technical solutions of the embodiments of the present invention. Obviously, the embodiments described are only part of the embodiments of the present invention, not all of the embodiments. Generally, the components of the embodiments of the present invention described and shown in the drawings herein can be arranged and designed in a variety of different configurations.
[0052] Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the invention as claimed, but rather merely represents selected embodiments of the present invention. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative work are within the scope of protection of the present invention.
[0053] It should be noted that relational terms such as "first" and "second" are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article, or apparatus comprising the element.
[0054] Current data resource packages, such as game resource packs, contain a large number of resource files, many of which are small files in the KB range. If these files are randomly scattered on disk, the sheer number of fragmented files will significantly slow down file access and copying. Therefore, files are typically concatenated into a single, larger file and stored as a resource pack. However, game resources can change, necessitating resource replacement.
[0055] Most game resource packages generated by game engines are read-only. Therefore, there are currently two commonly used methods for replacing game resources.
[0056] One approach is to directly replace the entire game resource package. With this method, even changing a small file requires replacing the entire package containing the file. This typically increases the number of packages and reduces the size of each package. Replacing the entire package requires users to download the entire large package, increasing wait time and placing certain demands on their network. Splitting multiple packages simultaneously increases the difficulty of resource management. Furthermore, resources are prone to duplication, and excessive small packages and frequent loading and unloading during runtime can affect game performance.
[0057] Another approach is to generate a new package and then compare binary data to create a differential package representing the differences between the old and new packages. This approach, when an update is needed, modifies the binary data in the old package to create the new one. However, changes to the front of the package file may require extensive file updates. File encryption can also cause even small changes to a large file within the package to require updates to the entire file. This can consume significant system resources on the user's end, impacting game performance.
[0058] Based on the above considerations, the present invention provides a data replacement method, a server, an update system, and a computer-readable storage medium.
[0059] Please refer to Figure 1, is a block diagram of server 100. Server 100 includes memory 110, processor 120, and communication module 130. Memory 110, processor 120, and communication module 130 are electrically connected to each other, directly or indirectly, to enable data transmission or exchange. For example, these components may be electrically connected via one or more communication buses or signal lines.
[0060] Memory 110 is used to store programs or data. Memory 110 may be, but is not limited to, random access memory (RAM), read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), etc.
[0061] The processor 120 is used to read / write data, computer programs or machine executable instructions stored in the memory 110 and perform corresponding functions. Specifically, the processor 120 executes the computer programs or machine executable instructions in the memory 110 to implement the data replacement method provided by the present invention.
[0062] The communication module 130 is used to establish a communication connection between the server 100 and other communication terminals through the network, and to send and receive data through the network.
[0063] It should be understood that Figure 1 The structure shown is only a schematic diagram of the structure of the server 100. The server 100 may also include Figure 1 More or fewer components than shown, or with Figure 1 Different configurations shown. Figure 1 Each component shown in the figure can be implemented by hardware, software or a combination thereof.
[0064] Please refer to Figure 2 , is a flow chart of a data replacement method provided by the present invention. In this embodiment, the method is mainly applied to Figure 2 The server 100 in FIG. 1 is used as an example.
[0065] S101: Delete the file to be replaced in the resource package.
[0066] S103 , for each gap left in the resource package after deleting the file to be replaced, record basic information of the gap in a linked list, and store the linked list in a storage file.
[0067] The basic information includes length, starting position and ending position, and each storage file corresponds to a resource package.
[0068] Specifically, for each resource package, the server 100 is provided with a corresponding linked list recording basic information of the gap left after deleting the file to be replaced, and stores the linked list recording the basic information of the gap in the storage file corresponding to the resource package.
[0069] S104: When a new resource file is to be added to the target resource package, the linked list in the storage file corresponding to the target resource package is retrieved to find a gap that meets the space requirements of the new resource file.
[0070] S105: Determine whether there is space available to meet the requirements of the new resource file. If so, proceed to S106.
[0071] S106: Put the new resource file into the gap of the target resource package.
[0072] The target resource package is any one of the resource packages in which the file to be replaced has been deleted.
[0073] Through steps S101 - S106 , the resource pre-replacement of the resource package can be completed on the server 100 .
[0074] In the above data replacement method, when a resource package needs to be updated, the file to be replaced in the resource package is deleted, and the gap left in the resource package due to the deletion of the file to be replaced is recorded in a linked list, and the linked list is stored in a storage file corresponding to the resource package. When a new resource file is to be added to the target resource package, a suitable gap is found from the linked list of the corresponding storage file to put the new resource file into the gap of the target resource package, and the data replacement can be completed without replacing the entire resource package or consuming a large amount of resources to calculate the binary data of the new resource package. It is only necessary to calculate the data of the new resource file to be replaced, thereby improving the problem that the existing data resource replacement method consumes a large amount of system resources.
[0075] For example, refer to Figure 3 and Figure 4 , Figure 3 A schematic diagram showing the structure of the resource package including gaps after deleting the files to be replaced. Figure 4 A schematic diagram showing the structure after a new resource file is inserted into the target resource package.
[0076] Further, refer to Figure 5 , Figure 5This is a flow chart of another part of the steps of the data replacement method provided by the present invention. The data replacement method provided by the present invention also includes S106.
[0077] After executing S105 , if no space that satisfies the space requirement of the new resource file is found, then executing S106 .
[0078] S106: Put the new resource file at the end of the target resource package.
[0079] When the server 100 fails to find a space that satisfies the space requirement of the new resource file, it puts the new resource file after the end of the target resource package, so that each new resource file can be put into the target resource package.
[0080] Please continue to refer to Figure 5 , the method may further include the following steps.
[0081] S108, when the data replacement of any resource package is completed, the old resource package that has not deleted the files to be replaced is compared with the resource package after the replacement is completed, and a list of deleted resource files and newly added resource files is counted, and a pre-merge is performed and the merge information is recorded.
[0082] The merge information includes the insertion position of the new resource file, the new resource file, and the start and end positions of the deleted resource file.
[0083] S109: Put the merge information and the new header into the differential package, and write the version numbers of the old resource package and the replaced resource package into the differential package.
[0084] Specifically, when the data replacement of any resource package is completed, the server 100 compares the old resources (including the files to be replaced) with the resource package after the replacement, calculates the list of deleted resource files and the hypothetical new resource files, and performs a pre-merge to obtain merge information. The merge information and the new package header are written into the differential package, and the version numbers of the old resource package and the new package after the replacement are also written into the differential package.
[0085] The differential package is used for downloading by the client 150 to update the data of the resource package.
[0086] Specifically, the user terminal 150 only needs to replace the header of the old resource package with the new header in the differential package, delete the resource file, and copy the new resource file according to the insertion position of the new resource file to update from the old resource package to the new version.
[0087] The differential package only includes the old and new version numbers, the start and end locations of the deleted resource files, the insertion location of the new resource files, and the new resource files. This reduces the size of the differential package, thereby increasing the speed at which users can download the differential package. Furthermore, the user terminal 150 does not need to perform a binary comparison to update the old resource package, nor does it need to move large amounts of data, thereby increasing the speed of updating the old resource package to the new one.
[0088] On the basis of the above, for S101, refer to Figure 6 , Figure 6 Including some sub-steps of S101, the following steps may be included.
[0089] S101-1, determine whether the resource package needs to be updated, and if so, delete the files to be replaced in the resource package.
[0090] That is, when it is determined that the resource package needs to be updated, the files to be replaced in the resource package are deleted.
[0091] Specifically, refer to Figure 7 , Figure 7 This is a flowchart of some sub-steps of step S101 - 1 . The following steps can be used to determine whether a resource package needs to be updated.
[0092] S201: Compare the file information of the new resource file with the file information of the resource package.
[0093] The file information includes timestamp and MD5.
[0094] S202: If the new resource file is newer than the resource package and the summary information is consistent, it is determined that the resource package needs to be updated.
[0095] Specifically, based on the timestamps of the new resource file and the resource bundle, it is determined whether the new resource bundle is newer than the resource bundle, and based on MD5, it is determined whether the digest information is consistent.
[0096] In other implementations, some resource files of a resource pack (i.e., an old resource pack) may be manually designated to be deleted, thereby deleting the resource files of the resource pack. That is, when there are no new resource files, some resource files of the resource pack may also be deleted as needed.
[0097] After deleting the file to be replaced or part of the resource file in the resource package, the resource package will leave multiple gaps. For the multiple gaps left, refer to Figure 8 , Figure 8 FIG. 1 is a flowchart of some sub-steps of step S103 . The following steps can be used to record the section information of the gap in the linked list.
[0098] S103-1: If there are continuous gaps, merge the continuous gaps.
[0099] According to the starting and ending positions of the gap, it can be determined whether the gap is continuous.
[0100] For example, if the end position of one gap is the start position of another gap, then the two gaps are continuous.
[0101] It should be understood that after multiple gaps are merged, the length of the gap obtained by merging is the sum of the lengths of the multiple gaps. Wherein, the length refers to the data length, and can also be understood as the storage length occupied by the gap.
[0102] For example, there are three consecutive gaps, the first gap is 100 bytes, the second gap is 150 bytes, and the third gap is 50 bytes. The gaps obtained after merging are 300 bytes.
[0103] S103-2, after the merging is completed, the basic information of the gaps with the same length interval is stored in the same node of the linked list.
[0104] The starting position of the merged gap is the starting position of the first gap after the merger, and the ending position is the ending position of the last gap after the merger.
[0105] Taking the merging of two gaps as an example, if the first gap is located earlier in the resource pack than the second gap, the starting position of the first gap is the starting position of the merged gap, and the ending position of the second gap is the ending position of the merged gap.
[0106] In addition, in one embodiment, for step S106, refer to Figure 9 , Figure 9 This is a flowchart of some sub-steps of S106. Through the following steps, it is possible to find a gap that meets the space requirements of the new resource file and put the new resource file into the gap of the target resource package.
[0107] S106-1, finding the gaps that meet the new resource demand space, and obtaining the minimum gap from the gaps that meet the demand space according to the length.
[0108] S106-2: Place the new resource file into the smallest gap in the target resource package.
[0109] Placing the new resource file into the smallest gap in the target resource package that meets the required space can make more effective use of the gap resources in the target resource package.
[0110] The data replacement method provided by the present invention completes data replacement by placing a new resource file into the gap left after the file to be replaced is deleted from the resource package. This method eliminates the need to replace the entire resource package or consume a large amount of resources to calculate the data for the new resource package. Instead, it only needs to calculate the data for the new resource file to be replaced, thereby improving the problem of existing data resource replacement methods consuming large amounts of system resources. After the resource package is replaced, a differential package is generated based on the merged information obtained by comparing the old and new resource packages. This reduces the size of the differential package, increases the speed at which users can download the differential package, and simplifies user-side updates.
[0111] It should be understood that although Figure 2-Figure 9 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. In addition, Figure 2-Figure 9 At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.
[0112] On the basis of the above, the present invention also provides a data updating system 140, referring to Figure 10 , is a block diagram of a data updating system 140. The data updating system 140 includes a server 100 and a plurality of client terminals 150. The server 100 and the plurality of client terminals 150 are connected via a network communication.
[0113] Furthermore, in order to execute the corresponding steps in the above-mentioned embodiments and various possible methods, the implementation of the server 100 in the data update system 140 is given below. Optionally, the server 100 may adopt the above-mentioned Figure 1 The device structure of the server 100 is shown in FIG. Figure 10 , Figure 10 This is a functional module diagram of the server 100 provided in an embodiment of the present invention. It should be noted that the basic principles and technical effects of the server 100 provided in this embodiment are the same as those of the above-mentioned embodiment. For the sake of simplicity, any parts not mentioned in this embodiment can be referred to the corresponding content in the above-mentioned embodiment. The server 100 includes: a deletion module 160, a replacement module 170, and a packaging module 180. On this basis, the data update system 140 performs data updates based on the data replacement method provided above, for example, by the following method.
[0114] The deletion module 160 is configured to delete the file to be replaced in the resource package, record basic information of each gap left in the resource package after deleting the file to be replaced in a linked list, and store the linked list in a storage file.
[0115] The basic information includes length, starting position and ending position, and each storage file corresponds to a resource package.
[0116] The replacement module 170 is used to retrieve the linked list in the storage file corresponding to the target resource package when a new resource file is to be added to the target resource package, find out the space that meets the space requirements of the new resource file, and put the new resource file into the space of the target resource package.
[0117] The packaging module 180, when the data replacement of any resource package is completed, compares the old resource package that has not deleted the files to be replaced with the resource package after the replacement is completed, counts the list of deleted resource files and the newly added resource files, and performs pre-merging, records the merge information, puts the merge information and the new package header into the differential package, and writes the version numbers of the old resource package and the resource package after the replacement in the differential package.
[0118] The merge information includes the insertion position of the new resource file, the new resource file, and the start and end positions of the deleted resource file.
[0119] The client 150 is used to download the differential package from the server 100 to update data.
[0120] Specifically, after the user terminal 150 downloads the differential package, it only needs to replace the header of the old resource package with the new header in the differential package, delete the resource file, and copy the new resource file according to the insertion position of the new resource file to update from the old resource package to the new version to complete the data update.
[0121] Optionally, the above modules can be stored in the form of software or firmware. Figure 1 The memory 110 shown in FIG. 1 is stored in the operating system (OS) of the server 100 and can be used by Figure 1 Meanwhile, the data, program codes, etc. required to execute the above modules may be stored in the memory 110.
[0122] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely illustrative. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architectures, functions and operations of the devices, methods and computer program products according to multiple embodiments of the present invention. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of the code, and the module, program segment or a part of the code contains one or more executable instructions for implementing the specified logical functions. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in an order different from that marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart, can be implemented using a dedicated hardware-based system that performs the specified function or action, or can be implemented using a combination of dedicated hardware and computer instructions.
[0123] In addition, the functional modules in various embodiments of the present invention may be integrated together to form an independent part, or each module may exist independently, or two or more modules may be integrated to form an independent part.
[0124] If the functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
[0125] The foregoing description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. Those skilled in the art will readily appreciate that various modifications and variations are possible. Any modifications, equivalent substitutions, or improvements made within the spirit and principles of the present invention are intended to be within the scope of protection of the present invention.
Claims
1. A data replacement method, characterized in that: The method comprises: Delete the files to be replaced in the resource package; For each gap left in the resource package after deleting the file to be replaced, basic information of the gap is recorded in a linked list, and the linked list is stored in a storage file, wherein the basic information includes length, starting position, and ending position, and each storage file corresponds to one resource package; When a new resource file is to be added to the target resource package, the linked list in the storage file corresponding to the target resource package is retrieved to find a gap that meets the space requirements of the new resource file, and the new resource file is placed in the gap of the target resource package; The step of finding a gap that meets the space requirement of the new resource file and placing the new resource file into the gap of the target resource package includes: Finding a gap that meets the new resource demand space, and obtaining the minimum gap from the gaps that meet the demand space according to the length; The new resource file is placed into the minimum gap of the target resource bundle.
2. The data replacement method according to claim 1, wherein: The method further comprises: When the data replacement of any resource package is completed, the old resource package that has not deleted the files to be replaced is compared with the resource package after the replacement is completed, and a list of deleted resource files and newly added resource files is counted. A pre-merge is performed and merge information is recorded; wherein the merge information includes the insertion position of the new resource file, the new resource file, and the start and end positions of the deleted resource files; The merge information and the new packet header are placed in a differential packet, and the version numbers of the old resource packet and the replaced resource packet are written into the differential packet.
3. The data replacement method according to claim 1 or 2, characterized in that: The method further comprises: If no space that satisfies the space requirement of the new resource file is found, the new resource file is placed after the tail position of the target resource package.
4. The data replacement method according to claim 1 or 2, characterized in that: The step of deleting the file to be replaced in the resource package includes: Determine whether the resource package needs to be updated. If so, delete the file to be replaced in the resource package.
5. The data replacement method according to claim 4, characterized in that: The step of determining whether the resource package needs to be updated includes: Comparing the file information of the new resource file with the file information of the resource package, if the new resource file is newer than the resource package and the summary information is consistent, then determining that the resource package needs to be updated; The file information includes a timestamp and MD5.
6. The data replacement method according to claim 1 or 2, characterized in that: The step of recording the basic information of the gap in a linked list includes: If there are continuous gaps, merge the continuous gaps; After the merging is completed, the basic information of the gaps with the same length interval is stored in the same node of the linked list.
7. A server, characterized in that: The invention comprises a processor and a memory, wherein the memory stores machine-executable instructions that can be executed by the processor, and the processor can execute the machine-executable instructions to implement the data replacement method according to any one of claims 1 to 6.
8. A data updating system, characterized in that: It includes a server and multiple client terminals, the server and the multiple client terminals are in communication connection, and the server includes a deletion module, a replacement module and a packaging module; The deletion module is configured to delete the file to be replaced in the resource package, record basic information of each gap left in the resource package after deleting the file to be replaced in a linked list, and store the linked list in a storage file, wherein the basic information includes length, starting position, and ending position. Each storage file corresponds to one resource package. The replacement module is configured to retrieve a linked list in a storage file corresponding to the target resource package when a new resource file is to be added to the target resource package, find a gap that satisfies the space required by the new resource file, and place the new resource file into the gap in the target resource package; The packaging module, when the data replacement of any of the resource packages is completed, compares the old resource package that has not deleted the files to be replaced with the resource package after the replacement is completed, calculates a list of deleted resource files and added new resource files, performs a pre-merge, records the merge information, puts the merge information and the new package header into a differential package, and writes the version numbers of the old resource package and the resource package after the replacement into the differential package; wherein the merge information includes the insertion position of the new resource file, the new resource file, and the start and end positions of the deleted resource files; The client is used to download the differential package from the server to update data; The replacement module is further configured to find a gap that satisfies the space requirement of the new resource, and obtain the minimum gap from the gaps that meet the space requirement according to their lengths; and place the new resource file into the minimum gap of the target resource package.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the data replacement method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Data updating method, device and system
CN104657170A
Resource processing method and device, electronic equipment and storage medium
CN112559180A
File processing method and device, readable medium and electronic equipment
CN113553300A