A method and device for processing files

By calculating the file value of the file to be processed and decompressing it to memory for processing when needed, the problem of low efficiency of compressed file processing in the existing technology is solved and a more efficient file processing process is realized.

CN113553307BActive Publication Date: 2024-09-27北京天空卫士网络安全技术有限公司
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202110811673.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-07-19
Publication Date
2024-09-27
Estimated Expiration
2041-07-19

AI Technical Summary

Technical Problem

The existing technology has the problem of low efficiency when processing compressed files. Especially when a large number of compressed files need to be processed, the same files need to be frequently decompressed and repeatedly processed, resulting in increased resource consumption and processing time.

Method used

By calculating the file value of the file to be processed, it is judged whether it exists in the processing set, and if it exists, the resources are released; if it does not exist, the compressed file is decompressed into the memory for processing, and the file information is stored or released according to the processing results to avoid repeated processing.

Benefits of technology

It improves the efficiency of processing compressed files, reduces the reading and writing operations on storage media, and improves the processing speed and resource utilization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113553307B
    Figure CN113553307B
Patent Text Reader

Abstract

The present invention discloses a method and device for processing files, and relates to the field of computer technology. A specific implementation of the method includes: being able to calculate the file value of a compressed file to be processed, determining whether the file needs to be processed by judging whether the file value exists in an existing processing set, and if processing is required, decompressing each target file contained in the compressed file into a memory, and processing each file; according to the processing result, storing the obtained target file information matching the target feature in a target set; and releasing the to-be-processed files that do not need to be processed or have been processed from the memory, thereby improving the efficiency of processing compressed files.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a method and device for processing files. Background Art

[0002] With the rapid development of Internet technology, Internet applications have become an indispensable tool in people's life and work. In order to improve data transmission efficiency and reduce network resource consumption, Internet applications usually compress multiple files before transmitting them.

[0003] When it is necessary to process a compressed file, for example, to determine whether the compressed file and the files it contains match target features such as set keywords and set sensitive data, it is usually necessary to decompress the compressed file to a storage medium, then process the decompressed file and clean up the file accordingly after the processing is completed. If the compressed file being processed contains the same file compressed multiple times, the problem of repeated processing of the same file is caused. Therefore, when the number of compressed files to be processed is large, the existing method of processing files has the problem of low processing efficiency. Summary of the invention

[0004] In view of this, an embodiment of the present invention provides a method and device for processing files, which can calculate the file value of a compressed file to be processed, and determine whether the file needs to be processed by judging whether the file value exists in an existing processing set. If processing is required, each target file contained in the compressed file is decompressed into a memory and each file is processed; based on the processing result, the obtained target file information matching the target feature is stored in a target set; and the files to be processed that do not need to be processed or have been processed are released from the memory, thereby improving the efficiency of processing compressed files.

[0005] To achieve the above-mentioned purpose, according to one aspect of an embodiment of the present invention, a processing method is provided, which is characterized by comprising: N1: obtaining a compressed file to be processed, and taking the compressed file as the file to be processed; N2: calculating the file value of the file to be processed, and determining whether the file value of the file to be processed exists in a processing set; if so, releasing the file to be processed from the memory; otherwise executing N3; N3: decompressing multiple target files contained in the file to be processed into the memory, and processing the decompressed multiple target files.

[0006] Optionally, the method for processing files is characterized in that the processing of the decompressed multiple target files includes: taking each of the target files as a file to be processed and executing step N2; if the file to be processed is a non-compressed file and step N2 determines that the file value of the file to be processed is not in the processing set, directly processing the file to be processed.

[0007] Optionally, the method for processing files is characterized in that the processing of the decompressed multiple target files includes: determining whether the file characteristics of the target files match the target characteristics, and if so, storing the file information corresponding to the target files in a target set; otherwise, storing the file values ​​corresponding to the target files in the processing set and releasing the target files from the memory.

[0008] Optionally, the method for processing files is characterized by processing the decompressed multiple target files, including: in the case where the compressed file is multi-layer compressed, taking each decompressed layer as the current layer, and executing: sequentially processing the first file in the current layer that has not been processed.

[0009] Optionally, the method for processing files is characterized in that the unprocessed first files in the current layer are processed sequentially, including: according to a preset processing order, for each unprocessed first file, executing steps M1 to M3: M1: Determine whether the unprocessed first file is a compressed file, if so, execute M2; M2: Decompress multiple second files contained in the unprocessed first file into memory; M3: Select any second file whose file type is a compressed file, and use the selected second file as the unprocessed first file, and execute M2.

