File processing method and electronic device

By implementing file deduplication methods in electronic devices and identifying and processing duplicate files, the problem of waste of storage space is solved, and the storage space saving and user experience are improved.

CN118410020BActive Publication Date: 2025-05-06HONOR DEVICE CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202410312832.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-03-18
Publication Date
2025-05-06
Estimated Expiration
2044-03-18

AI Technical Summary

Technical Problem

Electronic devices may generate duplicate files when processing files, resulting in wasted storage space and reducing user experience.

Method used

By implementing the file deduplication method in an electronic device, scanning and identifying duplicate files, selecting a target file to retain the file contents under its inode, and deleting the file contents of other duplicate files, establishing a mapping relationship between the new inode and the target inode.

Benefits of technology

It realizes that only one copy of data is saved at the bottom of the file system, saving a lot of storage space. At the same time, users can still see multiple data files of different purposes through directory items, which does not affect users' use of files.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118410020B_ABST
    Figure CN118410020B_ABST
Patent Text Reader

Abstract

The present application provides a file processing method and an electronic device, and relates to the field of data processing technology. The method includes: in response to a deduplication instruction, scanning out duplicate files in an electronic device; determining a target file from N duplicate files included in a group of duplicate files; the file includes file path information and file content, and the file path information is used to instruct the electronic device to find the corresponding file content from the storage space, and the file path information includes an index node. Then, a first index node is established for the target file; a mapping relationship is established between the target index node and the first index node and the second index node, respectively; the target index node is the original index node corresponding to the target file; the second index node is the index node corresponding to N‑1 files in a group of duplicate files except the target file. Finally, the file content of the N‑1 files is deleted from the storage space. This method reduces the storage space occupied by duplicate files.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing technology, and in particular to a file processing method and electronic equipment. Background Art

[0002] When processing files, electronic devices may generate duplicate files. Duplicate files refer to files with the same content, but other attribute information of the files (such as file paths) may be different. For example, two pictures with the same content saved in the photo album of an electronic device are duplicate pictures. For another example, if the content of file 1 received and saved by application 1 of an electronic device is the same as that of file 2 received and saved by application 2 of an electronic device, then file 1 and file 2 are also duplicate files.

[0003] Duplicate files will take up storage space on electronic devices, resulting in less available storage space, wasting storage space and reducing the user experience. Summary of the invention

[0004] The embodiments of the present application provide a file processing method and an electronic device, which can reduce the storage space occupied by duplicate files, save the storage space occupancy rate, and improve the user experience.

[0005] To achieve the above objectives, the embodiments of the present application adopt the following technical solutions:

[0006] In a first aspect, a file processing method is provided, which is applied to an electronic device, and the method includes: the electronic device responds to a deduplication instruction, first scanning out duplicate files in the electronic device. The electronic device may contain multiple groups of duplicate files. A group of duplicate files includes N files with the same file content.

[0007] The electronic device determines a target file from the N duplicate files included in the scanned set of duplicate files. The file includes file path information and file content. The file path information is used to instruct the electronic device to find the corresponding file content from the storage space. The file path information includes an index node. A file corresponds to a unique index node. The file path information also includes a directory entry, and an index node can correspond to multiple directory entries.

[0008] Then, the electronic device establishes a first index node for the determined target file. This first index node has no associated file content. The electronic device sets the index nodes corresponding to N-1 files in a set of duplicate files other than the target file as the second index node. Then, the electronic device establishes a mapping relationship between the target index node and the first index node and the second index node, respectively. Among them, the target index node is the original index node corresponding to the target file. The target index node is associated with the file content of the target file.

[0009] Finally, the electronic device only saves the file content associated with the target index node and deletes the file content of N-1 files from the storage space.

[0010] By adopting the above technical solution, the mobile phone only saves the file content contained in the target index node, so that a group of duplicate files only saves one copy of the data in the bottom layer of the file system, thereby saving a lot of storage space. In addition, when the mobile phone establishes a mapping relationship with the first index node and the second index node for the target index node, the first index node and the second index node are still associated with the directory items corresponding to each file, so the user side can also see multiple data files with different purposes through the external directory items, which does not affect the user's use of the file.

[0011] In a possible implementation of the first aspect, the electronic device determines a target file from N duplicate files included in a group of duplicate files for a group of duplicate files, including: the electronic device can determine a target file based on the security level from N duplicate files included in a group of duplicate files for a group of duplicate files. The security level of the target file is higher than the security level of N-1 files. Since the electronic device considers the security of the only actual data retained after file deduplication from the data source, the electronic device ultimately stores the file content under the target file with the highest security level, thereby improving the security of the stored data.

[0012] Among them, the file content contained in the target index node is the data that has been stored in the storage space of the mobile phone before the file deduplication process, which is more secure and stable. The mobile phone only needs to determine the associated target index node according to the index node corresponding to each file, and then it can find the file content under the target index node. The process of searching for file content on the mobile phone is safer.

[0013] In a possible implementation of the first aspect, the security level of the target file is higher than the security levels of N-1 files, including at least one of the following: the security level of the file path of the target file is higher than the security level of the file path of N-1 files; the security level of the file environment of the target file is higher than the security level of the file environment of N-1 files; the number of accesses to the target file is less than the number of accesses to the N-1 files; and the target file is the first file saved in the electronic device among the N repeated files. The number of accesses is the number of accesses to each file within a preset time period.

[0014] Among them, the file path, file environment, number of file accesses, and whether it is the first time the file is saved on the mobile phone are used as security aspects to compare the security level of the file. The priority of the above security aspects is from high to low: file path, file environment, number of file accesses, and whether it is the first time the file is saved on the mobile phone. In other words, when the conditions of the higher level are the same, the comparison of the lower level will be carried out one by one until the target node is determined.

[0015] In a possible implementation of the first aspect, a group of duplicate files includes a first file and a second file. The electronic device determines a target file from N duplicate files included in the group of duplicate files, including: if the security level of the file path of the first file is higher than the security level of the file path of the second file, the electronic device uses the first file as the target file. That is, the electronic device uses a file with the highest security level of the file path among the N duplicate files as the target file.

[0016] In a possible implementation of the first aspect, for a group of duplicate files, the electronic device determines a target file from N duplicate files included in the group of duplicate files, including: when the security level of the file path of the first file is the same as the security level of the file path of the second file, if the security level of the file environment of the first file is higher than the security level of the file environment of the second file, the electronic device uses the first file as the target file. That is, when the security levels of the file paths of the N duplicate files are the same, the electronic device uses the file with the highest security level of the file environment among the N duplicate files as the target file.

[0017] In a possible implementation of the first aspect, the electronic device determines a target file from N duplicate files included in a group of duplicate files, including: when the security level of the file environment of the first file is the same as the security level of the file environment of the second file, if the number of accesses to the first file is less than the number of accesses to the second file, the electronic device uses the first file as the target file. That is, when the security levels of the file paths of the N duplicate files are the same and the security levels of the file environments of the N duplicate files are the same, the electronic device uses the file with the least number of accesses among the N duplicate files as the target file.

[0018] In a possible implementation of the first aspect, for a group of duplicate files, the electronic device determines a target file from N duplicate files included in the group of duplicate files, including: when the number of accesses to the first file is the same as the number of accesses to the second file, if the first file is the first file saved in the electronic device among the N duplicate files, the electronic device uses the first file as the target file. That is, when the security levels of the file paths of the N duplicate files are all the same, the security levels of the file environments of the N duplicate files, and the number of accesses are all the same, the electronic device uses a file that is first saved (first appears) in the electronic device among the N duplicate files as the target file.

[0019] Therefore, the mobile phone can determine the file with the highest security level in a group of duplicate files as the target file by performing the above-mentioned layer-by-layer security comparison on N files, thereby providing security for the only actual data stored in the electronic device.

[0020] In a possible implementation of the first aspect, the file path information includes a directory item. The electronic device establishes a first index node for the target file, comprising: the electronic device disconnects the directory item of the target file from the target index node of the target file; when establishing the first index node, the electronic device associates the directory item of the target file with the first index node.

[0021] Therefore, the target index node is not associated with any file directory entry, and the target index node is not visible to the outside. After the electronic device associates the directory entry of the target file with the first index node, the electronic device determines the corresponding index node through the directory entry of the target file as the first index node, not the target index node. After the first index node is associated with the target item, it is visible to the outside.

[0022] In this way, even if the electronic device wants to delete the target file, what is deleted is the directory entry and the first index node of the target file, and the target index node will not be affected.

[0023] In a possible implementation of the first aspect, after the electronic device deletes the file contents of N-1 files from the storage space, the method further includes: in response to a deletion operation on the first file, the electronic device may determine a corresponding third index node according to the file path information of the first file. The deletion operation is used to trigger the electronic device to delete the file contents corresponding to the first file. The first file may be any one of the N duplicate files, and the third index node is an index node between the first index node and the second index node.

[0024] Then, the electronic device deletes the mapping relationship between the third index node and the target index node, and the file path information of the first file.

[0025] In this solution, the above-mentioned deletion operation on the first file only disconnects the connection between the index node of the first file and the target index node, and does not affect the mapping relationship established between the target index node and other index nodes.

[0026] In a possible implementation of the first aspect, after the electronic device deletes the file contents of the N-1 files from the storage space, the method further includes: in response to a modification operation on the second file, the electronic device may determine a corresponding fourth index node according to the file path information of the second file. The modification operation is used to trigger the electronic device to modify the second file, the second file is any one of the N repeated files, and the fourth index node is one of the first index node and the second index node.

[0027] Then, the electronic device deletes the mapping relationship between the fourth index node and the target index node. The electronic device copies the file content corresponding to the target index node, and uses the copied file content and the fourth index node as a new second file. Among them, the electronic device will apply for a certain storage space for storing the file content of the new second file. Finally, the electronic device modifies the new second file to obtain a modified new second file.

