Resource file management method and device and electronic equipment
By using the preset compressed file cache area in the resource file management method to reduce repeated compression of resource files, the problem of high time and computing resource consumption caused by multiple compressions of resource files in game development is solved, and development efficiency is improved.
Patent Information
- Application Number
- CN202410968580.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-18
- Publication Date
- 2024-10-15
AI Technical Summary
In game development, resource files need to be compressed multiple times when merging between branches and trunks, resulting in high time costs and large consumption of computing resources, which reduces development efficiency.
In the resource file management method, the preset compressed file cache area is used to search whether a compressed file exists. If it exists, the file is deleted from the queue and the file in the cache area is read to avoid repeated compression.
It effectively reduces the time consumption of repeated compression of resource files and improves the efficiency of project development. Especially when the number of resource files is large, it significantly saves compression time.
Smart Images

Figure CN118778936A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a resource file management method, device, electronic device and computer-readable storage medium. Background Art
[0002] The game development process usually involves a large number of resource files. These image files not only cover the texture maps of the character models and the user interface (UI) elements, but also involve the rich details of the game scenes. At present, in the resource production stage, resource files are usually produced in an uncompressed format on the personal terminal (PC) of the artist, which is convenient for the artist to perform high-quality editing. In the resource deployment stage, considering the performance optimization requirements of the actual operating environment, it is usually necessary to compress the resource files to reduce memory usage, increase loading speed and optimize rendering efficiency.
[0003] In related technologies, in order to provide independent development spaces for different development needs, separate branches are usually created for each development need to isolate changes. When newly added resource files are tested on a branch, they are often tested in a compressed form to simulate the performance of the resource files in the actual operating environment. When the resource file test is completed and the branch content is merged into the trunk, in order to avoid unnecessary conflicts, resource files are usually merged instead of compressed files, and the compression of resource files will be performed in the trunk environment.
[0004] In the above method, the resource file needs to be compressed once when testing on the branch. After each resource file on the branch is merged into the trunk, another compression operation is required. On the one hand, it increases the time cost, and on the other hand, it consumes a lot of computing resources, thereby reducing the efficiency of game development. Summary of the invention
[0005] The present application provides a resource file management method, device, electronic device and computer-readable storage medium, which can effectively solve the problem of resource files needing to be compressed multiple times in project development, resulting in a long time consumption, thereby improving the efficiency of project development. The specific solution is as follows:
[0006] In a first aspect, an embodiment of the present application provides a method for managing resource files, the method comprising:
[0007] In response to a compression instruction of a first resource file, adding the first resource file to a first queue to be compressed, wherein the compression instruction includes an instruction to compress the first resource file on a corresponding branch, or an instruction to compress the first resource file on a trunk;
[0008] Searching whether a compressed file corresponding to the first resource file is stored in a preset compressed file cache area;
[0009] If so, the first resource file is deleted from the first queue, and the first compressed file corresponding to the first resource file stored in the compressed file cache is read.
[0010] In a second aspect, an embodiment of the present application provides a resource file management device, the device comprising:
[0011] an adding unit, configured to add the first resource file to a first queue to be compressed in response to a compression instruction of the first resource file, wherein the compression instruction includes an instruction to compress the first resource file on a corresponding branch, or an instruction to compress the first resource file on a trunk;
[0012] A searching unit, used for searching whether a compressed file corresponding to the first resource file is stored in a preset compressed file cache area;
[0013] The processing unit is configured to, if yes, delete the first resource file from the first queue, and read the first compressed file corresponding to the first resource file stored in the compressed file cache area.
[0014] In a third aspect, the present application further provides an electronic device, including:
[0015] Processor; and
[0016] The memory is used to store a data processing program. After the electronic device is powered on and the program is run by the processor, the method described in the first aspect is executed.
[0017] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium storing a data processing program, which is executed by a processor to perform the method described in the first aspect.
[0018] Compared with the prior art, this application has the following advantages:
[0019] The resource file management method provided by the embodiment of the present application includes: in response to the compression instruction of the first resource file, adding the first resource file to the first queue to be compressed, wherein the compression instruction includes an instruction to compress the first resource file on the corresponding branch, or an instruction to compress the first resource file on the trunk; searching whether the compressed file corresponding to the first resource file is stored in the preset compressed file cache; if so, deleting the first resource file from the first queue, and reading the first compressed file corresponding to the first resource file stored in the compressed file cache. It can be seen that the resource file management method provided by the embodiment of the present application, when there is a first compressed file corresponding to the first resource file added to the first queue to be compressed in the preset compressed file cache, removes the first resource file from the first queue, and reads the first compressed file stored in the compressed file cache, so that the time consumed by the first resource file being recompressed can be saved. When the number of resource files included in the entire project development is large, the resource file management method provided by the embodiment of the present application can effectively solve the problem of long time consumption caused by the resource files needing to be compressed multiple times in project development, thereby improving the efficiency of project development. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Figure 1 It is a management system diagram for implementing a resource file management method provided in an embodiment of the present application;
[0021] Figure 2 is a flowchart of a method for managing resource files provided in an embodiment of the present application;
[0022] Figure 3 It is a schematic diagram of the compression process in the resource file management method provided in the embodiment of the present application;
[0023] Figure 4 It is a structural block diagram of an example of a resource file management device provided in an embodiment of the present application;
[0024] Figure 5 It is a structural block diagram of an example of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0025] Many specific details are described in the following description to facilitate a full understanding of the present application. However, the present application can be implemented in many other ways than those described herein, and those skilled in the art can make similar generalizations without violating the connotation of the present application, so the present application is not limited by the specific implementation disclosed below.
[0026] It should be noted that the terms "first", "second", "third", etc. in the claims, description and drawings of the present application are used to distinguish similar objects and are not used to describe a specific order or sequence. The data used in this way are interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "including", "having" and their variants are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0027] It should be understood that in the embodiments of the present application, "at least one" refers to one or more, and "more than one" refers to two or more. "And / or" is merely a way to describe the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the previous and subsequent associated objects are in an "or" relationship. "Including A, B and / or C" means including any one, any two, or any three of A, B, and C.
[0028] It should be understood that in the embodiments of the present application, "B corresponding to A", "B corresponding to A", "A corresponds to B", or "B corresponds to A" means that B is associated with A, and B can be determined according to A. Determining B according to A does not mean determining B only according to A, and B can also be determined according to A and / or other information.
[0029] Before describing the implementation methods of the present application in detail, relevant concepts are first introduced and the prior art is further described.
[0030] Introduction to related concepts
[0031] Usually project resources are managed through resource version control technology. This is because project resources usually need to be developed and maintained collaboratively by multiple developers. Therefore, version control technology can be used to record each modification of project resources. Managing project resources through version control technology can allow users to modify and manage the same set of project resources in their respective electronic devices to promote team collaboration.
[0032] The main function of version control is to store resource files and track changes to resource files. You can record the time, content, or personnel of resource file changes. Every time a resource file is changed, the version number of the resource file will increase. In addition to recording version changes, version control can also perform parallel development. Version control can effectively solve version synchronization and development communication problems between different developers, and improve the efficiency of collaborative development.
[0033] Version control tools may include: Concurrent Versions System (CVS) version control system, Subversion (SVN) version control system, Vesta version control system, Revision Control System (RCS) version control system, Source Code Control System (SCCS) version control system, etc. Two commonly used tools are CVS version control system and SVN version control system. In this embodiment, the version control tool adopts SVN version control system.
[0034] Further description of the prior art
[0035] In the game development process, resource file management is a crucial link, which directly affects the visual performance and running efficiency of the game after it goes online. Common resource files, such as character skins, user interface (UI) elements, etc., are usually created on the PC side of artists in uncompressed formats (such as PNG, TGA) to retain the best image quality and editing flexibility. However, with the widespread application of virtual games on mobile terminals, in order to ensure the smooth operation of games on mobile devices, resource files need to be converted into compression formats optimized for mobile hardware, such as ASTC, PVRTC, ETC, ETC2 and other compression formats.
[0036] In related technologies, development teams often use version control systems to manage code and resource assets, and ensure the parallelism and traceability of development work by creating separate branches for each development task or requirement. Each new feature or fix is tested on a separate branch to ensure that development work does not interfere with each other. In order to enable developers to evaluate the compression effect in a timely manner and determine whether there are obvious image quality issues with the compressed files, resource files are usually tested in a compressed form on the branch to simulate the final performance on mobile devices.
[0037] When these branch contents are merged back to the trunk (i.e., the stable version for regular releases), in order to avoid merge conflicts and maintain resource consistency, usually only the uncompressed resource files are merged into the trunk, and the compressed files are regenerated on the trunk through an automated process. Compared with directly merging compressed files, this method can effectively avoid the problem of version mismatch between resource files and compressed files, especially after the resource files are modified.
[0038] However, in the related art, after each branch merge, the resource compression step needs to be re-executed, which not only increases the workload in the development process, but also takes a lot of time to perform resource compression. In addition, the repeated compression process consumes a lot of computing resources, especially in large projects where each merge involves a large number of resource files. This inefficiency is more significant. This greatly affects key game development processes such as packaging and testing, reduces overall development efficiency, and prolongs the time to market.
[0039] Based on the above reasons, in order to effectively solve the problem of time-consuming and large-scale computing resource consumption caused by the need to re-compress resource files on branches when merging them into the trunk, thereby improving the efficiency of game development, the first embodiment of the present application provides a resource file management method, which is applied to electronic devices, which can be desktop computers, laptops, mobile phones, tablet computers, etc., or other electronic devices capable of resource management, which are not specifically limited in the embodiments of the present application.
[0040] For example, in combination with the above introduction, Figure 1 A management system 100 for implementing a resource file management method provided by an embodiment of the present application is shown. The game system 100 may include a branch 101, a trunk 102, a packaging terminal 103 and a network 104.
[0041] In the above-mentioned game system 100, the branch 101 and the trunk 102 may be two logical structures used by the development end in the development project. The branch 101 may include multiple branches. The branch 101 is a branch established when there is a development demand in the development project. The trunk 102 is used to aggregate the resource files developed on the branch 101. It should be noted that the compression of resource files is involved in both the branch 101 and the trunk 102. When compressing the resource files, it can be achieved through the packaging end 104. The packaging end 104 includes a compressed file cache area 201 and is deployed with a packaging tool 202. When the compressed file corresponding to the resource file to be compressed is stored in the compressed file cache area 201, there is no need to re-compress the resource file to be compressed, and the compressed file stored in the compressed file cache area 201 can be directly read. When the compressed file corresponding to the resource file to be compressed is not stored in the compressed file cache area 201, it is necessary to use the packaging tool 202 to compress the resource file to be compressed.
[0042] The network 104 may be a wireless network or a wired network, such as a wireless local area network (WLAN), a local area network (LAN), a cellular network, a 2G network, a 3G network, a 4G network, a 5G network, etc.
[0043] It should be noted that Figure 1 The management system diagram shown is only an example. The management system 100 described in the embodiment of the present application is to more clearly illustrate the technical solution of the embodiment of the present application, and does not constitute a limitation on the technical solution provided in the embodiment of the present application. Ordinary technicians in this field can know that with the emergence of new business scenarios, the technical solution provided in the embodiment of the present application is also applicable to similar technical problems.
[0044] The technical solution of the present application is described in detail below through specific embodiments. It should be noted that the following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments.
[0045] It should be noted that the resource file management method provided in the embodiment of the present application can be applied to project development, in which resource files need to be compressed, such as web page development, game project development, etc. In web page development or game project development, resource files such as pictures are packaged and processed. In order to more clearly introduce the embodiment of the present application, the resource file management method is applied to game project development as an example in the embodiment of the present application, and is not used to limit the application scenario of the resource file management method.
[0046] It should be noted that a resource file may be a file whose file format needs to be changed during the game development process. For example, the resource file may be a picture file, or an animation file that needs to be encrypted, or an audio file that needs to be encrypted. For the sake of ease of introduction, the resource file is taken as an example of a picture file. This application does not limit the specific type of resource file.
[0047] First, the game development process in game project development is introduced. The game development process usually includes the steps of proposing requirements, establishing branches, packaging, installing and testing, patching and iteration, continuing testing, and merging. The following is a detailed introduction to each step in the game development process:
[0048] Step 1: Propose requirements: The planners who are responsible for conceiving the game's content, rules, and gameplay will develop a detailed requirements document, which is used to describe the new features to be developed in the game or the improvements to the old features;
[0049] Step 2: Create a branch: After receiving the requirements document prepared by the requirements planner, in order not to affect the main line (usually called trunk), the developer will create a new SVN branch for development on the SVN branch;
[0050] Step 3: Packaging: After the developer has completed the development, the content on the SVN branch is packaged through the packaging device to obtain an installable package (also called an installation package). For example, an Android game is packaged into an APK (Android Package) file.
[0051] Step 4: Install and test: After receiving the installable package, the tester installs and tests it on a real device or simulator to verify the implementation, performance, and compatibility of the new function.
[0052] Step 5: Patching and Iteration: When errors are found during the testing process in step 4 or the game needs fine-tuning, the developer will fix it on the original branch and create an incremental data package (also called a patch data package) through the packaging device. The incremental data package is used to update the game version under test without re-downloading the entire game, saving time and traffic.
[0053] Step 6: Continue testing: Testers continue testing based on the updated game, and repeat this cycle until the game reaches a satisfactory quality and completion.
[0054] Step 7: Merge: When the development and testing on the SVN branch are confirmed to be correct and meet the release standards, the SVN branch will be merged into the trunk. The trunk is the latest game version to be released to the public. After the merger, the SVN branch can be abandoned or archived.
[0055] It should be noted that SVN branches and trunks refer to the logical structure of the version control system and are not limited to a physical machine. SVN branches can be created and maintained on the developer's local PC, and trunks can be created and maintained on servers. It should be noted that the physical machines where SVN branches and trunks are deployed need to have the version control system installed.
[0056] In the second step above, creating a branch means copying an independent development line from the trunk. Developers can freely experiment on the branch without affecting the stable version of the main line. Each branch is a complete development project, which contains the core code and resource files required to build the game. However, the development of changes or new features for specific needs is carried out on this branch. In other words, in theory, the content on each branch can be independently built into a complete and playable installation package.
[0057] The following Figure 2 and Figure 3 The present invention introduces a method for managing resource files provided in an embodiment of the present application.
[0058] like Figure 2 , which is a flowchart of a resource file management method provided in an embodiment of the present application, includes the following steps S101 to S103.
[0059] Step S101: In response to a compression instruction of a first resource file, adding the first resource file to a first queue to be compressed, wherein the compression instruction includes an instruction to compress the first resource file on a corresponding branch, or an instruction to compress the first resource file on a trunk.
[0060] The compression instruction of the above-mentioned first resource file can be generated by responding to the operation of the developer. For example, after the developer develops resource file 1 on the branch, he clicks the compression control, and the compression instruction of resource file 1 is generated. In some embodiments, the compression instruction of the above-mentioned first resource file can also be automatically generated after detecting that the resource file has been modified, and the present application does not make specific limitations on this. It should be noted that the method provided in the embodiment of the present application can be applied to the stage of compressing resources in the game development process. The whole process of game development may include a first compression stage of compressing resource files on the branch and a second compression stage of compressing the resource files of the branch after they are merged into the trunk. That is to say, the compression instruction of the first resource file in step S101 can be a compression instruction generated for the first resource file in the first compression stage or in the second compression stage.
[0061] In a specific implementation, in response to a compression instruction of the first resource file, the first resource file is added to a first queue to be compressed. Specifically, it can be: in response to the compression instruction of the first resource file, the SVN branch corresponding to the first resource file is determined as the SVN branch to be processed, and the total folder path of the SVN branch to be processed is added to the first queue.
[0062] It should be noted that the total folder path of the SVN branch to be processed is the root directory corresponding to the first storage path of the resource file corresponding to the SVN branch. The total folder path may include all SVN branches corresponding to the project, or only include the SVN branch to be processed.
[0063] The first queue to be compressed can be understood as a monitoring list, which records the branch paths corresponding to the resource files currently to be processed. In other words, by adding the total folder path corresponding to the SVN branch currently to be processed to the first queue to be processed, it is possible to determine which SVN branches correspond to resource files that currently need to be paid attention to and processed.
[0064] For example, if SVN branch 1, SVN branch 2, SVN branch 3, SVN branch 4 and SVN branch 5 are added to the first queue, it means that the resource files on SVN branch 1, SVN branch 2, SVN branch 3, SVN branch 4 and SVN branch 5 are all files to be processed.
[0065] Step S102: searching whether a compressed file corresponding to the first resource file is stored in a preset compressed file cache area.
[0066] It should be noted that during game project development, the project team can pre-establish a compressed file cache area.
[0067] In an embodiment of the present application, the compressed file cache area is a storage space established on a packaging device for caching compressed files corresponding to resource files in project development. Usually, one project development corresponds to a dedicated packaging device, which is used to compress and package resource files.
[0068] The resource file corresponds to source file information, which may include but is not limited to a first storage path of the resource file and a first file name of the resource file, wherein the first file name may indicate a file format of the resource file.
[0069] When a resource file has a compressed file, and the compressed file is stored in a compressed file cache area, the compressed file corresponds to compressed file cache information. The compressed file cache information may include but is not limited to a second storage path of the compressed file and a second file name of the compressed file, wherein the second storage path may include a root directory of the compressed file cache area, a sub-path for mapping the path structure of the first storage path, and a directory name for feeding back a unique identification code of the resource file, and the second file name of the compressed file may indicate the file format of the corresponding compressed file.
[0070] The resource file and the unique identification code have a one-to-one correspondence. In an optional implementation, the unique identification code of the resource file may be a hash value, which is a fixed-length value calculated by a hash function. A hash function is an algorithm that converts input data of any length (such as text, files, passwords, etc.) into a fixed-length output string. This output string is the hash value, which has the characteristics of uniqueness, fixed length, and irreversibility. Uniqueness means that for different input data, the hash function can produce different output results. Fixed length means that no matter the size of the input data, the hash function will compress it into a fixed-length string. For example, the hash function MD5 can output a 128-bit hash value based on the original file, which is usually represented by 32 hexadecimal characters, the hash function SHA-1 can output a 160-bit hash value based on the original file, which is usually represented by 40 hexadecimal characters, and the hash function SHA-256 can output a 256-bit hash value based on the original file, which is usually represented by 64 hexadecimal characters. Irreversibility means that the hash process is one-way, that is, it is difficult or almost impossible to restore the original input data from the hash value, which ensures the security of the information. In the embodiment of the present application, the unique identification code is an MD5 value obtained based on the output of the hash function MD5 as an example for explanation.
[0071] MD5 is an information digest algorithm that can generate a special string from a string or a file according to certain rules. The MD5 digest corresponding to a file is fixed. When the file content changes, its MD5 value will also be different. Therefore, MD5 values are often used in applications to verify whether a piece of data has been tampered with. The MD5 algorithm can generate a 128-bit (16-byte) hash value to ensure that the information transmission is complete and consistent.
[0072] It should be noted that the first file name can indicate the file format of the resource file through the file suffix of the resource file, and the file suffix of the picture resource file can include but is not limited to any one of ".bmp", ".png", ".jpg", ".jpeg", ".tga", ".dds", etc.; accordingly, the second file name can also indicate the file format of the compressed file through the file suffix of the corresponding compressed file, and the file suffix of the compressed file can include but is not limited to any one of ".pvr", ".ktx", etc.
[0073] In the embodiment of the present application, when multiple branches share the same cache area, different resource files may correspond to the same source file information, that is, different resource files have the same first storage path and the same first file name. In the embodiment of the present application, the resource file corresponding to the compressed file can be identified by the directory name of the unique identification code used to feedback the resource file in the compressed file cache information.
[0074] The following is an introduction to the source file information and compressed file cache information of the resource file in the resource file management method provided in the embodiment of the present application through a specific example table:
[0075] Table 1.
[0076]
[0077]
[0078] As shown in Table 1, it is assumed that the storage paths of the source files of picture A and picture B are both res / texture / test.png, that is, the first storage path of the source file of picture A is res / texture / test.png, and the first storage path of the source file of picture B is also res / texture / test.png, wherein the first file names of the source files of picture A and picture B are both test.png. Although the source file information of the source files of picture A and picture B is the same, since the MD5 value of a resource file is unique, the MD5 values of the source files of picture A and B are different. In this example, the MD5 value of the source file of picture A is called MD5A, and the MD5 value of the source file of picture B is called MD5B. Assume that the root directory of the compression cache is res_cache_path. Due to the requirements of different mobile platforms, if the source file of picture A and the source file of picture B need to be compressed into PVRTC and KTX compression formats, that is, the second file name of compressed file A corresponding to the source file of picture A will be changed to test.pvr and test.ktx, and the second file name of compressed file B corresponding to the source file of picture B will also be changed to test.pvr and test.ktx. Then the second storage path of compressed file A is res_cache_path / res / texture / test / MD5A / test.pvr and res_cache_path / res / textu re / test / MD5A / test.ktx, and the full path of compressed image of picture B is res_cache_path / res / texture / test / MD5B / test.pvr and res_cache_path / res / texture / test / MD5B / test.ktx.
[0079] In an optional implementation, the compressed file cache area corresponds to an index file, which records key-value pairs corresponding to the compressed files stored in the compressed file cache area, and the key name in the key-value pair is a unique identifier of the resource file corresponding to the compressed file.
[0080] It should be noted that the index file is used to summarize the compressed file information of each compressed file stored in the compressed file cache area. Specifically, for a compressed file, a key-value pair corresponding to the compressed file can be generated based on the unique identification code of the corresponding resource file, the first storage path, the file format of the resource file, and the file format of the compressed file, and the generated key-value pair can be stored in the index file.
[0081] A key-value pair is a data structure that is a programming language implementation of a mapping of mathematical concepts. A key-value pair consists of two parts: a key and a value. The key is used as an index for an element, while the value represents the data stored and read. This data structure is used to store and organize data so that the corresponding value can be quickly accessed through the key. The key (also called the key name) is a unique identifier used to identify the data, while the value is the stored information or data. In a key-value pair, the key must be unique so that the corresponding value can be efficiently found through the key. Specifically, the key is an identifier used to retrieve a value. The key can be of various data types, depending on the rules of the programming language or data structure used. The key can usually be a string, a number, or an object, etc. The key is used to locate a specific value in a data set. A value (also called a key-value) is the data associated with a key. It can be any form of information, such as text, numbers, Boolean values, arrays, objects, etc. A key can correspond to one value, or in some data structures, a key can correspond to multiple values (such as in some multi-valued dictionaries or mappings). Usually, values do not have to be unique, and different keys can point to the same value.
[0082] In the specific implementation of the present application, for a compressed file, the unique identification code of the resource file can be used as the key name, and the first storage path, the file format of the resource file and the file format of the compressed file can be used as key values to generate a key-value pair corresponding to the compressed file.
[0083] As shown in Table 2, it is an example table of key-value pairs of compressed files stored in the index file in the resource file management method provided in the embodiment of the present application.
[0084] Table 2.
[0085]
[0086] In Table 2, corresponding key-value pairs are generated for compressed file A and compressed file B in Table 1. For compressed file A, the key is the MD5 code of the source file of picture A, that is, MD5A. In the value, src_path=res / texture / test, that is, the first storage path of the source file of picture A, src_suffix=png, that is, the file format of the source file of picture A, and Dst_suffix=[pvr,ktx], that is, the file format of compressed file A. For compressed file B, the key is the MD5 code of the source file of picture B, that is, MD5B. In the value, src_path=res / texture / test, that is, the first storage path of the source file of picture B, src_suffix=png, that is, the file format of the source file of picture B, and Dst_suffix=[pvr,ktx], that is, the file format of compressed file B.
[0087] In an embodiment of the present application, the key value (value) may include three configuration variables, namely, the first configuration variable src_path, the second configuration variable src_suffix and the third configuration variable Dst_suffix. Among them, the first configuration variable src_path can be used to indicate the storage path of the resource file. In combination with the above Table 2, the source file of Picture A and the source file of Picture B are both stored in the directory res / texture / test. The second configuration variable src_suffix can be used to indicate the file format of the resource file. In combination with the above Table 2, the source file of Picture A and the source file of Picture B are both PNG, which is a commonly used lossless compression image format, suitable for storing image resources in network and game development. The third configuration variable Dst_suffix can be used to indicate the file format of the compressed file. Dst_suffix = [pvr, ktx] means that the corresponding compressed file can be in PVR format or KTX format.
[0088] The above is the introduction to the compressed file cache area.
[0089] In an embodiment of the present application, for the first resource file added to the first queue, it is possible to search whether a compressed file corresponding to the first resource file is stored in a preset compressed file cache area. If a compressed file corresponding to the first resource file is stored in the preset compressed file cache area, the following step S103 can be executed.
[0090] Step S103: If yes, the first resource file is deleted from the first queue, and the first compressed file corresponding to the first resource file stored in the compressed file cache is read.
[0091] It should be noted that in the embodiment of the present application, whether the first resource file is compressed in the above-mentioned first compression stage or in the above-mentioned second compression stage, it is possible that the first resource file is currently compressed. For example, the first resource file has been compressed on branch 1, and the corresponding first compressed file is stored in the compressed file cache area. In this way, whether the first resource file is compressed on branch 2 or merged into the trunk for compression, the first compressed resource has been compressed, and the first compressed file is correspondingly stored in the compressed file cache area.
[0092] In the embodiment of the present application, when a compressed file corresponding to the first resource file is stored in the preset compressed file cache area, the first resource file can be deleted from the first queue, and the first compressed file corresponding to the stored first resource file can be read from the compressed file cache area, which can effectively avoid the time consumption caused by re-compressing the first compressed file.
[0093] It should be noted that for each resource file in the first queue, the preset compressed file cache area can be accessed to find whether a corresponding compressed file is stored therein. In the case of a corresponding compressed file found, the resource file in the first queue can be deleted, and the compressed file corresponding to the resource file stored in the compressed file cache area can be read, thereby avoiding re-compression of the compressed file.
[0094] In a specific implementation, after obtaining the first queue, the resource file management method provided by the embodiment of the present application may further include the following steps:
[0095] Resource files whose corresponding compressed files exist in the compressed file cache area are removed from the first queue to obtain a fourth queue containing target resource files, wherein the target resource files are resource files in the first queue whose corresponding compressed files do not exist in the compressed file cache area.
[0096] In the embodiment of the present application, the resource files included in the first queue can be screened based on the compressed files cached in the compressed file cache area, thereby obtaining a fourth queue containing target resource files for which there are no corresponding compressed files in the compressed file cache area. In this way, the target resource files obtained by screening are files that really need to be compressed.
[0097] In this way, directly reading the compressed file corresponding to the non-target resource file (that is, the resource file whose corresponding compressed file exists in the compressed file cache) from the compressed file cache can avoid re-compressing the compressed resource file and save the compression time of the resource file in project development.
[0098] The resource file management method provided by the embodiment of the present application includes: in response to the compression instruction of the first resource file, adding the first resource file to the first queue to be compressed, wherein the compression instruction includes an instruction to compress the first resource file on the corresponding branch, or an instruction to compress the first resource file on the trunk; searching whether the compressed file corresponding to the first resource file is stored in the preset compressed file cache; if so, deleting the first resource file from the first queue, and reading the first compressed file corresponding to the first resource file stored in the compressed file cache. It can be seen that the resource file management method provided by the embodiment of the present application, when there is a first compressed file corresponding to the first resource file added to the first queue to be compressed in the preset compressed file cache, removes the first resource file from the first queue, and reads the first compressed file stored in the compressed file cache, so that the time consumed by the first resource file being recompressed can be saved. When the number of resource files included in the entire project development is large, the resource file management method provided by the embodiment of the present application can effectively solve the problem of long time consumption caused by the resource files needing to be compressed multiple times in project development, thereby improving the efficiency of project development.
[0099] It should be noted that, in the embodiment of the present application, "reading the first compressed file corresponding to the first resource file stored in the compressed file cache area" in step S103 can specifically be: copying the first compressed file to a target path, and the target path is used to store compressed files.
[0100] It should be noted that the target path is the location where the compressed file should be stored in game development, and the target path is usually set by the project team. In game development, a resource file in the image format is usually stored in the res file of the branch, and the compressed file is usually stored in the corresponding res_platforms file (that is, the target path). For example, in the development of Project 1, the resource file in the image format is stored in res / texture / test.png, and the corresponding compressed file is stored in res_platforms / texture / test.png.
[0101] By placing compressed files in a specific target path, you can keep the project directory structure clear and orderly. This organization allows everyone in the project team to quickly distinguish between resource files and compressed files, which is beneficial for file management and maintenance. In the version control system, storing resource files and compressed files separately helps with version management and backtracking.
[0102] When there is no compressed file corresponding to the first resource file in the compressed file cache area, that is, when the first resource file is the above-mentioned target resource file, the first resource file can be compressed. Therefore, the method provided in the embodiment of the present application can also include the following steps:
[0103] If the search result of step S102 is no, compressing the first resource file in the first queue to obtain a corresponding first compressed file;
[0104] The first compressed file is stored in the compressed file buffer area.
[0105] In an embodiment of the present application, when there is no compressed file corresponding to the first resource file in the compressed file cache area, the first resource file in the first queue can be retained. When the first queue includes multiple resource files, the resource files in the first queue can be compressed according to a certain compression order by a packaging device, thereby achieving compression processing of the first resource file in the first queue to obtain the corresponding first compressed file. After that, the first compressed file can be stored in the compressed file cache area.
[0106] In an embodiment of the present application, the compression instruction of the first resource file can be generated when a new first resource file is developed, or it can be generated when the first version of the first resource file is modified to the second version of the first resource file. Accordingly, in response to the compression instruction of the first resource file, the packaging device can package the first resource file or patch the first resource file (also called patching).
[0107] Packaging refers to the collection of a series of related files into a deployable unit, such as a software installation package or resource package. When an SVN branch has completed a certain stage of development work, all functions and resources have been integrated, and it is ready for testing or deployment, the branch needs to be packaged. For example, when a new version of a game is developed, including new game levels and character skins, all related files of this branch will be packaged into a resource package for testing or online use.
[0108] Patching is to generate a smaller file that describes the difference between one known version and another, and is mainly used for updates. Patches are made when only a part of the files or functions need to be updated, and the user does not need to re-download the entire package. For example, a game project needs to add a belt detail to a character's skin. At this time, only the difference of the repaired part needs to be made into a patch for users to download. Users can apply the patch based on the original version without downloading the entire game client.
[0109] In a specific implementation, after the resource files in the first queue are screened to obtain the fourth queue, the target resource files contained in the fourth queue can be compressed to obtain the corresponding target compressed files. It can be understood that, in the case where there is no compressed file corresponding to the first resource file in the compressed file cache, the first resource file is one of the target resource files, and the first compressed file is one of the generated target compressed files.
[0110] Afterwards, the target compressed file may be stored in a second storage path corresponding to the compressed file cache area, and a key-value pair corresponding to the target compressed file may be determined, and the key-value pair corresponding to the target compressed file may be added to the index file.
[0111] In an optional implementation, step S102 may be implemented by the following steps:
[0112] Determine a target unique identifier of the first resource file, and search the index file for a target key-value pair whose key name is the target unique identifier;
[0113] If the target key-value pair exists in the index file, determining that a compressed file corresponding to the first resource file is stored in the compressed file cache;
[0114] If the target key-value pair does not exist in the index file, it is determined that the compressed file corresponding to the first resource file is not stored in the compressed file cache.
[0115] In an embodiment of the present application, during the resource file compression process, the unique identifier can be used to accurately and efficiently determine whether there is a compressed file in the compressed file cache area for the resource files contained in the first queue. If the unique identifier corresponding to a resource file can be found in the index file, it is determined that the compressed file corresponding to the resource file is stored in the compressed file cache area. Conversely, if the unique identifier corresponding to the resource file cannot be found in the index file, it is determined that the compressed file corresponding to the resource file is not stored in the compressed file cache area.
[0116] When the unique identifier is an MD5 code, for a resource file in the first queue, its corresponding MD5 code can be calculated, and a search can be conducted in the index file to determine whether a key-value pair with the key name being the MD5 code exists. If so, it is determined that the compressed file corresponding to the resource file is stored in the compressed file cache area. Otherwise, if not, it is determined that the compressed file corresponding to the resource file is not stored in the compressed file cache area.
[0117] Therefore, the above step of "determining the target unique identifier of the first resource file, and searching whether there is a target key-value pair with a key name equal to the target unique identifier in the index file" can specifically be: calculating the MD5 code of the first resource file, and searching whether there is a target key-value pair with a key name equal to the MD5 code of the first resource file in the index file.
[0118] If the MD5 code calculated for a resource file can be found in the index file, it means that the resource file has been compressed before, and the corresponding compressed file is stored in the compressed file cache.
[0119] In this way, through the unique identifier and the index file, it can be quickly determined whether the first resource file has been compressed, thereby avoiding re-compression of the compressed resource file.
[0120] For example, resource file 1 has been compressed during testing on the branch, and the corresponding compressed file 1 is stored in the compressed file cache, and the key-value pair of compressed file 1 is recorded in the index file, where the key name is the MD5 code of resource file 1. When merging to the trunk, resource file 1 is not modified, but resource file 1 is directly merged. At this time, when resource file 1 is compressed again on the trunk, the MD5 code of resource file 1 can be calculated first. In this way, the key-value pair with the key name of the MD5 code can be found from the index file. In this way, the compressed file 1 stored in the compressed file cache can be directly read to avoid re-compression of resource file 1.
[0121] In an optional implementation, the step of "storing the first compressed file in the compressed file cache area" can be implemented according to the following steps:
[0122] Determine a second storage path where the first compressed file is to be stored in the compressed file cache area;
[0123] The first compressed file is stored in the second storage path.
[0124] In an optional implementation, the above step of "determining a second storage path where the first compressed file is to be stored in the compressed file cache area" can be implemented according to the following steps:
[0125] Acquire a first storage path where the first resource file is stored, and determine a target unique identifier of the first resource file;
[0126] Determine a subpath under the root directory of the compressed file cache area according to the first storage path;
[0127] Using the target unique identifier as the directory name under the subpath;
[0128] The second storage path is generated according to the sub-path and the directory name.
[0129] It should be noted that, when the compressed file has the above-mentioned compressed file cache information, in an embodiment of the present application, after the first resource file is compressed by the packaging device to generate the first compressed file, the second storage path where the first compressed file is to be stored in the compressed file cache area can be determined first, and the first compressed file can be stored in the second storage path.
[0130] In a specific implementation method, the first storage path where the first resource file is stored can be obtained, and the target unique identifier of the first resource file can be determined. When the unique identifier is an MD5 code, the MD5 code of the first resource file can be calculated, and the MD5 code of the first resource file can be determined as the target unique identifier. Thereafter, based on the information included in the second storage path in the aforementioned compressed file cache information, the second storage path where the first compressed file is to be stored in the compressed file cache area is determined.
[0131] Specifically, the above-mentioned “determining a subpath under the root directory of the compressed file cache area according to the first storage path; using the target unique identifier as the directory name under the subpath; generating the second storage path according to the subpath and the directory name” may be:
[0132] Determine a sub-path for mapping the path structure of the first storage path, and determine a directory name for feeding back a target unique identifier;
[0133] A second storage path is generated including the root directory of the compressed file cache area, the sub-path and the directory name.
[0134] In this way, the first compressed file is stored in the second storage path.
[0135] In an optional implementation, the resource file management method provided in the embodiment of the present application may further include the following steps:
[0136] In the case of storing the first compressed file in the second storage path, using the target unique identifier as the key name of a target key-value pair, and using the first storage path, the file format of the first resource file, and the file format of the first compressed file as the key values of the target key-value pair to generate the target key-value pair;
[0137] Add the target key-value pair to the index file.
[0138] In the embodiment of the present application, after compressing the first resource file by the packaging device to obtain the first compressed file and storing the first compressed file in the compressed file cache area, the target key-value pair corresponding to the first compressed file can also be added to the index file.
[0139] The above step of "using the target unique identifier as the key name of the target key-value pair, and using the first storage path, the file format of the first resource file, and the file format of the first compressed file as the key values of the target key-value pair, to generate the target key-value pair" can specifically be: using the above target unique identifier as the key name of the target key-value pair, and configuring the first configuration variable corresponding to the key value of the target key-value pair as the first storage path, configuring the second configuration variable corresponding to the key value of the target key-value pair as the file format of the first resource file, and configuring the third configuration variable corresponding to the key value of the target key-value pair as the file format of the first compressed file, thereby generating the target key-value pair.
[0140] In this way, by adding the key-value pairs corresponding to the compressed files into the index file, when a resource file needs to be compressed, it can be determined from the key-value pairs recorded in the index file whether the resource file has a corresponding compressed file stored in the compressed file cache area, thereby effectively avoiding compressing a compressed file twice.
[0141] In an optional implementation manner, the above step of “compressing the first resource file in the first queue to obtain a corresponding first compressed file” may include the following steps:
[0142] Determining whether there are modified resource files in the first queue;
[0143] In a case where the modified resource file includes the first resource file, the first resource file is compressed to obtain the first compressed file.
[0144] In an embodiment of the present application, after the total folder path corresponding to the SVN branch is added to the first queue, the version changes of each resource file corresponding to each SVN branch in the first queue can be compared, and the modified resource files can be determined from the first queue, thereby generating a second queue containing the modified resource files.
[0145] In this way, when the second queue contains the first resource file, the first resource file can be compressed to obtain the first compressed file.
[0146] It should be noted that the step of "determining whether there are modified resource files in the first queue" and the step of "searching whether the preset compressed file cache area stores compressed files corresponding to the first resource file" may not have an execution order, that is, there is no execution order between processing the first queue to obtain the fourth queue and processing the first queue to obtain the second queue. The second queue may be obtained first, and then the second queue may be processed to obtain modified resource files whose corresponding compressed files do not exist in the compressed file cache area. Alternatively, the fourth queue may be obtained first, and then the fourth queue may be processed to obtain modified resource files whose corresponding compressed files do not exist in the compressed file cache area.
[0147] In an optional specific implementation, the above step of "determining whether there is a modified resource file in the first queue" can be implemented according to the following steps:
[0148] For each resource file in the first queue, obtaining a first generation time of the resource file and a second generation time of a compressed file corresponding to the resource file in the compressed file cache area;
[0149] If the first generation time is later than the second generation time, the corresponding version of the resource file is a modified resource file.
[0150] In an embodiment of the present application, for each resource file in the first queue, the first generation time of the resource file and the second generation time of the compressed file corresponding to the resource file in the compressed file cache area can be obtained; when the first generation time is later than the second generation time, the version of the resource file corresponding to the first generation time is determined to be a modified resource file; conversely, when the first generation time is earlier than or equal to the second generation time, the version of the resource file corresponding to the first generation time is determined to be an unmodified resource file.
[0151] For example, the resource file was last modified in version 1, and the corresponding compressed file was last modified in version 2. If the generation time of version 1 is earlier than that of version 2, it means that the compressed file is the latest and the resource file has not been modified since the last compression. If the generation time of version 1 is earlier than that of version 2, it means that the compressed file is not the latest and the resource file has been modified, and the resource file needs to be recompressed.
[0152] It should be noted that by screening the resource files contained in the first queue, filtering out the unmodified resource files, and obtaining only the second queue containing the modified resource files, when the first queue contains a large number of unmodified resource files, since the unmodified resource files have been compressed before, by screening out the modified resource files, the compressed files that really need to be processed can be quickly located, effectively avoiding the consumption of computing resources and waste of time caused by compressing all the resource files in the entire first queue.
[0153] In an optional implementation manner, when the compressed file cache area stores a compressed file in a picture format, the above step of "compressing the first resource file to obtain the first compressed file" can be implemented by the following steps:
[0154] Screening the modified resource files by format to obtain resource files in picture format;
[0155] When the resource file in the picture format includes the first resource file, the first resource file is compressed to obtain the first compressed file.
[0156] In the embodiment of the present application, after obtaining the second queue containing the modified resource file, the resource files in the second queue can be screened by format to obtain a third queue containing resource files in image format. In this way, when the third queue contains the first resource file, the first resource file in the third queue can be compressed to obtain a first compressed file.
[0157] In an optional specific implementation, the resource files in the second queue can be screened by suffix name, and resource files with target suffix names can be retained, thereby obtaining a third queue containing resource files with target suffix names, wherein the target suffix name indicates that the corresponding resource file is in image format.
[0158] The target suffix may include but is not limited to ".bmp", ".png", ".jpg", ".jpeg", ".tga", ".dds". The target suffixes listed above are commonly used image suffixes, which can be used to distinguish images from other files. In game development, other file format suffixes include ".Gim", ".py", etc. Among them, ".Gim" is usually the suffix of model files, and ".py" is usually the suffix of python files.
[0159] It should be noted that, in the embodiment of the present application, the files in the compressed file cache area can also be cleaned up. The resource file management method provided in the embodiment of the present application can also include the following steps:
[0160] In response to a deletion instruction of the first SVN branch, the first SVN branch is deleted, and a resource file corresponding to the first SVN branch is deleted from the first queue to be processed;
[0161] In response to the compressed file clearing instruction, the compressed files corresponding to the resource files not in the first queue and stored in the compressed file cache are cleared.
[0162] It should be noted that after the SVN branch is merged into the trunk and the resource files corresponding to the branch are compressed, indicating that the SVN demand development of the branch is completed, the SVN branch can be abandoned and deleted. In an embodiment of the present application, a deletion instruction for the first SVN branch can be generated in response to a developer's deletion operation on the first SVN branch. In response to the deletion instruction for the first SVN branch, not only the first SVN branch can be deleted, but also the resource files corresponding to the first SVN branch in the first queue can be deleted.
[0163] When the first SVN branch is deleted, the compressed files stored in the compressed file cache area of the SVN branch may be cleared accordingly.
[0164] It should be noted that in the embodiment of the present application, when each SVN branch deletion instruction is generated, a compressed file clearing instruction can be automatically generated, or a compressed file clearing instruction can be manually issued, and the compressed file clearing instruction is used to clear the compressed files corresponding to the resource files stored in the compressed file cache that do not belong to the first queue. And the redundant compressed files are cleared through the following clearing process:
[0165] For each key-value pair recorded in the index file, determine the corresponding target storage path according to the corresponding key name;
[0166] Find whether there is a resource file corresponding to the i-th SVN branch in the first queue under the target storage path, where i traverses 1 to n, and n is the number of SVN branches in the first queue;
[0167] If not, the targeted key-value pair is deleted from the index file, and the compressed file corresponding to the targeted key-value pair stored in the compressed file cache is deleted.
[0168] In an embodiment of the present application, if it is found that a resource file no longer exists in the folder of the current branch, it can be considered that the compressed file corresponding to the resource file is redundant. In this case, the compressed file corresponding to the resource file can be automatically cleared from the compressed file cache area to free up storage space and avoid resource confusion.
[0169] In a specific implementation, the clearing process can be performed according to the following specific steps:
[0170] a. Initialize an empty index file E;
[0171] b. Perform steps c to g for each key-value pair k in index file C:
[0172] c. Determine the expected storage path of the original resource file t corresponding to the key-value pair k;
[0173] d. Traverse n SVN branches in the first queue, where n is the number of SVN branches in the first queue;
[0174] e. Check in each SVN branch whether the original resource file t exists in the expected storage path determined in step c;
[0175] f. If the original resource file t exists in any SVN branch, the MD5 code of the original resource file is calculated, and the calculated MD5 code is compared with the key name in the key-value pair k to see if they are consistent. If they are consistent, it means that the original resource file is the resource file corresponding to the key-value pair k, and then jump to step b to continue checking the next key-value pair in the index file C; if the calculated MD5 code of the original resource file is inconsistent with the key name in the key-value pair k, or if the original resource file t is not found in all branches, the key-value pair k is recorded in the index file E;
[0176] g. Update index file C according to the content of index file E. Specifically, clear the key-value pairs recorded in index file E from index file C to obtain updated index file F, and simultaneously clear the compressed file cache area and the compressed files associated with the cleared key-value pairs to obtain the cleared compressed file cache area.
[0177] It should be noted that the updated index file F is the index file after the key-value pairs corresponding to the redundant compressed files are cleared, and the cleared compressed file cache is the compressed file cache after the redundant compressed files are cleared.
[0178] The following Figure 3 The compression process in the resource file management method provided in the embodiment of the present application is introduced. Figure 3 FIG. 1 is a schematic diagram of a compression process in a resource file management method provided in an embodiment of the present application, including the following steps S20 to S28:
[0179] Step S20: in response to the compression instruction of the resource file a, the total folder path of the SVN branch corresponding to the resource file a is added to the compression cache area list D;
[0180] Step S21: Compare the version changes of the resource files in the image compression buffer list D to obtain a modified file list list1;
[0181] Step S22: filter the suffixes of list1, retain the resource files with suffixes (".bmp", ".png", ".jpg", ".jpeg", ".dds"), and obtain the file list list2 that needs to be compressed;
[0182] Step S23: Obtain the md5 code for each resource file in list2;
[0183] Step S24: determining whether the index file C corresponding to the compressed file buffer area has an md5 code recorded therein;
[0184] If yes, then execute step S25: read the compressed file corresponding to the md5 code from the compressed file buffer area, and delete the resource file corresponding to the md5 code from list2;
[0185] If not, execute step S26: keep the resource file corresponding to the md5 code in list2;
[0186] After step S25 and step S26, an uncompressed file list list3 is generated;
[0187] Step S27: compress the resource files in list3 into compressed files of corresponding compression formats through the packaging device;
[0188] Step S28: Store the compressed file in the compressed file buffer area and update the index file C.
[0189] It should be noted that the above Figure 3 The image compression buffer list D in is a specific example of the first queue, the file list list1 is a specific example of the second queue, the file list list2 is a specific example of the third queue, the file list lst3 is a specific example of the fourth queue, and the index file C is a specific example of the index file. The first queue, the second queue, the third queue, the fourth queue and the index file have been introduced in the above content, and will not be repeated here.
[0190] The above is an introduction to the resource file management method provided in the embodiment of the present application. The method aims to automatically manage and optimize resource files in SVN branches, reduce duplication of work, improve development efficiency, and ensure effective management and version control of resources.
[0191] For example, in the process of compressing 1,000 resource files, in the traditional process, each resource file is compressed at least twice, that is, 1,000 resource files need to be compressed at least 2,000 times, while through the resource file management method provided in the embodiment of the present application, each resource file only needs to be compressed once, that is, 1,000 resource files need to be compressed a total of 1,000 times, which improves the compression efficiency by at least 50%, and saves at least 50% of the compression time on the original compression time. It can be seen that the resource file management method improved by the embodiment of the present application can objectively reduce repetitive work and improve development efficiency.
[0192] Corresponding to the resource file management method provided in the first embodiment of the present application, the second embodiment of the present application further provides a resource file management device, such as Figure 4 As shown, the resource file management device 400 includes:
[0193] An adding unit 401 is used for adding the first resource file to a first queue to be compressed in response to a compression instruction of the first resource file, wherein the compression instruction includes an instruction to compress the first resource file on a corresponding branch, or an instruction to compress the first resource file on a trunk;
[0194] A searching unit 402 is used to search whether a compressed file corresponding to the first resource file is stored in a preset compressed file cache area;
[0195] The processing unit 403 is configured to delete the first resource file from the first queue if yes, and read the first compressed file corresponding to the first resource file stored in the compressed file cache area.
[0196] Optionally, the processing unit 403 is further configured to:
[0197] If not, compressing the first resource file in the first queue to obtain a corresponding first compressed file;
[0198] The first compressed file is stored in the compressed file buffer area.
[0199] Optionally, the compressed file cache area corresponds to an index file, and the index file records key-value pairs corresponding to the compressed files stored in the compressed file cache area, and the key name in the key-value pair is a unique identifier of the resource file corresponding to the compressed file.
[0200] Optionally, the searching unit 402 is specifically configured to:
[0201] Determine a target unique identifier of the first resource file, and search the index file for a target key-value pair whose key name is the target unique identifier;
[0202] If the target key-value pair exists in the index file, determining that a compressed file corresponding to the first resource file is stored in the compressed file cache;
[0203] If the target key-value pair does not exist in the index file, it is determined that the compressed file corresponding to the first resource file is not stored in the compressed file cache.
[0204] Optionally, the processing unit 403 is further specifically configured to:
[0205] Determine a second storage path where the first compressed file is to be stored in the compressed file cache area;
[0206] The first compressed file is stored in the second storage path.
[0207] Optionally, the processing unit 403 is further specifically configured to:
[0208] Acquire a first storage path where the first resource file is stored, and determine a target unique identifier of the first resource file;
[0209] Determine a subpath under the root directory of the compressed file cache area according to the first storage path;
[0210] Using the target unique identifier as the directory name under the subpath;
[0211] The second storage path is generated according to the sub-path and the directory name.
[0212] Optionally, the processing unit 403 is further configured to:
[0213] In the case of storing the first compressed file in the second storage path, using the target unique identifier as the key name of a target key-value pair, and using the first storage path, the file format of the first resource file, and the file format of the first compressed file as the key values of the target key-value pair to generate the target key-value pair;
[0214] Add the target key-value pair to the index file.
[0215] Optionally, the processing unit 403 is further specifically configured to:
[0216] Determining whether there are modified resource files in the first queue;
[0217] In a case where the modified resource file includes the first resource file, the first resource file is compressed to obtain the first compressed file.
[0218] Optionally, the processing unit 403 is further specifically configured to:
[0219] For each resource file in the first queue, obtaining a first generation time of the resource file and a second generation time of a compressed file corresponding to the resource file in the compressed file cache area;
[0220] If the first generation time is later than the second generation time, the corresponding version of the resource file is a modified resource file.
[0221] Optionally, when the compressed file cache area stores a compressed file in a picture format, the processing unit 403 is further configured to:
[0222] Screening the modified resource files by format to obtain resource files in picture format;
[0223] When the resource file in the picture format includes the first resource file, the first resource file is compressed to obtain the first compressed file.
[0224] Optionally, the modified resource files form a second queue, and the processing unit 403 is further specifically configured to:
[0225] The resource files in the second queue are screened by suffix names, resource files with target suffix names are retained, and a third queue containing resource files with target suffix names is obtained, wherein the target suffix name indicates that the corresponding resource file is in a picture format.
[0226] Optionally, the resource file management device 400 further includes a deleting unit, and the deleting unit is used to:
[0227] In response to a deletion instruction of the first SVN branch, the first SVN branch is deleted, and a resource file corresponding to the first SVN branch is deleted from the first queue;
[0228] In response to the compressed file clearing instruction, the compressed files corresponding to the resource files not in the first queue and stored in the compressed file cache are cleared.
[0229] Optionally, the deleting unit is specifically used for:
[0230] For each key-value pair recorded in the index file, determine the corresponding target storage path according to the corresponding key name;
[0231] Find whether there is a resource file corresponding to the i-th SVN branch in the first queue under the target storage path, where i traverses 1 to n, and n is the number of SVN branches in the first queue;
[0232] If not, the targeted key-value pair is deleted from the index file, and the compressed file corresponding to the targeted key-value pair stored in the compressed file cache is deleted.
[0233] Corresponding to the resource file management method provided in the first embodiment of the present application, the third embodiment of the present application further provides an electronic device for managing resource files. Figure 5 As shown, the electronic device 500 includes: a processor 501; and a memory 502, which is used to store a program of a resource file management method. After the device is powered on and the program of the resource file management method is run by the processor, the following steps are performed:
[0234] In response to a compression instruction of a first resource file, adding the first resource file to a first queue to be compressed, wherein the compression instruction includes an instruction to compress the first resource file on a corresponding branch, or an instruction to compress the first resource file on a trunk;
[0235] Searching whether a compressed file corresponding to the first resource file is stored in a preset compressed file cache area;
[0236] If so, the first resource file is deleted from the first queue, and the first compressed file corresponding to the first resource file stored in the compressed file cache is read.
[0237] Corresponding to the resource file management method provided in the first embodiment of the present application, the fourth embodiment of the present application provides a computer-readable storage medium storing a program of the resource file management method, the program is executed by a processor to perform the following steps:
[0238] In response to a compression instruction of a first resource file, adding the first resource file to a first queue to be compressed, wherein the compression instruction includes an instruction to compress the first resource file on a corresponding branch, or an instruction to compress the first resource file on a trunk;
[0239] Searching whether a compressed file corresponding to the first resource file is stored in a preset compressed file cache area;
[0240] If so, the first resource file is deleted from the first queue, and the first compressed file corresponding to the first resource file stored in the compressed file cache is read.
[0241] It should be noted that for the detailed description of the devices, electronic devices and computer-readable storage media provided in the second, third and fourth embodiments of the present application, reference can be made to the relevant description of the first embodiment of the present application, and no further details will be given here.
[0242] Although the present application is disclosed as above in the form of a preferred embodiment, it is not intended to limit the present application. Any technical personnel in this field may make possible changes and modifications without departing from the spirit and scope of the present application. Therefore, the scope of protection of the present application shall be based on the scope defined by the claims of the present application.
[0243] In a typical configuration, a node device in a blockchain includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0244] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0245] 1. Computer-readable media includes permanent and non-permanent, removable and non-removable media that can be used to store information by any method or technology. Information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), random access memory (RAM) of other attributes, read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage media or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined in this article, computer-readable media does not include non-transitory media such as modulated data signals and carrier waves.
[0246] 2. Those skilled in the art should understand that the embodiments of the present application can be provided as methods, systems or computer program products. Therefore, the present application can take the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware. Moreover, the present application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0247] Although the present application is disclosed as above in the form of a preferred embodiment, it is not intended to limit the present application. Any technical personnel in this field may make possible changes and modifications without departing from the spirit and scope of the present application. Therefore, the scope of protection of the present application shall be based on the scope defined by the claims of the present application.
Claims
1. A method for managing resource files, It is characterized in that The method comprises: In response to a compression instruction of a first resource file, adding the first resource file to a first queue to be compressed, wherein the compression instruction includes an instruction to compress the first resource file on a corresponding branch, or an instruction to compress the first resource file on a trunk; Searching whether a compressed file corresponding to the first resource file is stored in a preset compressed file cache area; If so, the first resource file is deleted from the first queue, and the first compressed file corresponding to the first resource file stored in the compressed file cache is read.
2. The method according to claim 1, It is characterized in that The method further comprises: If not, compressing the first resource file in the first queue to obtain a corresponding first compressed file; The first compressed file is stored in the compressed file buffer area.
3. The method according to claim 2, It is characterized in that The compressed file cache area corresponds to an index file, and the index file records key-value pairs corresponding to the compressed files stored in the compressed file cache area. The key name in the key-value pair is a unique identifier of the resource file corresponding to the compressed file.
4. The method according to claim 3, It is characterized in that The searching whether a compressed file corresponding to the first resource file is stored in a preset compressed file cache area includes: Determine a target unique identifier of the first resource file, and search the index file for a target key-value pair whose key name is the target unique identifier; If the target key-value pair exists in the index file, determining that a compressed file corresponding to the first resource file is stored in the compressed file cache; If the target key-value pair does not exist in the index file, it is determined that the compressed file corresponding to the first resource file is not stored in the compressed file cache.
5. The method according to claim 3, It is characterized in that The storing the first compressed file in the compressed file buffer area comprises: Determine a second storage path where the first compressed file is to be stored in the compressed file cache area; The first compressed file is stored in the second storage path.
6. The method according to claim 5, It is characterized in that The determining a second storage path where the first compressed file is to be stored in the compressed file cache area includes: Acquire a first storage path where the first resource file is stored, and determine a target unique identifier of the first resource file; Determine a subpath under the root directory of the compressed file cache area according to the first storage path; Using the target unique identifier as the directory name under the subpath; The second storage path is generated according to the sub-path and the directory name.
7. The method according to claim 6, It is characterized in that The method further comprises: In the case of storing the first compressed file in the second storage path, using the target unique identifier as the key name of a target key-value pair, and using the first storage path, the file format of the first resource file, and the file format of the first compressed file as the key values of the target key-value pair to generate the target key-value pair; Add the target key-value pair to the index file.
8. The method according to claim 2, It is characterized in that The compressing the first resource file in the first queue to obtain a corresponding first compressed file includes: Determining whether there are modified resource files in the first queue; In a case where the modified resource file includes the first resource file, the first resource file is compressed to obtain the first compressed file.
9. The method according to claim 8, It is characterized in that The determining whether there is a modified resource file in the first queue includes: For each resource file in the first queue, obtaining a first generation time of the resource file and a second generation time of a compressed file corresponding to the resource file in the compressed file cache area; If the first generation time is later than the second generation time, the corresponding version of the resource file is a modified resource file.
10. The method according to claim 8, It is characterized in that In the case where the compressed file cache area stores a compressed file in a picture format, compressing the first resource file to obtain the first compressed file includes: Screening the modified resource files by format to obtain resource files in picture format; When the resource file in the picture format includes the first resource file, the first resource file is compressed to obtain the first compressed file.
11. The method according to claim 10, It is characterized in that The modified resource files form a second queue, and the format of the modified resource files is screened to obtain resource files in picture format, including: The resource files in the second queue are screened by suffix names, resource files with target suffix names are retained, and a third queue containing resource files with target suffix names is obtained, wherein the target suffix name indicates that the corresponding resource file is in a picture format.
12. The method according to claim 3, It is characterized in that The method further comprises: In response to a deletion instruction of the first SVN branch, the first SVN branch is deleted, and a resource file corresponding to the first SVN branch is deleted from the first queue; In response to the compressed file clearing instruction, the compressed files corresponding to the resource files not in the first queue and stored in the compressed file cache are cleared.
13. The method according to claim 12, It is characterized in that The clearing of the compressed files corresponding to the resource files not in the first queue and stored in the compressed file cache area includes: For each key-value pair recorded in the index file, determine the corresponding target storage path according to the corresponding key name; Find whether there is a resource file corresponding to the i-th SVN branch in the first queue under the target storage path, where i traverses 1 to n, and n is the number of SVN branches in the first queue; If not, the targeted key-value pair is deleted from the index file, and the compressed file corresponding to the targeted key-value pair stored in the compressed file cache is deleted.
14. A resource file management device, It is characterized in that The device comprises: an adding unit, configured to add the first resource file to a first queue to be compressed in response to a compression instruction of the first resource file, wherein the compression instruction includes an instruction to compress the first resource file on a corresponding branch, or an instruction to compress the first resource file on a trunk; A searching unit, used for searching whether a compressed file corresponding to the first resource file is stored in a preset compressed file cache area; The processing unit is configured to, if yes, delete the first resource file from the first queue, and read the first compressed file corresponding to the first resource file stored in the compressed file cache area.
15. An electronic device, It is characterized in that include: processor; as well as The memory is used to store a data processing program. After the electronic device is powered on and the program is run by the processor, the method according to any one of claims 1 to 13 is executed.
16. A computer-readable storage medium, It is characterized in that A data processing program is stored, and the program is run by a processor to execute the method according to any one of claims 1 to 13.
Citation Information
Cited By
Picture compression method and device for application, equipment and program product
CN120994625A