[0010] Optionally, the method for processing a file is characterized by further comprising:

[0011] When all files included in the current layer are processed, determine whether the current layer includes a first file whose file type is a compressed file; if so, take each first file whose file type is a compressed file as a file to be processed and execute step N2.

[0012] To achieve the above object, according to a second aspect of an embodiment of the present invention, a device for processing files is provided, which is characterized by comprising: a file acquisition module, a file judgment module and a file matching module; wherein:

[0013] The file acquisition module is used to execute N1: acquire a compressed file to be processed, and use the compressed file as the file to be processed;

[0014] The file determination module is used for N2: calculating the file value of the to-be-processed file, and determining whether the file value of the to-be-processed file exists in the processing set; if so, releasing the to-be-processed file from the memory; otherwise, executing N3;

[0015] The matching file module is used to execute N3: decompress multiple target files included in the to-be-processed file into a memory, and process the decompressed multiple target files.

[0016] To achieve the above-mentioned purpose, according to the third aspect of an embodiment of the present invention, there is provided an electronic device for processing files, characterized in that it comprises: one or more processors; a storage device for storing one or more programs, when the one or more programs are executed by the one or more processors, the one or more processors implement any of the methods described in the above-mentioned methods for processing files.

[0017] To achieve the above-mentioned purpose, according to a fourth aspect of an embodiment of the present invention, a computer-readable medium is provided, on which a computer program is stored, characterized in that when the program is executed by a processor, any method as described in the above-mentioned method for processing a file is implemented.

[0018] An embodiment of the above invention has the following advantages or beneficial effects: it is able to calculate the file value of a compressed file to be processed, and determine whether the file needs to be processed by judging whether the file value exists in an existing processing set. If processing is required, each target file contained in the compressed file is decompressed into the memory and each file is processed; based on the processing result, the obtained target file information matching the target feature is stored in the target set; and the files to be processed that do not need to be processed or have been processed are released from the memory, thereby improving the efficiency of processing compressed files.

[0019] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with specific implementation examples. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.

[0021] Figure 1 It is a flowchart of a method for processing files provided by an embodiment of the present invention;

[0022] Figure 2 It is a schematic diagram of a process of processing a file provided by an embodiment of the present invention;

[0023] Figure 3 It is a schematic diagram of a multi-layer compression structure of a compressed file provided by an embodiment of the present invention;

[0024] Figure 4 is a schematic diagram of the structure of a device for processing files provided by an embodiment of the present invention;

[0025] Figure 5 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;

[0026] Figure 6 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION

[0027] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.

[0028] like Figure 1 As shown, an embodiment of the present invention provides a method for processing a file, which may include the following steps:

[0029] Step S101: N1: Obtain a compressed file to be processed, and use the compressed file as the file to be processed.

[0030] Specifically, in order to improve data transmission efficiency and reduce network resource consumption, Internet applications usually compress multiple files before transmitting files (data). In the case where the compressed files need to be processed, the processing of the files, for example, determines whether the compressed files and the files contained therein match target features such as set keywords and set sensitive data, and saves the file information that meets the target features.

[0031] Further, a compressed file to be processed is obtained, wherein the compressed file may be obtained through network transmission or stored in a local storage medium to be processed. The compressed file may be generated by a compression tool (for example, WinRAR, winzip, 7-Zip, etc.), and the present invention does not limit the specific format and content of the compressed file.

[0032] Step S102: N2: Calculate the file value of the to-be-processed file, and determine whether the file value of the to-be-processed file exists in the processing set; if so, release the to-be-processed file from the memory; otherwise, execute N3.

[0033] Specifically, the file value of the to-be-processed file may be a hash value of the to-be-processed file, and the method for calculating the file value of the to-be-processed file may be an MD5 algorithm for calculating the hash value of the to-be-processed file; further, the processing set includes hash values ​​of multiple processed files, and by judging whether the hash value of the to-be-processed file exists in the processing set, it is judged whether the to-be-processed file has been processed (processing includes searching for the file name or content, etc.), if it has been processed (that is, the file hash value exists in the processing set), it does not need to be processed, and the to-be-processed file is released from the memory, otherwise further processing steps for the to-be-processed file are performed. By releasing the to-be-processed file that does not need to be processed from the memory, the file is processed using the memory instead of the storage medium (such as a hard disk), and the efficiency of processing the file is improved by reducing the read and write operations on the storage medium.