[0028] In this solution, the above modification operation on the second file only disconnects the connection between the index node of the second file and the target index node, and does not affect the mapping relationship established between the target index node and other index nodes.

[0029] It is understandable that the file content of the modified second file changes and is no longer a duplicate file. The modified second file is stored again in the storage space of the electronic device as a new file.

[0030] In a possible implementation of the first aspect, the method further includes: the electronic device determines the number of index nodes that establish a mapping relationship with the target index node. If the number is 0, the electronic device deletes the target index node and the file content corresponding to the target index node from the storage space.

[0031] After the electronic device modifies the deduplicated file, the index node of the file will be disconnected from the associated target index node, that is, the mapping relationship will be deleted. Then, after the electronic device modifies each file in a group of deduplicated files, the number of index nodes that establish a mapping relationship with the target index node corresponding to the group of deduplicated files is reduced by 1.

[0032] Similarly, after the electronic device deletes a deduplicated file, the index node of the file will be disconnected from the associated target index node, that is, the mapping relationship will be deleted. Then, after the electronic device deletes each file in a group of deduplicated files, the number of index nodes that establish a mapping relationship with the target index node corresponding to the group of deduplicated files is reduced by 1.

[0033] In this solution, the electronic device will delete the file content corresponding to the target index node only when the number of index nodes that establish a mapping relationship with the target index node is reduced to 0, which means that there is no file with the same file content as the target index node in the electronic device.

[0034] In a possible implementation of the first aspect, after the electronic device deletes the file contents of N-1 files from the storage space, the method further includes: in response to a read operation on a third file, the electronic device determines the corresponding fifth index node according to the file path information of the third file. The read operation is used to trigger the electronic device to read the file contents corresponding to the third file, the third file is any one of the N repeated files, and the fifth index node is one of the first index node and the second index node.

[0035] The electronic device can find the corresponding target index node based on the fifth index node according to the mapping relationship of the index nodes. Then, the electronic device can read the file content corresponding to the target index node from the storage space according to the target index node.

[0036] Thus, the electronic device can find the target index node corresponding to the index node by determining the index node corresponding to the file, and then find the file content corresponding to the target index node, thereby realizing reading of the file.

[0037] In a possible implementation of the first aspect, after the electronic device deletes the file contents of N-1 files from the storage space, it also includes: the electronic device can display the file processing results of the N duplicate files, and the file processing results are used to indicate that the N duplicate files are successfully deduplicated.

[0038] In this solution, for multiple sets of duplicate files in an electronic device, one file will be selected from each set of duplicate files as the file that actually stores data, and its index node will be invisible to the outside. In addition, a new index node is created for the selected file, so the data access of the index node in each set of duplicate files needs to use the index node that stores the real data. The deduplication process is fast and the deduplication effect is good, and the deduplication solution is relatively robust.

[0039] In a second aspect, the present application provides an electronic device, comprising: a communication module, a memory and one or more processors; the communication module, the memory and the processor are coupled; wherein the memory stores computer program code, the computer program code comprises computer instructions, and when the computer instructions are executed by the processor, the electronic device executes any one of the file processing methods in the above-mentioned first aspect.

[0040] In a third aspect, the present application provides a computer-readable storage medium, which stores instructions. When the computer-readable storage medium is run on a computer, the computer can execute any file processing method in the first aspect.

[0041] In a fourth aspect, the present application provides a computer program product comprising instructions, which, when executed on a computer, enables the computer to execute any one of the file processing methods in the first aspect.

[0042] It can be understood that the electronic device described in the second aspect provided above, the computer-readable storage medium described in the third aspect and the computer program product described in the fourth aspect are all used to execute the corresponding methods provided above. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding methods provided above, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] Figure 1 A schematic diagram of the structure of a memory provided in an embodiment of the present application;

[0044] Figure 2 A schematic diagram of deduplication of two duplicate files provided in an embodiment of the present application;

[0045] Figure 3 A schematic diagram of the hardware structure of a mobile phone 100 provided in an embodiment of the present application;

[0046] Figure 4 A schematic diagram of a user interface change of a mobile phone displaying files to be cleaned in response to a user's operation provided in an embodiment of the present application;

[0047] Figure 5 A schematic diagram of another mobile phone provided in an embodiment of the present application showing a user interface change of files to be cleaned in response to a user's operation;

[0048] Figure 6 A schematic diagram of a process for determining a target file based on a security level by a mobile phone provided in an embodiment of the present application;

[0049] Figure 7 A schematic diagram of the overall process of a file processing method provided in an embodiment of the present application;

[0050] Figure 8 A schematic diagram of the structure of an index node provided in an embodiment of the present application;

[0051] Fig. 9 A schematic diagram of another method of deduplicating two duplicate files provided in an embodiment of the present application;

[0052] Fig.10 A schematic diagram of a deduplication method provided in an embodiment of the present application;

[0053] Fig.11 A schematic diagram of a process for reading a deduplicated file provided in an embodiment of the present application;

[0054] Fig.12 A schematic diagram of deleting files after deduplication provided in an embodiment of the present application;

[0055] Fig.13 A schematic diagram of a modified file after deduplication provided in an embodiment of the present application;

[0056] Fig.14 A software architecture diagram of an electronic device provided in an embodiment of the present application;

[0057] Fig.15 A schematic diagram of the structure of a chip system provided in an embodiment of the present application. DETAILED DESCRIPTION

[0058] The following will describe the technical solutions in the embodiments of the present application in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of this application.

[0059] It should be noted that the following terms "first", "second", etc. are only used for descriptive purposes and should not be understood as indicating or implying relative importance or implicitly indicating the number of indicated technical features. Thus, features defined as "first", "second", etc. may explicitly or implicitly include one or more of the features. In addition, the terms "include" and "have" and any variations thereof 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 limited to the listed steps or units, but may optionally include steps or units that are not listed, or may optionally include other steps or units that are inherent to these processes, methods, products or devices.

[0060] References to "one embodiment" or "some embodiments" etc. described in this specification mean that a particular feature, structure or characteristic described in conjunction with the embodiment is included in one or more embodiments of the present application. Thus, the phrases "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. appearing in different places in this specification do not necessarily all refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways.

[0061] In the embodiments of the present application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific way.

[0062] In order to better illustrate the technical solution of the present application, the following is a brief overview of the terms involved in the present application.

[0063] (1) File system is a software abstraction layer that hides the details of physical storage devices and provides users and applications with a logically continuous and easy-to-use data storage space. The file system is responsible for the storage, retrieval, protection and sharing of data and is an indispensable part of the operating system.

[0064] Among them, the file system stores data by creating files. The file system uses a directory structure to organize files, grouping related files together to form folders or directories. This hierarchical structure helps users better manage and find files. The file system provides a set of unified application programming interfaces (Application Programming Interface, API) so that users and applications can easily access and operate files. These APIs include operations such as opening files, reading data, writing data, and closing files.

[0065] The file system in the embodiment of the present application can be taken as an example of the f2fs file system.

[0066] (2) Files: A file is a collection of information stored on an electronic device using the hard disk of the electronic device as a carrier. A file can be a text document, picture, video, program, audio, etc. A file usually has a three-letter file extension to indicate the file type. For example, picture files are often saved in JPEG format, and their file extension is .jpg; exe represents executable files, mp3 represents audio files, and mp4 represents video files. Among them, files can be created, modified, deleted, and copied to meet the different needs of users.

[0067] (3) Storage includes internal memory and hard disk. Data input, reading and storage are all carried out back and forth between internal memory and hard disk. Memory can include random access memory (RAM), read-only memory (ROM), and cache memory (CACHE). Memory is the workplace of electronic devices. Its task is to provide operating space for electronic devices and temporarily store data generated when programs are running. However, since memory generally uses semiconductor storage units, data will be lost after power failure. In order to save data, a storage device that will not disappear after power failure is required - a hard disk. For example, Figure 1 A schematic diagram of the structure of a memory is shown. Figure 1 As shown, the storage includes a memory and a hard disk.

[0068] (4) Metadata, also known as intermediate data or relay data, is data about data. Metadata mainly describes the properties of data and is used to support functions such as indicating storage location, historical data, resource search, and file records. Metadata is a kind of electronic catalog. In order to achieve the purpose of cataloging, it can describe and collect the content or characteristics of data, thereby achieving the purpose of assisting data retrieval.

[0069] (5) The hard disk is divided into two areas. One is the index node (inode) area, which stores the file attribute information contained in the inode. The other is the data area, which stores the file data, that is, the actual content of the file. For example, Figure 1 As shown, the hard disk includes an inode area and a data area.

[0070] The file attribute information stored in the inode area includes directory entries and index nodes.

[0071] Among them, the directory entry is used to record the file name (i.e. file name), the index node pointer, and the relationship with other directory entries. Multiple associated directory entries constitute the directory structure of the file system. The index node is used to record the metadata of the file. The index node corresponds to the file one by one, is the unique mark of each file, and will be persistently stored on the disk.

[0072] The index node includes the inode number, file size, user ID number (identity document, id), read and write permissions, file type, modification time, access time, and pointer to the file entity, but does not include the file name. This is because each index node has an inode number. After an electronic device opens a file, it uses the inode number to identify different files, and no longer considers the file name.

[0073] The data area includes the index node area and the data block area.

[0074] The index node area is used to store index nodes. The data block area is used to store the actual content of the file.

[0075] Specifically, for example, Figure 1 As shown, the process of an electronic device finding a file is:

[0076] Step 1: First, the electronic device finds the inode number corresponding to the file name in the directory entry through the file name. Then, the electronic device finds the index node pointer corresponding to the inode number in the directory entry through the inode number.

[0077] Step 2: Then, the index node corresponding to the inode number is found through the index node pointer corresponding to the inode number in the directory entry. Then, the electronic device finds the index node pointer of the index node area in the index node corresponding to the inode number.

[0078] Step 3: Then, the electronic device finds the index node in the index node area through the index node pointer in the index node area. Then, the electronic device finds the data block pointer in the index node in the index node area.

[0079] Step 4: Then, the electronic device finds the file corresponding to the inode number in the data area through the data block pointer.

[0080] (6) File path information, which is information indicating the storage address of a file in a storage space of an electronic device. The file path information may be information such as a directory entry or an index node, and the electronic device may find the file content through the directory entry or the index node. The file path information and the file content may constitute a file.

[0081] As described in the background art above, when an electronic device processes files, duplicate files may be generated, which will occupy the storage space of the electronic device, resulting in less available storage space, causing storage space waste and reducing the user experience.

[0082] There are many scenarios for duplicate files. One scenario for duplicate files is that with the development of Internet technology, electronic devices can forward files using the network, and the flow of files on electronic devices has become more convenient and faster. If an electronic device forwards a file, the electronic device will store duplicate files due to the flow of files.

[0083] For example, a 1GB video file 1 is forwarded once in social software A and then forwarded once in the mailbox, resulting in a duplicate video file 1 on the electronic device, which occupies 2GB of storage space. The storage space is occupied by 1GB more, resulting in a waste of device storage space. For another example, if an electronic device stores a 4MB picture 1, if the 4MB picture 1 is forwarded once in social software A, then the electronic device will have a duplicate picture 1, which occupies 8MB of storage space. The storage space is occupied by 4MB more, resulting in a waste of device storage space.

[0084] Another scenario where duplicate files are generated may be when an electronic device copies files. For example, an electronic device stores a 4MB picture 1, and the electronic device copies the 4MB picture 1, so that the electronic device has duplicated picture 1, which occupies 8MB of storage space. The storage space is occupied by 4MB more, resulting in a waste of device storage space.

[0085] Moreover, as electronic devices are used for a long time, more duplicate files may be stored in the electronic devices. More duplicate files will occupy more storage space, leaving less available storage space, resulting in a waste of storage space and reducing the user experience.

[0086] In order to solve the technical problems in the background technology, an embodiment of the present application proposes a file processing method.

[0087] If the N files stored in the electronic device are duplicate files, the electronic device can select one file from the N files as the target file, save the file content under the index node of the target file, and delete the file content of N-1 files other than the target file from the storage space. In addition, a new index node is created for the target file, and a mapping relationship is established between the index node and the index nodes of the N-1 files and the original target index node of the target file.

[0088] In this way, even if there is no file content under the index node of the non-target file (other files except the target file), the electronic device can find the associated target index node through the index node corresponding to the non-target file when obtaining the file content corresponding to the non-target file. Then, the electronic device finds the file content under the index node of the target file, thereby finding the file content corresponding to the non-target file. Similarly, when searching for the target file, the electronic device can find the associated target index node through the new index node corresponding to the target file, and then find the file content associated with the target index node.

[0089] In this way, under the premise that the electronic device can normally obtain files, the number of duplicate files can be reduced, thereby reducing the storage space occupied by the duplicate files, saving the occupancy rate of storage space, and improving the user experience.

[0090] See also Figure 2 , Figure 2 A schematic diagram of deduplication of two duplicate files provided in an embodiment of the present application. Figure 2 As shown, File A and File B are two files with duplicate file contents. A five-pointed star represents a directory entry. A triangle represents an index node. A circle represents a file content storage address or an address of a file content storage address, and a storage address or an address of a file storage address represents a storage location of a file in a storage space. A square represents file content. Among them, file content can be a data block that occupies a storage space, and this application does not limit the number of data blocks. Figure 2 Just an example.

[0091] It should be noted that in the current f2fs file system, during the process of writing and modifying data, the relevant address is read from the index node associated with the current file, and the index nodes used by other files are not associated. It is not possible to identify whether the data of other files is the same as the data of the current file, and it does not support the read and modify operations associated with other index nodes. Figure 2Although file A and file B are two identical files at the application layer, they can be accessed by directory entry A (external interface) and directory entry B. File B may be the result of copying file A, but within the current file system, the addresses occupied by the two in disk space are completely independent, including the metadata storage areas of the two files, and the read and write operations of the two files are unrelated.

[0092] In the embodiment of the present application, file A can be selected as the target file, and then index node A of file A is the target index node. The electronic device retains the file content associated under index node A, and deletes the file content associated under index node B of file B. In addition, the electronic device creates a new index node C for directory item A of file A. The mobile phone associates directory item A with index node C, and the electronic device associates the target index node A with index node B and index node C, respectively. At this point, the file is successfully deduplicated, and only one file content is stored in the storage space of the electronic device, saving storage space.

[0093] Exemplarily, the electronic device in the embodiments of the present application may be a mobile phone, a tablet computer, a desktop, a laptop, a handheld computer, a notebook computer, an ultra-mobile personal computer (UMPC), a netbook, a cellular phone, a personal digital assistant (PDA), an augmented reality (AR) device, a virtual reality (VR) device, a vehicle-mounted device, and the like, which can execute the file processing method provided in the embodiments of the present application. The embodiments of the present application do not impose any special restrictions on the specific form of the electronic device.

[0094] The embodiment of the present application is described by taking a mobile phone as an example of the electronic device. Figure 3 FIG. 1 shows a schematic diagram of the hardware structure of a mobile phone 100. Figure 3As shown, the mobile phone 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.

[0095] It is to be understood that the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the mobile phone 100. In other embodiments of the present application, the mobile phone 100 may include more or fewer components than shown in the figure, or combine some components, or separate some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.

[0096] The processor 110 may include one or more processing units, for example, the processor 110 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Among them, different processing units may be independent devices or integrated into one or more processors. It is understandable that a file includes file content and file path information, and the file path information is used to instruct the processor 110 to find the corresponding file from the storage space of the processor 110.

[0097] If the N files stored in the memory are duplicate files, the processor 110 can determine a file from the N files as the target file, delete the file contents of the N-1 files except the file contents of the target file from the storage space, and create a new index node for the target file. Then, the processor 110 associates the original target index node of the target file with the index node and the index nodes of the N-1 files respectively.

[0098] In this way, even if there is no file under the non-target index node (the index node of other files except the target file), when the processor 110 obtains a deduplicated file, it can find the file content under the target index node through the mapping relationship between the index node of the file and the target index node, so as to find the file content corresponding to the file. In this way, under the premise that the processor 110 normally obtains the file, the number of duplicate file contents can be reduced, thereby reducing the storage space occupied by the duplicate files, saving the storage space occupancy rate, and improving the user experience.

[0099] The controller may be the nerve center and command center of the mobile phone 100. The controller may generate an operation control signal according to the instruction operation code and the timing signal to complete the control of fetching and executing instructions.

[0100] The processor 110 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may store instructions or data that the processor 110 has just used or cyclically used. If the processor 110 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.

[0101] In some embodiments, the processor 110 may include one or more interfaces. The interface may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.

[0102] It is understandable that the interface connection relationship between the modules illustrated in the embodiment of the present application is only a schematic illustration and does not constitute a structural limitation on the mobile phone 100. In other embodiments of the present application, the mobile phone 100 may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.

[0103] The charging management module 140 is used to receive charging input from a charger. The charger may be a wireless charger or a wired charger. In some wired charging embodiments, the charging management module 140 may receive charging input from a wired charger through the USB interface 130. In some wireless charging embodiments, the charging management module 140 may receive wireless charging input through a wireless charging coil of the mobile phone 100. While the charging management module 140 is charging the battery 142, it may also power the mobile phone 100 through the power management module 141.

[0104] The power management module 141 is used to connect the battery 142, the charging management module 140 and the processor 110. The power management module 141 receives input from the battery 142 and / or the charging management module 140 to power the processor 110, the internal memory 121, the external memory, the display screen 194, the camera 193, and the wireless communication module 160.

[0105] The wireless communication function of the mobile phone 100 can be implemented through the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor and the baseband processor.

[0106] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in mobile phone 100 can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve the utilization of antennas. For example, antenna 1 can be reused as a diversity antenna for a wireless local area network. In some other embodiments, the antenna can be used in combination with a tuning switch.

[0107] The mobile communication module 150 can provide solutions for wireless communications including 2G / 3G / 4G / 5G, etc., applied to the mobile phone 100. The mobile communication module 150 may include at least one filter, a switch, a power amplifier, a low noise amplifier (LNA), etc. The mobile communication module 150 can receive electromagnetic waves from the antenna 1, and filter, amplify, and process the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modulation and demodulation processor, and convert it into electromagnetic waves for radiation through the antenna 1. In some embodiments, at least some of the functional modules of the mobile communication module 150 can be set in the processor 110. In some embodiments, at least some of the functional modules of the mobile communication module 150 can be set in the same device as at least some of the modules of the processor 110.

[0108] The modem processor may include a modulator and a demodulator. Among them, the modulator is used to modulate the low-frequency baseband signal to be sent into a medium-high frequency signal. The demodulator is used to demodulate the received electromagnetic wave signal into a low-frequency baseband signal. The demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing. After the low-frequency baseband signal is processed by the baseband processor, it is passed to the application processor. The application processor outputs a sound signal through an audio device (not limited to a speaker 170A, a receiver 170B, etc.), or displays an image or video through a display screen 194. In some embodiments, the modem processor may be an independent device. In other embodiments, the modem processor may be independent of the processor 110 and be set in the same device as the mobile communication module 150 or other functional modules.

[0109] The wireless communication module 160 can provide wireless communication solutions including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR), etc., which are applied to the mobile phone 100. The wireless communication module 160 can be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2, modulates the frequency of the electromagnetic wave signal and performs filtering, and sends the processed signal to the processor 110. The wireless communication module 160 can also receive the signal to be sent from the processor 110, modulate the frequency of it, amplify it, and convert it into electromagnetic waves for radiation through the antenna 2.