[0034] By using the processing set to save the processed file value and determining whether the file value of the file to be processed exists in the processing set before processing the file, the situation where the same file is processed multiple times is avoided, and the efficiency of processing the file is improved. It can be understood that if it is determined that the file has not been processed, the file value is saved in the processing set after executing the step of processing the file.

[0035] Furthermore, the file to be processed is a compressed file, or a file of a non-compressed file type contained in a compressed file. The specific description of processing the file to be processed is consistent with the description of step S103 and is not repeated here.

[0036] Step S103: N3: decompress the multiple target files contained in the to-be-processed file into the memory, and process the decompressed multiple target files.

[0037] Specifically, the to-be-processed file (compressed file) is decompressed, that is, multiple target files contained in the to-be-processed file are decompressed into the memory; by decompressing the to-be-processed file into the memory, the file is processed in the memory instead of the storage medium (such as a hard disk), and the efficiency of processing the file is improved by reducing the read and write operations on the storage medium. For example, the compressed file 0.zip (the to-be-processed file) contains 10 target files, and the target files correspond to multiple file types (text, image, source code, compression, etc.). The present invention does not limit the specific content of the file type.

[0038] Furthermore, the processing of the decompressed multiple target files includes: taking each target file as a file to be processed, executing step N2 (i.e., N2: calculating the file value of the file to be processed, and determining whether the file value of the file to be processed exists in the processing set; if so, releasing the file to be processed from the memory; otherwise executing N3); if the decompressed target file (i.e., the file to be processed) is a non-compressed file, and the file value does not exist in the processing set, which means that the text needs to be processed, then the file is directly processed, that is, in view of the fact that the file to be processed is a non-compressed file, and step N2 determines that the file value of the file to be processed is not in the processing set, the file to be processed is directly processed. If the target file (i.e., the file to be processed) is a compressed file, the file needs to be decompressed.

[0039] Further, regarding the processing operation of the target file, it specifically includes: processing the multiple target files decompressed, including: judging whether the file feature of the target file matches the target feature, if so, storing the file information corresponding to the target file in the target set; otherwise, storing the file value corresponding to the target file in the processing set, and releasing the target file from the memory. Among them, the target feature is a matching strategy containing one or more features set according to the application scenario, for example: using the keywords contained in the file name, one or more keywords contained in the file content, the file hash value, the file content similarity, etc. as the target feature; further, judging whether the file feature of the target file matches the target feature, that is, judging whether the file feature of the target file matches the matching strategy corresponding to the target feature. Through the target feature, the files are searched to select the files that meet the target feature (i.e., matching strategy), and the file information of the files is stored in the target set. The target set includes the file information (such as file identification, etc.) of each file that meets the target feature and matches the set matching strategy; if the current file to be processed does not match the target feature, the file value corresponding to the target file is stored in the processing set (indicated as processed), and the target file is released from the memory.

[0040] Furthermore, the decompressed multiple target files are processed, including: in the case where the compressed file is multi-layer compressed, each decompressed layer is used as the current layer, and the following steps are performed: sequentially processing the first file in the current layer that has not been processed.

[0041] Specifically, when the target file is a multi-layer compressed file (multi-layer compression includes two-layer compression, that is, a compressed file contains multiple non-compressed files), for example: the target file (multi-layer compression) is 0.zip; after decompression, 1.zip and 8.zip are obtained; after decompression, 1.zip obtains 3.zip; each decompressed layer is used as the current layer, and the first file in the current layer that has not been processed is processed sequentially.

[0042] There are two methods for sequentially processing the first file in the current layer that has not been processed: Figure 3 The schematic diagram of the structure of the compressed file of multi-layer compression shown in FIG. 1 is used as an example to illustrate two methods; illustratively, Figure 3 The file names of various files are shown (excluding the file extension information). In the following description, the extension information is added based on the example file name to distinguish whether the file type is a compressed file. It is assumed that the compressed file is in zip format; specifically, Figure 3 As shown in the structure, it is assumed that the compressed file 0.zip contains compressed files 8.zip, 1.zip, and uncompressed file 7.txt; 8.zip, 1.zip, and 7.txt are the first layer of the decompression, as shown in Figure 3 As shown; further, similarly, 1.zip contains compressed files 3.zip, non-compressed files 6.pdf, 2.htm (the second layer); 3.zip contains non-compressed files 5.txt, 4.pdf (the third layer); 8.zip contains non-compressed files 9.txt, 10.pdf (the second layer).