[0110] In some embodiments, the antenna 1 of the mobile phone 100 is coupled to the mobile communication module 150, and the antenna 2 is coupled to the wireless communication module 160, so that the mobile phone 100 can communicate with the network and other devices through wireless communication technology. The wireless communication technology may include global system for mobile communications (GSM), general packet radio service (GPRS), code division multiple access (CDMA), wideband code division multiple access (WCDMA), time-division code division multiple access (TD-SCDMA), long term evolution (LTE), BT, GNSS, WLAN, NFC, FM, and / or IR technology. The GNSS may include a global positioning system (GPS), a global navigation satellite system (GLONASS), a Beidou navigation satellite system (BDS), a quasi-zenith satellite system (QZSS) and / or a satellite based augmentation system (SBAS).

[0111] The mobile phone 100 implements the display function through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, which connects the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs that execute program instructions to generate or change display information.

[0112] The display screen 194 is used to display images, videos, etc. The display screen 194 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode or an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), Miniled, MicroLed, Micro-oLed, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the mobile phone 100 may include 1 or N display screens 194, where N is a positive integer greater than 1.

[0113] The mobile phone 100 can realize the shooting function through ISP, camera 193, video codec, GPU, display screen 194 and application processor.

[0114] ISP is used to process the data fed back by camera 193. For example, when taking a photo, the shutter is opened, and the light is transmitted to the camera photosensitive element through the lens. The light signal is converted into an electrical signal, and the camera photosensitive element transmits the electrical signal to ISP for processing and converts it into an image visible to the naked eye. ISP can also perform algorithm optimization on the noise, brightness, and skin color of the image. ISP can also optimize the exposure, color temperature and other parameters of the shooting scene. In some embodiments, ISP can be set in camera 193.

[0115] The camera 193 is used to capture still images or videos. The object generates an optical image through the lens and projects it onto the photosensitive element. The photosensitive element can be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the optical signal into an electrical signal, and then passes the electrical signal to the ISP to be converted into a digital image signal. The ISP outputs the digital image signal to the DSP for processing. The DSP converts the digital image signal into an image signal in a standard RGB, YUV or other format. In some embodiments, the mobile phone 100 may include 1 or N cameras 193, where N is a positive integer greater than 1.

[0116] The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the mobile phone 100. The external memory card communicates with the processor 110 through the external memory interface 120 to implement a data storage function, such as storing music, video and other files in the external memory card.

[0117] The internal memory 121 can be used to store computer executable program codes, which include instructions. The processor 110 executes various functional applications and data processing of the mobile phone 100 by running the instructions stored in the internal memory 121. The internal memory 121 may include a program storage area and a data storage area. Among them, the program storage area can store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc. The data storage area can store data created during the use of the mobile phone 100 (such as audio data, a phone book, etc.), etc. In addition, the internal memory 121 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (UFS), etc.

[0118] The mobile phone 100 can implement audio functions such as music playing and recording through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the earphone interface 170D, and the application processor.

[0119] The audio module 170 is used to convert digital audio information into analog audio signal output, and is also used to convert analog audio input into digital audio signals. The audio module 170 can also be used to encode and decode audio signals. In some embodiments, the audio module 170 can be arranged in the processor 110, or some functional modules of the audio module 170 can be arranged in the processor 110.

[0120] The pressure sensor 180A is used to sense the pressure signal and can convert the pressure signal into an electrical signal. In some embodiments, the pressure sensor 180A can be set on the display screen 194. There are many types of pressure sensors 180A, such as resistive pressure sensors, inductive pressure sensors, capacitive pressure sensors, etc. The capacitive pressure sensor can be a parallel plate including at least two conductive materials. When a force acts on the pressure sensor 180A, the capacitance between the electrodes changes. The mobile phone 100 determines the intensity of the pressure according to the change in capacitance. When a touch operation acts on the display screen 194, the mobile phone 100 detects the touch operation intensity according to the pressure sensor 180A. The mobile phone 100 can also calculate the touch position according to the detection signal of the pressure sensor 180A. In some embodiments, touch operations acting on the same touch position but with different touch operation intensities can correspond to different operation instructions. For example: when a touch operation with a touch operation intensity less than the first pressure threshold acts on the short message application icon, an instruction to view the short message is executed. When a touch operation with a touch operation intensity greater than or equal to the first pressure threshold acts on the short message application icon, an instruction to create a new short message is executed.

[0121] The key 190 includes a power key, a volume key, etc. The key 190 can be a mechanical key or a touch key. The mobile phone 100 can receive key input and generate key signal input related to the user settings and function control of the mobile phone 100.

[0122] Motor 191 can generate vibration prompts. Motor 191 can be used for incoming call vibration prompts, and can also be used for touch vibration feedback. For example, touch operations acting on different applications (such as taking pictures, audio playback, etc.) can correspond to different vibration feedback effects. For touch operations acting on different areas of the display screen 194, motor 191 can also correspond to different vibration feedback effects. Different application scenarios (for example: time reminders, receiving messages, alarm clocks, games, etc.) can also correspond to different vibration feedback effects. The touch vibration feedback effect can also support customization.

[0123] Indicator 192 may be an indicator light, which may be used to indicate charging status, power changes, messages, missed calls, notifications, etc.

[0124] The SIM card interface 195 is used to connect the SIM card. The SIM card can be connected to and separated from the mobile phone 100 by inserting it into the SIM card interface 195 or pulling it out from the SIM card interface 195. The mobile phone 100 can support 1 or N SIM card interfaces, where N is a positive integer greater than 1. The SIM card interface 195 can support Nano SIM cards, Micro SIM cards, SIM cards, etc. Multiple cards can be inserted into the same SIM card interface 195 at the same time. The types of the multiple cards can be the same or different. The SIM card interface 195 can also be compatible with different types of SIM cards. The SIM card interface 195 can also be compatible with external memory cards. The mobile phone 100 interacts with the network through the SIM card to realize functions such as calls and data communications. In some embodiments, the mobile phone 100 uses an eSIM, i.e., an embedded SIM card. The eSIM card can be embedded in the mobile phone 100 and cannot be separated from the mobile phone 100.

[0125] The methods in the following embodiments can all be implemented in the mobile phone 100 having the above hardware structure.

[0126] The file processing includes the following stages: file deduplication, access to the deduplicated file, modification of the deduplicated file, and deletion of the deduplicated file. The above stages will be introduced in sections below.

[0127] First, the embodiment of the present application introduces the file deduplication stage.

[0128] A file processing method provided in an embodiment of the present application is applied to an electronic device, wherein the electronic device takes a mobile phone as an example, and specifically comprises the following steps:

[0129] Step S301: The mobile phone responds to a deduplication instruction and scans out duplicate files in the mobile phone.

[0130] In the embodiment of the present application, the deduplication instruction may be generated in response to a user operation.

[0131] Specifically, the mobile phone displays a file to be cleaned interface in response to the user's first operation, and the file to be cleaned interface includes a cleaning control for duplicate files. Then, the mobile phone can generate a deduplication instruction in response to the user's touch operation on the cleaning control. Then, the mobile phone can subsequently scan out duplicate files in response to the deduplication instruction.

[0132] See also Figure 4 , Figure 4 The diagram shows a schematic diagram of the change of the user interface (User Interface) of a mobile phone in response to the user's operation to display the files to be cleaned. The user interface of the files to be cleaned can be referred to as the file to be cleaned interface.

[0133] like Figure 4As shown in FIG. 4( a ), the mobile phone 100 displays a setting interface 402 in response to a user's touch operation on a setting icon in the mobile phone interface 401. For example, Figure 4 As shown in FIG. 4( b), the setting interface 402 includes controls corresponding to the storage items. In response to the user's touch operation on the controls corresponding to the storage items, the mobile phone 100 displays the storage interface 403. For example, Figure 4 The storage interface 403 shown in FIG. (c) includes a cleaning acceleration button 404. In response to the user's touch operation on the cleaning acceleration button 404, the mobile phone 100 displays a cleaning acceleration interface 405. The cleaning acceleration interface 405 includes various files to be cleaned. If there are duplicate files in the files to be cleaned, the cleaning controls corresponding to the duplicate files are displayed. For example, Figure 4 The cleaning acceleration interface 405 (interface of files to be cleaned) shown in FIG. 5 (d) includes a duplicate file entry, and the duplicate file entry includes a cleanup control 406 (a cleanup control corresponding to the duplicate file).

[0134] It is understandable that the first operation mentioned above may be a series of operations including the user clicking a setting icon, the user clicking a control corresponding to a storage item in the setting interface, and the user clicking a cleanup acceleration button in the storage interface.

[0135] In addition to generating a deduplication instruction in response to a user operation in the settings, the mobile phone 100 can also generate a deduplication instruction in response to a user operation in the mobile phone manager. For example, Figure 5 A schematic diagram of a user interface change of a mobile phone in response to a user's operation to display files to be cleaned up is shown. Figure 5 As shown in FIG. 5( a ), the mobile phone 100 displays the mobile phone manager interface 502 in response to the user's touch operation on the mobile phone manager icon in the mobile phone interface 501. For example, Figure 5 As shown in FIG. 1 (b), the mobile phone manager interface 502 includes a cleaning acceleration control 503. In response to the user's touch operation on the cleaning acceleration control 503, the mobile phone 100 displays a cleaning acceleration interface 504 (a file to be cleaned interface), which includes various files to be cleaned. If there are duplicate files in the files to be cleaned, the cleaning control corresponding to the duplicate files is displayed. For example, Figure 5 The cleaning acceleration interface 504 shown in Figure (c) includes a duplicate file entry, and the duplicate file entry includes a cleaning control 505 (a cleaning control corresponding to the duplicate file).

[0136] It is understandable that the first operation mentioned above may be a series of operations including the user clicking on the mobile phone manager icon and the user clicking on the cleaning acceleration control in the mobile phone manager interface.

[0137] The mobile phone 100 can display the classification and sorting results of the files to be cleaned up on the file to be cleaned up interface. The files to be cleaned up include duplicate files, uninstall residual data, etc. The files to be cleaned up can be all files scanned by the mobile phone 100, including files visible to the user and invisible to the user in the prior art.

[0138] The mobile phone 100 responds to the user's touch operation on the cleaning control corresponding to the duplicate files, so that the mobile phone 100 can scan the duplicate files and delete the duplicate files, reduce the number of duplicate files, and then reduce the storage space occupied by duplicate files, save storage space occupancy, and improve the user experience.

[0139] In an embodiment of the present application, without receiving any user operation, the deduplication instruction may also be generated by the mobile phone after the preset conditions are met. The preset conditions may refer to the scenario where the mobile phone is charging with the screen off, or at preset time intervals. For example, the mobile phone can generate a deduplication instruction when the screen is off and charging. For another example, the mobile phone can also generate a deduplication instruction at preset time intervals. The preset time can be one week, one month, etc., and this application does not limit this.

[0140] After the mobile phone scans at least one group of duplicate files in the storage space in response to the deduplication instruction, it can deduplicate all duplicate files in the storage space.

[0141] In some examples, after the mobile phone scans out duplicate files in the storage space in response to the deduplication instruction, it can display at least one group of duplicate files on the mobile phone interface. The mobile phone can determine which duplicate files to deduplication in response to the user's selection operation.

[0142] Step S302: The mobile phone determines a target file from N duplicate files included in a group of duplicate files based on security levels; wherein the security level of the target file is higher than the security levels of N-1 files.

[0143] In an embodiment of the present application, a file includes file path information and file content, and the file path information is used to instruct the mobile phone to find the corresponding file content from the storage space.

[0144] The following description is made by taking a group of duplicate files including N duplicate files as an example, where N is an integer greater than 1.

[0145] First, the mobile phone compares the security levels of N files and selects the file with the highest security level as the target file. The security level can be compared from at least four security aspects, including: file path, file environment, number of file accesses, whether it is the first time the file is saved by the mobile phone, etc.

[0146] The priorities of the above security aspects are as follows: file path, file environment, number of file accesses, and whether it is the first time the file is saved on the mobile phone. That is to say, when the conditions at the higher level are the same, the lower levels will be compared one by one until the target node is determined.

[0147] The mobile phone first determines the file paths of N files, and then compares the security levels of the file paths of the N files. The mobile phone can use the file with the highest security level as the target file, that is, the security level of the file path of the target file is higher than the security level of the file paths of N-1 files. Among them, N-1 files are files other than the target file in a set of duplicate files.

[0148] For example, the security level of the privacy space path is higher than the security level of the public path. Then, if the content of file 2 is the same as that of file 1, and the file path of file 1 is the privacy space path and the file path of file 2 is the public path, then the security level of file 1 is higher than the security level of file 2.

[0149] If the security levels of the file paths of N files are the same, the mobile phone can further determine the file environments of the N files, and then compare the security levels of the file environments of the N files. The mobile phone uses the file with the highest security level of the file environment among the N files as the target file, that is, the security level of the file environment of the target file is higher than the security level of the file environment of N-1 files.

[0150] The file environment can also refer to the application or environment where the file is generated. For example, the security level of the system application that comes with the mobile phone manufacturer is higher than the security level of the third-party application that the user downloads and installs. Then, if the security level of the file path of picture A and picture B is the same, if picture A is saved in the mobile phone by the system application email that comes with the mobile phone manufacturer, and picture B is a copy of picture A that is forwarded by the third-party application 2 that the user downloads and installs and saved in the mobile phone, then the security level of picture A is higher than the security level of picture B.

[0151] If the security level of the file environment of N files is the same, the mobile phone can further determine the number of accesses to the N files, and then compare the number of accesses to the N files. The mobile phone uses the file with the least number of accesses among the N files as the target file, that is, the number of accesses to the target file is less than the number of accesses to the N-1 files.

[0152] For example, when the security levels of the file paths and file environments of file C and file C's duplicate file D are the same, if file C has been read and written 3 times within the historical time period, and file C's duplicate file D has been read and written 100 times within the same historical time period, since the probability of file D being read and written again is high, the security level of file C is higher than that of file D.

[0153] If the access times of the N files are the same, the mobile phone can further determine the file that is first saved in the mobile phone among the N files. The mobile phone can use the first file saved in the mobile phone among the N files as the target file.

[0154] For example, if file 1 generated by third-party application 1 in the / data path is accessed 5 times, and file 2, a copy of file 1 forwarded by third-party application 2 in the / data path, is also accessed 5 times, then if file 1 generated by third-party application 1 appears for the first time in the mobile phone, the mobile phone can determine file 1 as the target file.

[0155] Therefore, the mobile phone can determine a file with the highest security level in a group of duplicate files as the target file by performing the above-mentioned layer-by-layer security comparison on N files.

[0156] See also Figure 6 , Figure 6 A schematic diagram of a process for determining a target file based on a security level provided by a mobile phone in an embodiment of the present application. Figure 6 As shown, the mobile phone assumes that any two files among N files are file one and file two. The mobile phone determines the security level of the file path of file one and the file path of file two. The mobile phone uses the file with a higher security level as the target file. If the security level of the file path of file one is the same as that of the file path of file two, then the mobile phone determines the security level of the file environment of file one and the file environment of file two. The mobile phone uses the file with a higher security level of the file environment as the target file. If the security level of the file environment of file one is the same as that of the file environment of file two, then the mobile phone determines the number of accesses to file one and the number of accesses to file two. The mobile phone uses the file with fewer accesses as the target file. If the number of accesses to file one is the same as that to file two, then the mobile phone determines the file that appears for the first time in the mobile phone. The mobile phone uses the file that appears for the first time in the mobile phone as the target file.

[0157] In the embodiment of the present application, the mobile phone can also increase or decrease the conditions for judging the security level, and compare the security level from more or fewer security aspects. In addition, the priority level corresponding to the security aspect can also be adjusted according to the actual situation of the mobile phone, and the present application does not limit this.

[0158] In an embodiment of the present application, the mobile phone can use the determined target file as the file for storing data in the mobile phone storage space after subsequent deduplication. That is, what is saved in the mobile phone is the file content of the target file, and what is deleted is the file content of N-1 files in a group of duplicate files except the target file.

[0159] The file path information includes directory entries and index nodes. Each file corresponds to an index node. The index node corresponding to the target file is assumed to be the target index node. Then, the mobile phone continues to save the corresponding file content under the target index node.

[0160] Step S303: The mobile phone creates a first index node for the target file.

[0161] Among them, the mobile phone can use the target index node as a hidden node that is invisible to the outside, that is, the target index node contains the corresponding file content, but there is no corresponding directory entry. In this way, the mobile phone needs to create a new index node for the target file and associate the new index node with the target index node. Then, when the mobile phone searches for the target file, it can find the corresponding file content through the new index node and the associated target index node. Among them, the mobile phone sets the new index node created for the target file as the first index node. The first index node does not contain file content and only corresponds to the target item of the target file.

[0162] Specifically, the mobile phone first disconnects the directory item of the target file from the target index node, and then associates the directory item of the target file with the first index node when the first index node is established. In this way, when searching for the target file, the mobile phone can find the directory item of the target file, then find the first index node associated with the target item, and then find the corresponding file content through the target index node associated with the first index node, thereby achieving access to the target file.

[0163] It is understandable that when the mobile phone selects the target index node from the existing index nodes, the file content associated with the target index node is already stored in the storage space before the deduplication process. Compared with re-establishing a new index node as the target index node, the association relationship between the target index node selected from the existing index nodes and the file content is already stored, and there is no need to re-establish the association relationship between the target index node and the file content. Therefore, the mobile phone selects the target index node from the existing index nodes and retains the file content associated with the target index node, making the data storage more stable, and the process of the mobile phone accessing the file content through the target associated node is more accurate.

[0164] Step S304: The mobile phone establishes a mapping relationship between the target index node and the first index node and the second index node respectively.

[0165] In the embodiment of the present application, the mobile phone not only establishes a mapping relationship between the first index node and the target index node, but also establishes a mapping relationship between the index nodes corresponding to the N-1 files and the target index node. The mobile phone can set the index nodes corresponding to the N-1 files in a group of duplicate files other than the target file as the second index node.

[0166] Therefore, for N-1 files, the mobile phone can find the file content included in the target index node by determining the second index nodes of the N-1 files and the target index nodes associated with the second index nodes.

[0167] After the mobile phone establishes mapping relationships between the target index node and the first index node and the second index node respectively, step S305 is executed.

[0168] Step S305: The mobile phone deletes the file contents of N-1 files from the storage space.

[0169] As a result, the mobile phone only saves the file contents contained in the target index node, and a set of duplicate files is saved in the bottom layer of the file system, thereby saving a lot of storage space. In addition, when the mobile phone establishes a mapping relationship between the target index node and the first index node and the second index node, the first index node and the second index node are still associated with the directory entries corresponding to each file, so the user side can also see multiple data files with different purposes through the external directory entries, which does not affect the user's use of the file.

[0170] Among them, the file content contained in the target index node is the data that has been stored in the storage space of the mobile phone before the file deduplication process, which is more secure and stable. The mobile phone only needs to determine the associated target index node according to the index node corresponding to each file, and then it can find the file content under the target index node. The process of searching for file content on the mobile phone is safer.

[0171] The mobile phone determines the target file from a group of duplicate files based on the security level, and the security level of the target file is higher than that of N-1 duplicate files. Since the mobile phone considers the security of the only actual data retained after the file is deduplicated from the data source, the mobile phone ultimately stores the file content under the target file, which improves the security of the stored data.