[0043] The first method: according to the preset processing order, for each first file that has not been processed, execute steps M1 to M3:

[0044] M1: Determine whether the unprocessed first file is a compressed file, and if so, execute M2; M2: Decompress multiple second files contained in the unprocessed first file into the memory; M3: Select any second file whose file type is a compressed file, and use the selected second file as the unprocessed first file, and execute M2.

[0045] According to the steps of the method M1, Figure 3As shown, it is determined whether the unprocessed first file (for example: 1.zip) is a compressed file. If so, M2 is executed; that is, multiple second files (3.zip, 6.pdf, 2.htm) contained in the first file (1.zip) are decompressed into the memory; M3, when the multiple second files include a compressed file (for example, 3.zip), any compressed file is selected, and the second file is used as the first file to execute the step of decompressing the compressed file described in M2 (for example: decompressing 3.zip to obtain 5.txt, 4.pdf); In summary, in this method, Figure 3 The processing order of the files contained in 0.zip in the example is expressed in the file name as: 0->1->2->3->4->5->6->7->8->9->10; that is, when sequentially processing the first files that have not been processed in the current layer, according to the preset processing order (for example: for each unprocessed first file, process it in turn and determine whether it is a compressed file), the method of preferentially decompressing the compressed files is adopted.

[0046] The second method: when all files included in the current layer have been processed, determine whether the current layer includes a first file whose file type is a compressed file; if so, treat each first file whose file type is a compressed file as a file to be processed and execute step N2.

[0047] Specifically, Figure 3 As an example, Figure 3 As shown in the structure, the file 0.zip to be processed is decompressed, and the files obtained in the first layer are compressed files 8.zip, 1.zip, and non-compressed file 7.txt. These three files are processed in turn, and then it is determined whether the current layer includes the first file whose file type is a compressed file. Figure 3 From the example, it can be seen that 1.zip and 8.zip are determined to be compressed files (i.e., the first file); then the first file of each compressed file type is used as the file to be processed, and the step N2 is executed. That is, N2: calculate the file value of the file to be processed, and determine whether the file value of the file to be processed exists in the processing set; if it exists, release the file to be processed from the memory; otherwise, execute N3; N3: decompress the multiple target files contained in the file to be processed into the memory, and process the decompressed multiple target files. In this method, Figure 3 The order of processing each file in the example is represented by the file name: 0->1->7->8->2->3->6->9->10->4->5; that is, when the first file that has not been processed in the current layer is processed sequentially, the files are processed in sequence, and when the first file is a compressed file, the first file is decompressed.

[0048] like Figure 2 As shown, an embodiment of the present invention provides a method for processing a file, which may include the following steps:

[0049] Step S201: obtaining a compressed file to be processed, and taking the compressed file as a file to be processed; and calculating a file value of the file to be processed.

[0050] Step S202: Determine whether the file value of the file to be processed exists in the processing set.

[0051] If yes, execute step S203; otherwise, execute step S204.

[0052] Step S203: releasing the to-be-processed file from the memory.

[0053] Step S204: decompress the multiple target files included in the to-be-processed file into the memory, and process the decompressed multiple target files.

[0054] Specifically, the description of step S201-step S204 is: N1: obtain the compressed file to be processed, and use the compressed file as the file to be processed; N2: calculate the file value of the file to be processed, and determine whether the file value of the file to be processed exists in the processing set; if so, release the file to be processed from the memory; otherwise execute N3; N3: decompress the multiple target files contained in the file to be processed into the memory, and process the decompressed multiple target files.

[0055] Step S205: Determine whether the file feature of the target file matches the target feature.

[0056] Specifically, if yes, execute step S207; otherwise, execute step S206.

[0057] Step S206: storing the file value corresponding to the target file in the processing set, and releasing the target file from the memory.

[0058] Step S207: storing the file information corresponding to the target file in the target set.