[0172] See also Figure 7 , Figure 7 FIG. 1 shows a schematic diagram of the overall process of a file processing method. Figure 7As shown, step S701, the mobile phone receives a deduplication instruction. Step S702, the mobile phone responds to the deduplication instruction and scans out all duplicate files in the mobile phone. Then, step S703, the mobile phone selects a file with the highest security level in a group of duplicate files as the target file based on the security level, and sets the index node of the target file as the target index node. Step S704, the mobile phone determines whether the current file is the target file (optimal file). If the current file is the target file, then, step S705, the mobile phone creates an alternative index node for the target file and associates it with the target index node. Step S706, the index node of the non-target file is associated with the target index node. If the current file is a non-target file, then step S706 is also executed.

[0173] Finally, in step S707, the mobile phone deletes the file contents of the non-target files to complete deduplication. At this point, the entire deduplication process is completed.

[0174] The present application also provides another file processing method, which is applied to an electronic device. The electronic device takes a mobile phone as an example, and includes steps S601 to S605, which are specifically as follows:

[0175] Step S601: The mobile phone responds to a deduplication instruction and scans out duplicate files in the mobile phone.

[0176] Among them, step S601 can refer to the specific content of step S301, and this application will not elaborate on it here.

[0177] Step S602: The mobile phone determines a target file from N duplicate files included in a group of duplicate files.

[0178] In the embodiment of the present application, the mobile phone can randomly select one file from N duplicate files as the target file.

[0179] A file includes file path information and file content. The file path information is used to instruct the mobile phone to find the corresponding file content from the storage space. The file path information includes an index node.

[0180] Step S603: The mobile phone creates a first index node for the target file.

[0181] Among them, step S603 can refer to the specific content of step S303, and this application will not elaborate on it here.

[0182] Step S604: The mobile phone establishes a mapping relationship between the target index node and the first index node and the second index node respectively.

[0183] The target index node is the original index node corresponding to the target file. The second index node is the index node corresponding to N-1 files in a group of duplicate files except the target file.

[0184] Among them, step S604 can refer to the specific content of step S304, and this application will not elaborate on it here.

[0185] Step S605: The mobile phone deletes the file contents of N-1 files from the storage space.

[0186] In this solution, the mobile phone retains the file content of the target file node in the storage space and deletes the file content of the non-target file node to achieve the purpose of deduplication. This deduplication operation is simpler, takes less time, and saves power consumption of the deduplication operation.

[0187] See also Figure 8 , Figure 8 FIG. 1 shows a schematic diagram of the structure of an index node. Figure 8 As shown, the index node is a structure, and an index node includes multiple variables, including: i_mode: stores the file type and permission information of the file; i_size: stores the size of the file; i_uid: the unique identifier corresponding to the file.

[0188] In the embodiment of the present application, the target index node may be set as a trusted node, and the non-target index node may be set as a trusted node.

[0189] A variety of new attributes have been added to the structure of the index node. Among them, the new attributes include i_trust_ino: used to record the ino of the trusted node that is invisible to the outside and corresponds to the deduplicated file. For example, if the file corresponding to the index node is the target file, then the index node is the target index node. If the file corresponding to the index node is a non-target file, then the i_trust_ino of the index node records the identification information of the target index node corresponding to the index node.

[0190] New attributes also include i_trust_flags: used to record the flags of the index node and distinguish different types of index nodes. The types of index nodes include ordinary index nodes, trust nodes, and trusted. Ordinary index nodes indicate that the file corresponding to the index node has not been deduplicated.

[0191] Among them, the mobile phone can set different numbers as the flags of the index node. For example, the normal index node corresponds to 0, the trust node corresponds to 1, and the trusted node corresponds to 2. Then, the mobile phone can determine the type of the index node through the number recorded in the i_trust_flags of the index node. In other words, the mobile phone can determine the type of the corresponding file through the number recorded in the i_trust_flags of the index node.

[0192] New attributes include i_trust_state: used to indicate the deduplication status. The deduplication status includes deduplication in progress, deduplication completed, and deduplication not completed.

[0193] New attributes also include i_trust_count: used to indicate the number of trust nodes associated with a trusted node. Each time a trusted node is associated with a new trust node, the corresponding i_trust_count count increases by 1. For a trust node, the corresponding index node may not contain the i_trust_count attribute.

[0194] Therefore, the index node maintains the mapping relationship of the trust-trusted symmetric structure by adding the above attributes.

[0195] See also Fig. 9 , Fig. 9 FIG. 1 shows a schematic diagram of deduplication of two duplicate files. Fig. 9 As shown, ordinary file A and ordinary file B are two duplicate files with the same file content.

[0196] like Fig. 9 As shown in (a), the file path information of common file A includes directory entry A, index node A associated with directory entry A, and index node A is associated with the file content of common file A. The file path information of common file B includes directory entry B, index node B associated with directory entry B, and index node B is associated with the file content of common file B.

[0197] Assuming that ordinary file A is used as the target file, the mobile phone sets the attribute i_trust_flags of index node A to the trusted node and i_trust_state to deduplication. Fig. 9As shown in (a), the mobile phone can create a new index node C for the common file A. Among them, the i_trust_flags of the index node C is set to the trust node, the i_trust_state is set to deduplication, and the i_trust_ino records the ino of the externally invisible trusted inode A corresponding to the deduplication file, so that the externally visible trust inode C can find the associated index node A.

[0198] Then, if Fig. 9 As shown in (b), the mobile phone disconnects the directory entry A from the index node A, and establishes the connection between the directory entry A and the index node C, and the connection between the index node C and the index node A. The mobile phone clears the value of the directory entry A in the i_dir of the index node A, disconnects the link with the outside world, and sets it to a hidden state. Since the i_trust_ino of the index node C is recorded to the index node A, the value of the i_trust_count of inode A is increased by 1, indicating that a pair of trust-trusted mappings has been established.

[0199] The mapping relationship is that one trusted can correspond to multiple trusted nodes. For a set of duplicate files, there is only one single trusted node.

[0200] Then, if Fig. 9 As shown in (c), the mobile phone establishes a connection between index node B and index node A. Since the i_trust_ino of index node B is recorded in index node A, the value of i_trust_count of index node A is increased by 1, indicating that another pair of trust-trusted mappings is established.

[0201] In the case of more duplicate files, other trust nodes are similarly mapped with the trusted nodes one by one. For each trust-trusted mapping, the value of i_trust_count of trusted node A is cumulatively increased by 1.

[0202] Finally, if Fig. 9 As shown in (d), the mobile phone deletes the file content associated with inode B.

[0203] In the process of completing the deduplication of the above-mentioned common file A and common file B, the common file A and common file B become deduplication file A and deduplication file B. After the mobile phone clears all redundant data, the i_trust_state of the group of index nodes for which the trust-trusted mapping is established is set to the deduplication state.

[0204] Therefore, the above-mentioned file deduplication process can be summarized into three steps: hiding data, establishing a mapping relationship, and clearing the original data area. After the file deduplication is completed, only one file content is stored in the storage space of the mobile phone, saving storage space.

[0205] In some scenarios, see Fig.10 , Fig.10 A schematic diagram of a deduplication method is shown. Fig.10 As shown, for a group of duplicate files (file A and file B), the index node A of file A and the index node B of file B are both used as externally exposed nodes (out nodes). These externally exposed nodes do not store data. Instead, a new index node C is copied, which inherits the properties of index node A and is specifically used to store data to achieve a deduplication effect.