[0059] Specifically, the description of step S205-step S207 is: the processing of the decompressed multiple target files includes: determining whether the file characteristics of the target files match the target characteristics, and if so, storing the file information corresponding to the target files in the target set; otherwise, storing the file values ​​corresponding to the target files in the processing set and releasing the target files from the memory.

[0060] Step S208: Determine whether the target file is a compressed file; if so, execute step S201; otherwise, execute step S205.

[0061] Specifically, it is determined whether the file to be processed (target file) is a compressed file, that is, the decompressed multiple target files are processed, including: taking each target file as a file to be processed, and executing step N2; if the file to be processed is a non-compressed file, and step N2 determines that the file value of the file to be processed is not in the processing set, directly processing the file to be processed. The specific description of processing the target file is consistent with the description of step S103, and will not be repeated here.

[0062] The order of step S205 and step S208 is only an example, and step S205 may precede step S208, and step S208 may also precede step S205.

[0063] like Figure 4 As shown, an embodiment of the present invention provides a device 400 for processing files, including: a file acquisition module 401, a file determination module 402 and a file matching module 403; wherein,

[0064] The file acquisition module 401 is used to execute N1: acquire a compressed file to be processed, and use the compressed file as the file to be processed;

[0065] The file determination module 402 is used for N2: calculating the file value of the to-be-processed file, and determining whether the file value of the to-be-processed file exists in the processing set; if so, releasing the to-be-processed file from the memory; otherwise, executing N3;

[0066] The matching file module 403 is used to execute N3: decompress multiple target files included in the to-be-processed file into the memory, and process the decompressed multiple target files.

[0067] An embodiment of the present invention also provides an electronic device for processing files, comprising: one or more processors; a storage device for storing one or more programs, when the one or more programs are executed by the one or more processors, the one or more processors implement the method provided in any of the above embodiments.

[0068] An embodiment of the present invention further provides a computer-readable medium on which a computer program is stored. When the program is executed by a processor, the method provided in any of the above embodiments is implemented.

[0069] Figure 5 An exemplary system architecture 500 is shown to which the method for processing a file or the apparatus for processing a file according to the embodiment of the present invention can be applied.

[0070] like Figure 5 As shown, system architecture 500 may include terminal devices 501, 502, 503, a network 504 and a server 505. Network 504 is used to provide a medium for communication links between terminal devices 501, 502, 503 and server 505. Network 504 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.

[0071] Users can use terminal devices 501, 502, 503 to interact with server 505 through network 504 to receive or send messages, etc. Various client applications can be installed on terminal devices 501, 502, 503, such as e-commerce client applications, web browser applications, search applications, instant messaging tools, and email clients.

[0072] The terminal devices 501 , 502 , and 503 may be various electronic devices having a display screen and supporting various client applications, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, and the like.

[0073] Server 505 may be a server that provides various services, such as a background management server that provides support for client applications used by users using terminal devices 501, 502, and 503. The background management server may process the received request for processing files and feed back target set information obtained by processing files to the terminal device.

[0074] It should be noted that the method for processing files provided in the embodiment of the present invention is generally executed by the server 505 , and accordingly, the device for processing files is generally disposed in the server 505 .

[0075] It should be understood that Figure 5 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.

[0076] Reference below Figure 6 , which shows a schematic diagram of the structure of a computer system 600 of a terminal device suitable for implementing an embodiment of the present invention. Figure 6 The terminal device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0077] like Figure 6As shown, the computer system 600 includes a central processing unit (CPU) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage part 608 into a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the system 600 are also stored. The CPU 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.

[0078] The following components are connected to the I / O interface 605: an input section 606 including a keyboard, a mouse, etc.; an output section 607 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 608 including a hard disk, etc.; and a communication section 609 including a network interface card such as a LAN card, a modem, etc. The communication section 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to the I / O interface 605 as needed. A removable medium 611, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 610 as needed, so that a computer program read therefrom is installed into the storage section 608 as needed.

[0079] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 609, and / or installed from the removable medium 611. When the computer program is executed by the central processing unit (CPU) 601, the above-mentioned functions defined in the system of the present invention are executed.

[0080] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.

[0081] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession 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 or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0082] The modules and / or units involved in the embodiments of the present invention may be implemented in software or hardware. The modules and / or units described may also be arranged in a processor. For example, they may be described as follows: a processor includes a file acquisition module, a file judgment module, and a file matching module. The names of these modules do not, in some cases, constitute limitations on the modules themselves. For example, the file acquisition module may also be described as a "module for acquiring a compressed file to be processed and using the compressed file as a file to be processed."