[0206] exist Fig.10 In the process of deduplication method shown, a new index node C needs to be created, and the index node C needs to be re-associated with the index node A, the index node B and the storage data address respectively (ie Fig.10 1, 2, 3, 4 in the above association process, Fig.10 The association processes 1, 2, 3, and 4 in the above diagram may all be abnormal, and there are many risk points. In particular, when accessing files, both file A and file B need to access the file content through index node C. If the association process between index node C and the storage data address is abnormal during the deduplication process ( Fig.10 If there are problems with 3 and 4), then all external index nodes (index node A and index node B) may not be able to access the actual data, or the accessed data may be incomplete.

[0207] Using the file deduplication method provided in the embodiment of the present application, compared with Fig.10 As for the method shown, this scheme selects an index node from the existing index nodes as the target index node associated with the actual data. In other words, the storage data address of the externally unavailable node trusted inode (target index node) and the underlying actual data has been written to the disk before the file is deduplicated, and is stable and secure data. Therefore, in this scheme, the target index node is selected from the existing index nodes, and the connection relationship between the target index node and the storage data address is retained, so that the file access after deduplication is more accurate.

[0208] Moreover, this scheme can select the target index node based on the security level. Fig.10 The deduplication architecture shown only considers the efficiency of deduplication recovery, and further considers the security and controllability of data.

[0209] In the embodiment of the present application, if some files are generated in the storage space of the mobile phone, and the files are also duplicate files after the deduplication operation, the mobile phone can deduplicate the above duplicate files again. Specifically, the mobile phone establishes a mapping relationship between the index node of the file and the target index node originally determined in the group of duplicate files, and deletes the file content of the file. Among them, the value of i_trust_count of the target index node is increased by 1.

[0210] In some embodiments, the mobile phone can also re-determine the target file node. The method for determining the target file node can refer to the method for determining the target file node described in the above embodiment. For example, if the target file node is determined based on the security level, then the security level of the original file corresponding to the target index node is compared with the security level of the newly generated file.

[0211] If the security level of the original file corresponding to the current target index node is still higher than the security level of the newly generated file, the target index node will not change. The mobile phone will establish a mapping relationship between the index node of the newly generated file and the target index node, and delete the file content of the newly generated file.

[0212] If the security level of the original file corresponding to the current target index node is lower than the security level of a newly generated file 1, the mobile phone can use the newly generated file 1 as a new target index node. The mobile phone establishes a mapping relationship between the index nodes of the newly generated file except file 1 and the new target index node, and deletes the file content of the newly generated file. In addition, the mobile phone creates a replacement index node for file 1 and establishes a mapping relationship with the new target index node.

[0213] Then, the mobile phone disconnects the index node of the original deduplicated file from the original target index node, and establishes a mapping relationship between the index node of the original deduplicated file and the new target index node. The mobile phone deletes the file content associated with the original target index node. As a result, only the file content associated with the new target index node is retained in the mobile phone, and the file content of the remaining duplicate files is deleted, saving the storage space of the mobile phone.

[0214] Next, the embodiment of the present application introduces access to the deduplicated files.

[0215] In the embodiment of the present application, when the mobile phone receives a read operation for a certain file, the mobile phone first determines whether it is a deduplicated file by the i_trust_flags flag of the index node corresponding to the file. The read operation is used to trigger the mobile phone to read the file content corresponding to the file.

[0216] If it is an ordinary file, the mobile phone can obtain the file content directly through the index node corresponding to the file through the original normal data reading process.

[0217] If it is a deduplicated file, the mobile phone determines the corresponding index node according to the file path information of the file. Then, the mobile phone can find the corresponding target index node according to the mapping relationship of the index node. Finally, the mobile phone reads the file content corresponding to the target index node from the storage space according to the target index node.

[0218] See also Fig.11 , Fig.11 A flowchart of a deduplicated file reading process provided in an embodiment of the present application. Fig.11 As shown, after receiving the read request for file 1, the mobile phone finds the corresponding index node from the dir path and determines the type of the index node, that is, whether the index node is a deduplication index node (trust node). If the mobile phone determines that the index node is a deduplication index node, the mobile phone accesses the associated target index node (trusted node) that is invisible to the outside through the corresponding index node, and finally the mobile phone sends the file read request to the real data area through the target index node.

[0219] If the mobile phone determines that the index node is a common index node, the mobile phone directly accesses the real data area through the index node corresponding to file 1.

[0220] In the above-mentioned process of reading files for deduplication, a series of index node conversion configurations are performed in the mobile phone, including: dir->trust node->trusted node->file content.

[0221] Therefore, for data access to deduplicated files, it is necessary to use the target index node that stores the actual data. The deduplication process is fast and effective, and the robustness is relatively good.

[0222] Next, the embodiment of the present application introduces the deletion of the deduplicated files.

[0223] The mobile phone responds to a deletion operation on a file, and the deletion operation is used to trigger the mobile phone to delete the file content corresponding to the file. The mobile phone determines the corresponding index node according to the file path information corresponding to the file, and determines whether the file is a deduplicated file based on the index node.

[0224] If the mobile phone determines that the file is a deduplicated file, the mobile phone can delete the mapping relationship between the index node and the associated target index node, as well as the file path information of the file. The mobile phone deletes the file path information of the file, that is, the mobile phone deletes the target item and index node of the file.

[0225] See also Fig.12 , Fig.12 A schematic diagram of deleting files after deduplication provided in an embodiment of the present application. Fig.12 As shown in the figure, assume that a set of duplicate files includes file 1, file 2, and file 3. The mobile phone saves file 1 through application 1, file 2 through application 2, and file 3 through application 3. Then, the file connection relationship diagram of file 1, file 2, and file 3 after deduplication processing is as follows Fig.12 As shown in (a). The index node corresponding to file 1 is index node D (trust inode D), the index node corresponding to file 2 is index node B (trust inode B), and the index node corresponding to file 3 is index node C (trust inode C). The target index node associated with these three index nodes is set to index node A (trusted inode A). The target index node contains the file content.

[0226] Assume that the mobile phone receives a delete operation for file 2, then, Fig.12 As shown in (b), the mobile phone disconnects the link between the index node B (trust inode B) of file 2 and the target index node A (trusted inode A). Then, the mobile phone clears the index node B (trust inode B) of file 2 and the directory entry B of file 2. Finally, the set of duplicate files only contains file 1 and file 3, and the corresponding file connection relationship diagram is shown in Fig.12 as shown in (c).

[0227] It can be understood that the above-mentioned deletion operation on file 2 has no effect on directory entry A of file 1 and directory entry C of file 3.

[0228] After deleting file 2, the mobile phone will reduce the value of i_trust_count of the target index node of the group of duplicate files by 1.

[0229] Next, the embodiment of the present application introduces the modification of the deduplicated file.

[0230] The mobile phone responds to a modification operation on a certain file (file X), and the modification operation is used to trigger the mobile phone to modify the file. The mobile phone determines the corresponding index node according to the file path information of the file, and determines whether the file is a deduplicated file based on the index node.

[0231] If the mobile phone determines that the file is a deduplicated file, then the mobile phone can delete the mapping relationship between the index node and the associated target index node. Then, the mobile phone copies the file content corresponding to the target index node, and uses the copied file content and the index node as a new file X. The mobile phone modifies the new file X.

[0232] See also Fig.13 , Fig.13 A schematic diagram of a file modified after deduplication provided in an embodiment of the present application. Fig.13 As shown in Figure 1, assume that a set of duplicate files includes file a, file b, and file c. The mobile phone saves file a through application 1, file b through application 2, and file c through application 3. Then, the file connection relationship diagram of file a, file b, and file c after deduplication processing is as follows: Fig.13 As shown in (a). The index node corresponding to file a is index node d (trust inode d), the index node corresponding to file 2 is index node b (trust inode b), and the index node corresponding to file 3 is index node c (trust inode c). The target index node associated with these three index nodes is set to index node a (trusted inode a). The target index node contains the file content.

[0233] Assume that the mobile phone receives a delete operation for file b, then, Fig.13 As shown in (b), the mobile phone disconnects the link between the index node trusted inode b of file b and the target index node trusted inode a.

[0234] Then, the mobile phone will find the trust inode b through the directory entry b of file b. Trust inode b finds the trusted inode a through the trust-trusted mapping, and finds the actual data (file content a) indirectly. The mobile phone reads the data of file content a and applies for new storage space as the data area for writing file b. The mobile phone copies file content a to generate file content b. Fig.13 As shown in (c), the mobile phone uses the copied file content b and the index node of file b as a new file b, and modifies certain data in the file content b. Fig.13 The 1301 shown in (c) is the modified data block, wherein the association relationship between the index nodes of file a and file c and the target index node has not changed.

[0235] Among them, after the file b is modified, it becomes a new file for the mobile phone, and the data of the new file b needs to be written to the disk, that is, the mobile phone writes the data of the new file b to the disk.

[0236] It can be understood that the above modification operation on file b has no effect on directory entry a of file a and directory entry c of file c.

[0237] After the mobile phone modifies the file b, it will reduce the value of i_trust_count of the target index node of the group of duplicate files by 1.

[0238] Since file b becomes a new file after modification, the deduplication feature of file b needs to be cleaned. Specifically, the i_trust_ino value of the trust inode b corresponding to file b is cleared, and the link with the target index node trusted inode a is disconnected. The i_trust_flags of trust inode b is set to a normal index node; the i_trust_state of trust inode b is set to not deduplicated, etc.

[0239] In the embodiment of the present application, after receiving a modification operation or a deletion operation for a deduplicated file, the mobile phone will determine the number of index nodes that establish a mapping relationship with the target index node, that is, determine the value of i_trust_count of the target index node. If the number is 0, that is, the value of i_trust_count of the target index node is 0, the mobile phone deletes the target index node and the file content corresponding to the target index node from the storage space.

[0240] In the embodiment of the present application, after the mobile phone successfully deletes the file contents other than the target file, the mobile phone displays the file processing result for the group of duplicate files, and the file processing result is used to indicate that the N duplicate files are successfully deduplicated. The present application does not limit the display format of the file processing result.

[0241] In summary, through the file processing method provided by the embodiment of the present application, only the file content contained in the target index node is saved in the mobile phone, so that only one copy of the data is saved in the bottom layer of the file system for a group of duplicate files, thereby saving a lot of storage space. In addition, when the mobile phone establishes a mapping relationship with the first index node and the second index node for the target index node, the first index node and the second index node are still associated with the directory items corresponding to each file, so the user side can also see multiple data files with different purposes through the external directory items, which does not affect the user's use of the file.

[0242] See also Fig.14, which is a diagram of the software architecture inside an electronic device. The layered architecture divides the software into several layers, each with clear roles and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the internal architecture of the electronic device can be divided into five layers, from top to bottom, namely, the application layer, the application framework layer, the Android runtime (ART) and the native C / C++ library, the hardware abstract layer (HAL), and the kernel layer.

[0243] The application layer can include a series of application packages.

[0244] like Fig.14 As shown, the application package may include camera, gallery, call, map, navigation, WLAN, Bluetooth, music, video, SMS, file management, mobile phone manager and other applications. In the embodiment of the present application, the mobile phone may generate a deduplication instruction in response to the user's operation on file management or mobile phone manager.

[0245] The application framework layer provides an application programming interface (API) and a programming framework for the applications in the application layer. The application framework layer includes some predefined functions.

[0246] like Fig.14 As shown, the application framework layer may include a window manager, a content provider, a view system, a resource manager, a notification manager, an activity manager, an input manager, and the like.

[0247] The Android runtime includes the core library and the Android runtime. The Android runtime is responsible for converting source code into machine code. The Android runtime mainly uses the ahead of time (AOT) compilation technology and the just in time (JIT) compilation technology.

[0248] The core library is mainly used to provide basic Java class library functions, such as basic data structures, mathematics, IO, tools, databases, networks, etc. The core library provides an API for users to develop Android applications.

[0249] The native C / C++ library can include multiple functional modules, such as surface manager, media framework, libc, OpenGL ES, SQLite, Webkit, etc.

[0250] The hardware abstraction layer runs in user space, encapsulates the kernel layer driver, and provides a calling interface to the upper layer. The hardware abstraction layer includes at least a display module, a camera module, an audio module, and a Bluetooth module.

[0251] The kernel layer is the layer between hardware and software. The kernel layer contains at least display driver, camera driver, audio driver, and Bluetooth driver.

[0252] In the embodiment of the present application, after the mobile phone generates a deduplication instruction in response to the user's operation, the deduplication instruction passes through the application layer, the application framework layer, the Android runtime and the native C / C++ library, and the hardware abstraction layer before reaching the kernel layer. The kernel layer responds to the deduplication instruction and executes the above-mentioned file deduplication step. The mobile phone determines a target file and a corresponding target index node in a group of duplicate files in the kernel layer, establishes a new index node for the target file, and establishes a mapping relationship between the target index node and the new index node and the index nodes of files other than the target file.

[0253] Correspondingly, after the mobile phone responds to the user's modification operation on the file, it generates a corresponding modification instruction, which is transmitted through the application layer, application framework layer, Android runtime and native C / C++ library, and hardware abstraction layer before reaching the kernel layer. In response to the modification instruction, the kernel layer disconnects the index node of the file to be modified from the target index node, copies the file content corresponding to the target index node, and uses the copied file content and the index node of the file to be modified as the new file to be modified. Then, the kernel layer modifies the new file to be modified according to the modification instruction contained in the modification instruction.

[0254] Correspondingly, after the mobile phone responds to the user's deletion operation on the file, it generates a corresponding deletion instruction, which is transmitted through the application layer, application framework layer, Android runtime and native C / C++ library, and hardware abstraction layer before reaching the kernel layer. In response to the deletion instruction, the kernel layer deletes the mapping relationship between the index node and the target index node, and deletes the file path information of the deleted file.

[0255] The file processing methods in the aforementioned embodiments can all be implemented in the electronic device 100 having the aforementioned software structure.

[0256] The present application also provides a chip system, such as Fig.15As shown, the chip system 900 includes at least one processor 901 and at least one interface circuit 902. The processor 901 and the interface circuit 902 can be interconnected via lines. For example, the interface circuit 902 can be used to receive signals from other devices (such as a memory of an electronic device). For another example, the interface circuit 902 can be used to send signals to other devices (such as the processor 901). Exemplarily, the interface circuit 902 can read instructions stored in the memory and send the instructions to the processor 901. When the instructions are executed by the processor 901, the electronic device can execute the various steps in the above embodiments. Of course, the chip system may also include other discrete devices, which are not specifically limited in the embodiments of the present application.

[0257] An embodiment of the present application also provides a computer-readable storage medium, which includes computer instructions. When the computer instructions are executed on the above-mentioned electronic device, the electronic device executes each function or step executed by the mobile phone in the above-mentioned method embodiment.

[0258] The embodiment of the present application also provides a computer program product. When the computer program product is run on a computer, the computer is enabled to execute each function or step executed by the mobile phone in the above method embodiment.

[0259] The various embodiments of the mechanism disclosed in the present application can be implemented in hardware, software, firmware or a combination of these implementation methods. The embodiments of the present application can be implemented as a computer program or program code executed on a programmable system, which includes at least one processor, a storage system (including volatile and non-volatile memory and / or storage elements), at least one input device and at least one output device.

[0260] Program code can be applied to input instructions to perform the functions described in this application and generate output information. The output information can be applied to one or more output devices in a known manner. For the purposes of this application, a processing system includes any system having a processor such as, for example, a digital signal processor (DSP), a microcontroller, an application specific integrated circuit (ASIC), or a microprocessor.

[0261] Program code can be implemented with high-level programming language or object-oriented programming language to communicate with the processing system. When necessary, program code can also be implemented with assembly language or machine language. In fact, the mechanism described in this application is not limited to the scope of any specific programming language. In either case, the language can be a compiled language or an interpreted language.

[0262] Through the description of the above implementation methods, technical personnel in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.

[0263] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0264] The units described as separate components may or may not be physically separated, and the components shown as units may be one physical unit or multiple physical units, that is, they may be located in one place or distributed in multiple different places. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.