[0083] As another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiment; or may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device includes: N1: obtaining a compressed file to be processed, and using the compressed file as a file to be processed; N2: calculating the file value of the file to be processed, and determining whether the file value of the file to be processed exists in the processing set; if so, releasing the file to be processed from the memory; otherwise executing N3; N3: decompressing multiple target files contained in the file to be processed into the memory, and processing the decompressed multiple target files.

[0084] The embodiments of the present invention can calculate the file value of a compressed file to be processed, and determine whether the file needs to be processed by judging whether the file value exists in an existing processing set. If processing is required, each target file contained in the compressed file is decompressed into a memory and each file is processed; based on the processing result, the obtained target file information matching the target feature is stored in a target set; and the files to be processed that do not need to be processed or have been processed are released from the memory, thereby improving the efficiency of processing compressed files.

[0085] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A method for processing a file, characterized in that: include: N1: Obtain a compressed file to be processed, and use the compressed file as the file to be processed; N2: Calculate the file value of the to-be-processed file, and determine whether the file value of the to-be-processed file exists in the processing set; If it exists, release the to-be-processed file from the memory; Otherwise, execute N3; wherein the file value of the to-be-processed file is a hash value of the to-be-processed file, and the processing set includes hash values ​​of multiple processed files; N3: decompressing multiple target files contained in the to-be-processed file into a memory, and processing the decompressed multiple target files; Among them, the processing of the decompressed multiple target files includes: determining whether the file characteristics of the target file match the target characteristics, and if so, storing the file value corresponding to the target file in the target set; otherwise, storing the file value corresponding to the target file in the processing set and releasing the target file from the memory; the target characteristics are one or more of the keywords of the file name, the keywords of the file content, the file hash value, and the file content similarity.

2. The method according to claim 1, characterized in that The processing of the decompressed multiple target files includes: Take each of the target files as a file to be processed and execute step N2; In case that the file to be processed is a non-compressed file and step N2 determines that the file value of the file to be processed is not in the processing set, the file to be processed is directly processed.

3. The method according to claim 2, characterized in that Processing the decompressed target files includes: In case the compressed file is multi-layer compressed, Take each decompressed layer as the current layer and execute: The first files in the current layer that have not been processed are processed sequentially.

4. The method according to claim 3, characterized in that Sequentially processing the first file in the current layer that has not been processed, comprising: According to the preset processing order, for each first file that has not been processed, steps M1 to M3 are executed: M1: Determine whether the first file that has not been processed is a compressed file, and if so, execute M2; M2: decompressing the plurality of second files included in the unprocessed first file into a memory; M3: Select any second file whose file type is a compressed file, and use the selected second file as the unprocessed first file, and execute M2.

5. The method according to claim 3, characterized in that: Further including: When all files included in the current layer are processed, determining whether the current layer includes a first file whose file type is a compressed file; If yes, each first file whose file type is a compressed file is taken as a file to be processed, and step N2 is executed.

6. A device for processing files, characterized in that: include: Obtain file module, judge file module and match file module; wherein, The file acquisition module is used to execute N1: acquire a compressed file to be processed, and use the compressed file as the file to be processed; The file determination module is used for N2: calculating the file value of the to-be-processed file, and determining whether the file value of the to-be-processed file exists in the processing set; if so, releasing the to-be-processed file from the memory; otherwise, executing N3; the file value of the to-be-processed file is the hash value of the to-be-processed file, and the processing set contains the hash values ​​of multiple processed files; The matching file module is used to execute N3: decompress multiple target files contained in the file to be processed into the memory, and process the decompressed multiple target files; wherein, the processing of the decompressed multiple target files includes: determining whether the file feature of the target file matches the target feature, and if so, storing the file value corresponding to the target file in the target set; otherwise, storing the file value corresponding to the target file in the processing set and releasing the target file from the memory; the target feature is one or more of the keywords of the file name, the keywords of the file content, the file hash value, and the file content similarity.

7. An electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 5.

8. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.

Citation Information

Patent Citations

  • Storage space saving method and device

    CN107193496A

  • File processing method and device

    CN108197204A

  • Multi-layer decompression method of compressed file, electronic equipment and storage medium

    CN112214462A

  • Method for downloading file and the download file

    JP1999312105A