[0265] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0266] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium, including several instructions to enable a device (which can be a single-chip microcomputer, chip, etc.) or a processor (processor) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk and other media that can store program code.

[0267] The above contents are only specific implementation methods of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions within the technical scope disclosed in the present application shall be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims

1. A file processing method, characterized in that: Applied to electronic equipment, the method comprises: The electronic device scans duplicate files in the electronic device in response to the deduplication instruction; The electronic device determines a target file from N duplicate files included in a group of duplicate files; wherein each file in the N duplicate files includes file path information and file content, the file path information is used to instruct the electronic device to find the corresponding file content from the storage space, and the file path information includes an index node; The electronic device establishes a first index node for the target file; the first index node does not contain file content, and the first index node is associated with a directory entry of the target file; The electronic device establishes mapping relationships between the target index node and the first index node and the second index node respectively; wherein the target index node is the original index node corresponding to the target file; and the second index node is the index node corresponding to N-1 files in the set of duplicate files except the target file; The electronic device deletes the file contents of the N-1 files from the storage space.

2. The method according to claim 1, characterized in that The electronic device determines a target file from N duplicate files included in a group of duplicate files, including: The electronic device determines a target file from N duplicate files included in a group of duplicate files based on security levels; wherein the security level of the target file is higher than the security levels of the N-1 files.

3. The method according to claim 2, characterized in that The security level of the target file is higher than the security level of the N-1 files, including at least one of the following: The security level of the file path of the target file is higher than the security level of the file paths of the N-1 files; The security level of the file environment of the target file is higher than the security level of the file environment of the N-1 files; The number of accesses to the target file is less than the number of accesses to the N-1 files; and The target file is a file among the N repeated files that is saved in the electronic device for the first time.

4. The method according to claim 3, characterized in that: The group of duplicate files includes a first file and a second file; the electronic device determines a target file from N duplicate files included in the group of duplicate files, including: If the security level of the file path of the first file is higher than the security level of the file path of the second file, the electronic device uses the first file as the target file.

5. The method according to claim 4, characterized in that The electronic device determines a target file from N duplicate files included in a group of duplicate files, including: When the security level of the file path of the first file is the same as the security level of the file path of the second file, if the security level of the file environment of the first file is higher than the security level of the file environment of the second file, the electronic device uses the first file as the target file.

6. The method according to claim 5, characterized in that The electronic device determines a target file from N duplicate files included in a group of duplicate files, including: When the security level of the file environment of the first file is the same as the security level of the file environment of the second file, if the number of accesses to the first file is less than the number of accesses to the second file, the electronic device uses the first file as the target file.

7. The method according to claim 6, characterized in that The electronic device determines a target file from N duplicate files included in a group of duplicate files, including: When the number of accesses to the first file is the same as the number of accesses to the second file, if the first file is a file that is first saved in the electronic device among the N duplicate files, the electronic device uses the first file as the target file.

8. The method according to any one of claims 1 to 7, characterized in that The file path information includes a directory item; the electronic device establishes a first index node for the target file, including: The electronic device disconnects the directory entry of the target file from the target index node of the target file; When establishing the first index node, the electronic device associates the directory entry of the target file with the first index node.

9. The method according to claim 1, characterized in that: After the electronic device deletes the file contents of the N-1 files from the storage space, the method further includes: In response to a delete operation on a first file, the electronic device determines a corresponding third index node according to file path information of the first file; wherein the delete operation is used to trigger the electronic device to delete file content corresponding to the first file, the first file is any one of the N duplicate files, and the third index node is one of the first index node and the second index node; The electronic device deletes the mapping relationship between the third index node and the target index node, and the file path information of the first file.

10. The method according to claim 1, characterized in that After the electronic device deletes the file contents of the N-1 files from the storage space, the method further includes: In response to a modification operation on a second file, the electronic device determines a corresponding fourth index node according to file path information of the second file; wherein the modification operation is used to trigger the electronic device to modify the second file, the second file is any one of the N repeated files, and the fourth index node is one of the first index node and the second index node; The electronic device deletes the mapping relationship between the fourth index node and the target index node; The electronic device copies the file content corresponding to the target index node, and uses the copied file content and the fourth index node as a new second file The electronic device modifies the new second file.

11. The method according to claim 9 or 10, characterized in that: The method further comprises: The electronic device determines the number of index nodes that establish a mapping relationship with the target index node; If the number is 0, the electronic device deletes the target index node and the file content corresponding to the target index node from the storage space.

12. The method according to any one of claims 1 to 7, characterized in that After the electronic device deletes the file contents of the N-1 files from the storage space, the method further includes: In response to a read operation on a third file, the electronic device determines a corresponding fifth index node according to file path information of the third file; wherein the read operation is used to trigger the electronic device to read file content corresponding to the third file, the third file is any one of the N repeated files, and the fifth index node is one of the first index node and the second index node; The electronic device finds the corresponding target index node based on the fifth index node according to the mapping relationship of the index nodes; The electronic device reads the file content corresponding to the target index node from the storage space according to the target index node.

13. The method according to any one of claims 1 to 7, characterized in that After the electronic device deletes the file contents of the N-1 files from the storage space, the method further includes: The electronic device displays a file processing result of the N duplicate files, where the file processing result is used to indicate that the N duplicate files are successfully deduplicated.

14. An electronic device, characterized in that: The electronic device comprises: a communication module, a memory and one or more processors; the communication module, the memory and the processor are coupled; the memory is used to store computer program code, and the computer program code comprises computer instructions, and when the computer instructions are executed by the electronic device, the electronic device executes the method as described in any one of claims 1 to 13.

15. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores instructions, and when the instructions are executed in an electronic device, the electronic device executes the method according to any one of claims 1 to 13.

16. A computer program product, characterized in that The computer program product includes instructions, and when the instructions are executed in an electronic device, the electronic device executes the method according to any one of claims 1 to 13.

Citation Information

Patent Citations

  • Data processing method and electronic equipment

    CN117251411A