File processing method and electronic equipment

By using the file indicator field (U field) in electronic devices to determine the file modification status, the problem of file management bottleneck is solved, and efficient file management and storage space optimization is achieved.

CN119513041APending Publication Date: 2025-02-25HUAWEI TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411397973.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2022-09-05
Publication Date
2025-02-25

AI Technical Summary

Technical Problem

File systems in existing electronic devices have file management bottlenecks when managing large amounts of files, resulting in low available storage space.

Method used

By introducing a file processing method in an electronic device, the file's indication field (U field) is used to determine the modification status of the file. This method attempts to modify the value of the U field at the first moment. If successful, the value of the U field will be queried at the second moment to determine whether the file is modified from the first moment to the second moment.

Benefits of technology

It realizes efficient file management, reduces the resource consumption of electronic devices for monitoring file modification status, avoids misjudgment, and improves the utilization rate of storage space.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119513041A_ABST
    Figure CN119513041A_ABST
Patent Text Reader

Abstract

A file processing method and an electronic device, relating to the technical field of terminals, can reduce the occupation of storage space, the method is applied to the electronic device, the electronic device stores an indication field of a first file, the initial value of the indication field is a first value, and the initial value of the indication field is a second value. The indication field is modified to a second value by the electronic equipment when the first file is modified; the method comprises the following steps: attempting to modify the value of an indication field of a first file into a third value at a first moment; the third value is different from the first value; the third value is different from the second value; if the value of the indication field of the first file is successfully modified into the third value, acquiring the value of the indication field at a second moment; and according to the value of the indication field of the first file at the second moment, judging whether the first file is modified within the time period from the first moment to the second moment.
Need to check novelty before this filing date? Find Prior Art

Description

[0001] This application is a divisional application. The application number of the original application is 202211095247.7, and the original application date is September 5, 2022. The entire content of the original application is incorporated into this application by reference. Technical Field

[0002] The present application relates to the field of terminal technology, and in particular to a file processing method and an electronic device. Background Art

[0003] Currently, many electronic devices use file systems within their operating systems to manage files. With the rapid increase in the number of files stored in electronic devices, file system management has become a bottleneck. In some scenarios, files in electronic devices can occupy a large amount of storage space, resulting in a low available storage space. Summary of the Invention

[0004] This application provides a file processing method and electronic device that can efficiently manage files.

[0005] In order to achieve the above objectives, the embodiments of the present application provide the following technical solutions:

[0006] In a first aspect, a file processing method is provided, which is applied to an electronic device or a component supporting a function of the electronic device (such as a chip system). The electronic device stores an indication field of a first file, the indication field having an initial value of a first value, and the indication field being modified by the electronic device to a second value when the first file is modified. The method includes:

[0007] At a first moment, attempting to modify a value of an indication field of a first file to a third value; the third value is different from the first value; and the third value is different from the second value;

[0008] If the value of the indicator field of the first file is successfully modified to the third value, then at the second moment, the value of the indicator field is obtained;

[0009] According to the value of the indication field of the first file at the second moment, it is determined whether the first file is modified during a period from the first moment to the second moment.

[0010] For example, Figure 13 At time t1 (an example of the first time), the mobile phone successfully modifies the value of the U field (an example of the indicator field) of English grammar 3 (an example of the first file) to V1 (an example of the third value). At time t5 (an example of the second time), the mobile phone queries the value of the U field. Based on the value of the U field of English grammar 3 at time t5, the mobile phone can determine whether English grammar 3 has been modified between t1 and t5.

[0011] In an embodiment of the present application, the modification status of the first file can be determined by the value of the indicator field of the first file, and then the first file can be managed accordingly according to the modification status of the first file. Among them, the electronic device does not need to continuously monitor the modification status of the first file from the first moment to the second moment, but can stop monitoring at other moments other than the first moment and the second moment to reduce the resource consumption of the electronic device for monitoring. For example, at the first moment, the electronic device can try to modify the value of the indicator field of the first file to V1 through the first application, and after the first moment, the electronic device can exit the first application. At the second moment, the electronic device opens the first application again, obtains the value of the indicator field of the first file, and determines whether the first file has been modified between the first moment and the second moment based on the value of the indicator field. It can be seen that in an embodiment of the present application, when the first application does not need to be resident, the electronic device can also determine whether the first file has been modified within a certain period of time, which can reduce the occupancy of storage space.

[0012] Moreover, this solution has nothing to do with the system time, so even if the user modifies the system time, it will not lead to misjudgment.

[0013] In one possible design, attempting to modify the value of the indication field of the first file to a third value includes:

[0014] If the first condition is met, the value of the indication field is modified to a third value; under the first condition, the file system of the electronic device can detect the modification operation on the first file during the period from the first moment to the second moment.

[0015] In this way, once the file is modified between the first moment and the second moment, the file system can ensure that the modification is perceived and the value of the indicator field of the file is modified to a non-V1 value (such as the second value V2). Subsequently, the electronic device can query the value of the indicator field of the file. If the value of the indicator field is modified to a non-V1 value, the electronic device determines that the file was modified between the first moment and the second moment. Conversely, if the value of the indicator field remains V1, it is determined that the file was not modified between the first moment and the second moment.

[0016] In one possible design, after the first moment, the method further includes:

[0017] It is detected that the first file is modified, and the value of the indication field of the first file is modified to a second value.

[0018] Determining, based on a value of an indicator field of the first file at the second moment, whether the first file is modified during a period from the first moment to the second moment includes:

[0019] If the value of the indication field of the first file at the second moment is the second value, it is determined that the first file is modified during the period from the first moment to the second moment; or, if the value of the indication field of the first file at the second moment is not the third value, it is determined that the first file is modified during the period from the first moment to the second moment.

[0020] For example, Figure 12 After time t1 (an example of the first time), at time t3, the phone detects that English grammar 2 has been modified (this modification is the first memory write after time t1), and the phone changes the value of the U field of English grammar 2 to V2 (an example of the second value). At time t5 (an example of the second time), the phone queries the value of the U field of English grammar 2 and finds that the value of the U field of English grammar 2 at time t5 is V2 (no longer V1). Therefore, it is determined that English grammar 2 has been modified between time t1 and t5.

[0021] In one possible design, determining, based on a value of an indicator field of the first file at the second moment, whether the first file is modified during a period from the first moment to the second moment includes:

[0022] If the value of the indication field of the first file at the second moment is the third value, it is determined that the first file has not been modified during the period from the first moment to the second moment; or, if the value of the indication field of the first file at the second moment is not the second value, it is determined that the first file has not been modified during the period from the first moment to the second moment.

[0023] For example, Figure 13 After the mobile phone manager application scans for duplicate files (e.g., performing a binary comparison) and before displaying the scan results to the user, at time t5, the mobile phone manager application queries the value of the U field in the English Grammar 3 file and learns that the field value is V1 (an example of a third value). Since the field value of the U field in English Grammar 3 at time t5 is the same as the field value at time t1, both are V1, the mobile phone manager application can determine that the English Grammar 3 file has not been modified between time t1 and time t5.

[0024] In one possible design, attempting to modify the value of the indication field of the first file to the third value includes: if the first condition is not satisfied, not modifying the indication field to the third value;

[0025] The method further includes: when the value of the indication field of the first file cannot be successfully modified to the third value, determining that the first file is modified within a period from the first moment to the second moment.

[0026] For example, Figure 15Assume that before time t1, the phone performed a memory write operation on Computer Technology 1, one of the candidate duplicate files. After the initial screening of duplicate files is completed, at time t1, the mobile phone manager application cannot successfully modify the value of the U field of Computer Technology 1 to V1 (the value of the U field remains V0) because the first condition is not met. In this case, the mobile phone manager application will treat Computer Technology 1 as a modified file (no longer a duplicate file) and will not perform deduplication on Computer Technology 1 to avoid incorrect deduplication.

[0027] In one possible design, the first condition includes one or more of the following conditions: before the first moment, the first file is not mapped to the memory; before the first moment, the first file is mapped to the memory, but the electronic device has not performed a write operation on the memory.

[0028] For a certain file, if the file is not mapped to the memory before the first moment, then once the mobile phone performs one or more memory write operations on the file between the first moment and the second moment, the first memory write operation will definitely cause the mobile phone to execute the relevant code of the file system. In other words, at least the first memory write operation between the first moment and the second moment will be detected by the file system. In this way, the file system can determine that the file has been modified based on at least the first memory write operation between the first moment and the second moment, and accordingly modify the value of the U field of the file to V2. Subsequently, the application can query the value of the U field of the file, and determine whether the file has been modified between the first moment and the second moment based on the value of the U field. It can be seen that in the embodiment of the present application, the file system does not need to detect every memory write operation. Even if the file system misses the memory write operation, the file system can determine that the file has been modified based on at least the first memory write operation detected within a period of time. In this way, the detection accuracy of the electronic device can be improved.

[0029] Similarly, for a file, if the file was mapped to memory before a first moment, but the electronic device had not performed any write operations on the memory, then if the mobile phone subsequently performs one or more write operations on the file between the first moment and the second moment, the first write operation will inevitably cause the mobile phone to execute the relevant code of the file system. In other words, if the file is modified between the first moment and the second moment, the modification will be detected by the file system.

[0030] Based on this principle, if a file is mapped to memory before a first moment, but the electronic device has not performed a write operation on the memory, the electronic device can modify the value of the U field of the file to V1 at the first moment. Subsequently, if the file is modified between the first moment and the second moment, the value of the U field of the file will be modified by the file system to a non-V1 value (such as V2). The electronic device can determine whether the file has been modified between the first moment and the second moment based on the value of the U field of the file.

[0031] It can be seen that this solution can reduce the misjudgment of mmap scenarios.

[0032] In one possible design, the method further includes:

[0033] Scanning and obtaining duplicate files in the electronic device, the duplicate files including a first file and a second file; the first file is stored in a first storage space, and the second file is stored in a second storage space;

[0034] Determining that the first file and the second file have not been modified during a period from the first moment to the second moment;

[0035] The first interface is displayed; the first interface includes information about the first file and information about the second file.

[0036] For example, if the scan results in English grammars 1-4 being a set of duplicate files, and these four duplicate files are stored in storage spaces 1-4 respectively, if it is determined that English grammar 2 is modified between the first moment and the second moment, and English grammars 1, 3, and 4 are not modified between the first moment and the second moment, then it means that English grammars 1, 3, and 4 still constitute duplicate files. Figure 10A (c), the mobile phone may display a first interface 906, which includes information about a group of duplicate files of English grammar 1, 3, and 4.

[0037] In one possible design, a first operation input by a user in a first interface is detected;

[0038] The first file and the second file are compressed into the same storage space.

[0039] For example, Figure 10A In step (c), the mobile phone detects the user clicking the compress button 907 (an example of the first operation). The mobile phone compresses the set of duplicate files (English grammars 1, 3, and 4) selected by the user. After compression, English grammars 1, 3, and 4 are allocated to the same storage space. This frees up storage space.

[0040] In one possible design, after scanning the electronic device for duplicate files, the method further includes:

[0041] Store the identifier of the first file and the identifier of the second file. For example, Figure 11 In the embodiment of the present invention, the electronic device stores the identifier of the duplicate file in a duplicate file information library.

[0042] In one possible design, the identifier of the first file includes a first index node number of the first file; and the identifier of the second file includes a second index node number of the second file.

[0043] Subsequently, when the user opens the mobile manager and clicks the "Clean and Accelerate" button, the phone can detect that the first and second files have historically been duplicates based on the stored duplicate file identifiers. The phone can then query the values ​​of the U fields in the first and second files to determine whether the first and second files are still duplicates. This eliminates the need for the phone to rescan the contents of the first and second files, helping to reduce phone operating costs.

[0044] In one possible design, determining, based on a value of an indicator field of the first file at the second moment, whether the first file is modified during a period from the first moment to the second moment includes:

[0045] If the value of the indicator field of the first file at the second moment is the third value, and the index node number of the first file is the first index node number, it is determined that the first file has not been modified during the period from the first moment to the second moment.

[0046] In a second aspect, a file processing method is provided, which is applied to an electronic device or a component (such as a chip system) that supports the functions of the electronic device, and the method includes:

[0047] Displaying a second interface, the second interface including a plurality of duplicate files scanned in the electronic device; the plurality of duplicate files are respectively stored in a plurality of storage spaces of the electronic device;

[0048] In response to an operation input by the user on the second interface, at a third moment, obtaining an indication field of each duplicate file in the plurality of duplicate files, wherein a value of the indication field of the duplicate file is used to indicate whether the duplicate file has been modified;

[0049] According to the values ​​of the indication fields of the multiple duplicate files at the third moment, some duplicate files among the multiple duplicate files are compressed into the same storage space.

[0050] For example, Figure 10A (c) The mobile phone displays interface 906 (an example of the second interface), which includes multiple duplicate files obtained by scanning (the duplicate files of English grammar 1, 3, and 4, and the duplicate files of computer 2 and 3).

[0051] In response to the user clicking the compression button 907 on the interface 906, at the third moment, the mobile phone obtains the indication fields of the duplicate files of English grammar 1, 3, and 4 selected by the user, and compresses some of the files in English grammar 1, 3, and 4 into the same storage space according to the values ​​of the respective indication fields of English grammar 1, 3, and 4 at the third moment.

[0052] In this solution, the indication field of the duplicate files in the second interface can be obtained according to the user's operation, and some of the duplicate files can be compressed according to the indication field of each duplicate file. On the one hand, the storage space of the electronic device can be released. On the other hand, instead of compressing all the duplicate files selected by the user, it is checked whether the duplicate files really need to be compressed according to the value of the indication field of the duplicate file selected by the user, so as to reduce the probability of miscompression and prevent miscompression from affecting the normal operation of the electronic device. It can be seen that this solution can achieve accurate file compression, and thus can accurately release the storage space of the electronic device. Moreover, it can effectively avoid the problem of misdeduplication caused by the deduplication program not sensing the modification of the duplicate files because other processes have modified the duplicate files before deduplication is performed.

[0053] In one possible design, the initial value of the indication field of each duplicate file is the first value.

[0054] In one possible design, before displaying the second interface, the method further includes:

[0055] Scanning to obtain multiple candidate duplicate files; the multiple candidate duplicate files include multiple duplicate files;

[0056] At a first moment, attempting to modify a value of an indication field of each candidate duplicate file in a plurality of candidate duplicate files to a third value;

[0057] The multiple candidate duplicate files are compared to determine multiple duplicate files from the multiple candidate duplicate files.

[0058] For example, Figure 10B After the user clicks the "Clean Up" button, the phone initially screens and obtains multiple candidate duplicate files. English grammar 1-5 constitutes a group of candidate duplicate files, and computer technology 1-4 constitutes a group of candidate duplicate files. At time t1 (an example of the first time), the phone attempts to modify the value of the indicator field of each candidate duplicate file to V1 (an example of the third value).

[0059] In a possible design, multiple candidate duplicate files are obtained by scanning, including:

[0060] Displaying a third interface, where the third interface includes the first control;

[0061] A user operation on the first control is detected, and a plurality of candidate duplicate files are obtained by scanning.

[0062] For example, Figure 10A (a), the mobile phone displays an interface 901 (an example of the third interface), and the interface 901 includes a cleaning acceleration button 902 (a first control). When the user clicks the cleaning acceleration button 902, the mobile phone scans and obtains multiple candidate duplicate files (such as Figure 10B English grammar 1-5 shown), and obtain multiple duplicate files based on multiple candidate duplicate files (such as Figure 10B English grammar shown in 1-4).

[0063] In a possible design, multiple candidate duplicate files are obtained by scanning, including:

[0064] When the electronic device is idle, multiple candidate duplicate files are scanned, for example, at night, or after the screen is locked for a certain period of time.

[0065] By performing a pre-scan when the phone is idle, the time required for subsequent file deduplication can be saved, the efficiency of file deduplication can be improved, and the efficiency of human-computer interaction between users and electronic devices can be improved.

[0066] In one possible design, after the first moment, the method further includes:

[0067] At a second moment, obtaining a value of an indication field of at least one duplicate file and an inode number of at least one duplicate file;

[0068] When the third condition is met, the second interface is displayed; the third condition includes: the value of the indication field of at least one duplicate file at the second moment is the third value, and the index node number of at least one duplicate file is consistent with the index node number stored in the database.

[0069] For example, Figure 10B At time t5 (an example of the second time), the mobile phone queries the value of the U field (indicator field) of English grammars 1-4. Among them, the value of the U field of English grammar 2 is V0 (not V1), and the values ​​of the U fields of English grammars 1, 3, and 4 are all V1. The mobile phone can determine that English grammars 1, 3, and 4 have not been modified during the period t1-t5. The mobile phone can Figure 10A The interface 906 (second interface) shown in (c) displays information of English grammar 1, 3, and 4.

[0070] In one possible design, attempting to modify the value of the indication field of each candidate duplicate file in the plurality of candidate duplicate files to a third value includes:

[0071] If at least one candidate duplicate file among multiple candidate duplicate files meets the first condition, the value of the indication field of at least one candidate duplicate file is modified to a third value; under the first condition, the file system of the electronic device can detect the modification operation on at least one candidate duplicate file within the time period from the first moment to the second moment.

[0072] In one possible design, obtaining, at the second moment, a value of an indication field of at least one duplicate file includes: obtaining, at the second moment, a value of an indication field of a target duplicate file in the at least one duplicate file as a third value;

[0073] The method further includes: when the value of the indication field of the target duplicate file at the second moment is a third value, determining that the target duplicate file is not modified during a period from the first moment to the second moment.

[0074] In one possible design, the plurality of candidate duplicate files include a third file;

[0075] After the first moment, the method further includes: detecting that the third file is modified, and modifying the value of the indication field of the third file to a second value;

[0076] At the second moment, the value of the indication field of the third file obtained is not the third value;

[0077] It is determined that the third file is modified during a period from the first moment to the second moment.

[0078] In one possible design, the plurality of candidate duplicate files include a fourth file;

[0079] At the first moment, attempting to modify the value of the indicator field of each candidate duplicate file in the plurality of candidate duplicate files to a third value includes: if the fourth file does not meet the first condition, not modifying the indicator field of the fourth file to the third value;

[0080] The method further includes: when the value of the indication field of the fourth file cannot be successfully modified to the third value, determining that the fourth file is modified within a time period from the first moment to the second moment.

[0081] In a possible design, compressing some of the duplicate files into the same storage space according to the values ​​of the indication fields of the multiple duplicate files at the third moment includes:

[0082] If the value of the indicator field of the first file among the multiple duplicate files at the third moment is a third value, compressing the first file;

[0083] Alternatively, if the value of the indication field of the first file among the multiple duplicate files at the third moment is not the third value, compression is not performed on the first file.

[0084] Exemplarily, if the value of the indicator field of the first file among the multiple duplicate files at the third moment is a third value, compression is performed on the first file;

[0085] Alternatively, if the value of the indication field of the first file among the multiple duplicate files at the third moment is not the third value, compression is not performed on the first file.

[0086] For example, Figure 19 After the user clicks the "Compress" button and before the phone performs deduplication, at time t9 (the third time), the mobile manager app again queries the value of the U field for each duplicate file (English Grammar 1, 3, and 4, and Computer Technology 1 and 2). It determines that the value of the U field for English Grammar 3 was successfully set to V1 at time t1, but the value of the U field is V0 at time t9. Therefore, the mobile manager app can determine that English Grammar 3 was modified between times t1 and t9. Similarly, the mobile manager app determines whether the other duplicate files were modified between times t1 and t9.

[0087] like Figure 19 Since English grammar 3 was modified between t1 and t9, it is no longer a duplicate file with English grammars 1 and 4. The mobile manager app does not perform deduplication on English grammar 3. Conversely, if English grammars 1 and 4 were not modified between t1 and t9, they are still duplicate files. The mobile manager app can perform deduplication on English grammars 1 and 4 at t10.

[0088] In this way, by verifying whether the file is a duplicate file before actual compression and deduplication, the probability of false deduplication can be reduced and the accuracy of deduplication can be improved.

[0089] In one possible design, the method further includes:

[0090] The information of the multiple duplicate files is stored in a database, where the information of the duplicate files includes any one or more of the following information: an index node number of the duplicate file, a path of the duplicate file, and a name of the duplicate file.

[0091] In one possible design, when the value of the indicator field of the target duplicate file at the second moment is the third value, determining that the target duplicate file is not modified during the period from the first moment to the second moment includes:

[0092] When the value of the indicator field of the target duplicate file is the third value, if the index node number of the target duplicate file has not changed, it is determined that the target duplicate file has not been modified during the period from the first moment to the second moment.

[0093] In a third aspect, a file processing device is provided, which is applied to an electronic device or a chip system. For example, the electronic device stores an indication field of a first file, where the initial value of the indication field is a first value and the indication field is modified to a second value by the electronic device when the first file is modified. The device includes:

[0094] Processing module for:

[0095] At a first moment, attempting to modify a value of an indication field of a first file to a third value; the third value is different from the first value; and the third value is different from the second value;

[0096] If the value of the indicator field of the first file is successfully modified to the third value, then at the second moment, the value of the indicator field is obtained;

[0097] According to the value of the indication field of the first file at the second moment, it is determined whether the first file is modified during a period from the first moment to the second moment.

[0098] In one possible design, attempting to modify the value of the indication field of the first file to a third value includes:

[0099] If the first condition is met, the value of the indication field is modified to a third value; under the first condition, the file system of the electronic device can detect the modification operation on the first file during the period from the first moment to the second moment.

[0100] In one possible design, the processing module is further configured to detect, after the first moment, that the first file is modified, and modify the value of the indication field of the first file to a second value.

[0101] Determining, based on a value of an indicator field of the first file at the second moment, whether the first file is modified during a period from the first moment to the second moment includes:

[0102] If the value of the indication field of the first file at the second moment is the second value, it is determined that the first file is modified during the period from the first moment to the second moment.

[0103] In one possible design, determining, based on a value of an indicator field of the first file at the second moment, whether the first file is modified during a period from the first moment to the second moment includes:

[0104] If the value of the indication field of the first file at the second moment is the third value, it is determined that the first file has not been modified during the period from the first moment to the second moment.

[0105] In one possible design, attempting to modify the value of the indication field of the first file to the third value includes: if the first condition is not satisfied, not modifying the indication field to the third value;

[0106] The processing module is further configured to determine that the first file is modified within a period from the first moment to the second moment when the value of the indication field of the first file cannot be successfully modified to the third value.

[0107] In one possible design, the first condition includes one or more of the following conditions: before the first moment, the first file is not mapped to the memory; before the first moment, the first file is mapped to the memory, but the electronic device has not performed a write operation on the memory.

[0108] In a possible design, the processing module is further configured to:

[0109] Scanning and obtaining duplicate files in the electronic device, the duplicate files including a first file and a second file; the first file is stored in a first storage space, and the second file is stored in a second storage space;

[0110] Determining that the first file and the second file have not been modified during a period from the first moment to the second moment;

[0111] The device also includes a display module, which is used to display a first interface; the first interface includes information about the first file and information about the second file.

[0112] In one possible design, the device further includes an input module, the input module being configured to detect a first operation input by a user in the first interface;

[0113] The processing module is configured to compress the first file and the second file into the same storage space according to the first operation detected by the input module.

[0114] In one possible design, the device further includes a storage module, which is configured to store the identifier of the first file and the identifier of the second file after scanning the electronic device for duplicate files.

[0115] In one possible design, the identifier of the first file includes a first index node number of the first file; and the identifier of the second file includes a second index node number of the second file.

[0116] In one possible design, determining, based on a value of an indicator field of the first file at the second moment, whether the first file is modified during a period from the first moment to the second moment includes:

[0117] If the value of the indicator field of the first file at the second moment is the third value, and the index node number of the first file is the first index node number, it is determined that the first file has not been modified during the period from the first moment to the second moment.

[0118] In a fourth aspect, a file processing device is provided, which is applied to an electronic device or a chip system, and includes:

[0119] A display module is configured to display a second interface, wherein the second interface includes a plurality of duplicate files scanned in the electronic device; the plurality of duplicate files are respectively stored in a plurality of storage spaces of the electronic device;

[0120] a processing module, configured to, in response to an operation input by a user on the second interface, obtain, at a third moment, an indication field of each duplicate file in the plurality of duplicate files, wherein a value of the indication field of the duplicate file is used to indicate whether the duplicate file has been modified;

[0121] The processing module is further configured to compress some of the duplicate files into the same storage space according to the values ​​of the indication fields of the multiple duplicate files at a third moment.

[0122] In one possible design, the initial value of the indication field of each duplicate file is the first value.

[0123] In one possible design, the processing module is further configured to scan and obtain a plurality of candidate duplicate files before displaying the second interface; the plurality of candidate duplicate files include a plurality of duplicate files;

[0124] The processing module is further configured to, at a first moment, attempt to modify the value of the indication field of each candidate duplicate file in the plurality of candidate duplicate files to a third value.

[0125] In a possible design, multiple candidate duplicate files are obtained by scanning, including:

[0126] Controlling the display module to display a third interface, where the third interface includes the first control;

[0127] A user operation on the first control is detected, and a plurality of candidate duplicate files are obtained by scanning.

[0128] In a possible design, multiple candidate duplicate files are obtained by scanning, including:

[0129] When the electronic device is idle, multiple candidate duplicate files are scanned and obtained.

[0130] In one possible design, the processing module is further configured to obtain, at a second moment after the first moment, a value of an indication field of at least one duplicate file;

[0131] The display module is also used to display a second interface according to the value of the indication field of at least one duplicate file at the second moment; the multiple duplicate files in the second interface are files whose modification status is unmodified during the period from the first moment to the second moment.

[0132] In one possible design, attempting to modify the value of the indication field of each candidate duplicate file in the plurality of candidate duplicate files to a third value includes:

[0133] If at least one candidate duplicate file among multiple candidate duplicate files meets the first condition, the value of the indication field of at least one candidate duplicate file is modified to a third value; under the first condition, the file system of the electronic device can detect the modification operation on at least one candidate duplicate file within the time period from the first moment to the second moment.

[0134] In one possible design, obtaining, at the second moment, a value of an indication field of at least one duplicate file includes: obtaining, at the second moment, a value of an indication field of a target duplicate file in the at least one duplicate file as a third value;

[0135] The processing module is further configured to determine, when the value of the indicator field of the target duplicate file at the second moment is a third value, that the target duplicate file has not been modified during a period from the first moment to the second moment.

[0136] In one possible design, the plurality of candidate duplicate files include a third file;

[0137] The processing module is also used to:

[0138] After the first moment, it is detected that the third file is modified, and the value of the indication field of the third file is modified to a second value;

[0139] At the second moment, the value of the indication field of the third file obtained is not the third value;

[0140] It is determined that the third file is modified during a period from the first moment to the second moment.

[0141] In one possible design, the plurality of candidate duplicate files include a fourth file;

[0142] At the first moment, attempting to modify the value of the indicator field of each candidate duplicate file in the plurality of candidate duplicate files to a third value includes: if the fourth file does not meet the first condition, not modifying the indicator field of the fourth file to the third value;

[0143] The processing module is further configured to determine that the fourth file is modified within a period from the first moment to the second moment when the value of the indication field of the fourth file cannot be successfully modified to the third value.

[0144] In a possible design, compressing some of the duplicate files into the same storage space according to the values ​​of the indication fields of the multiple duplicate files at the third moment includes:

[0145] If the value of the indicator field of the first file among the multiple duplicate files at the third moment is a third value, compressing the first file;

[0146] Alternatively, if the value of the indication field of the first file among the multiple duplicate files at the third moment is not the third value, compression is not performed on the first file.

[0147] In a possible design, the storage module is used to store identifiers of multiple duplicate files, where the identifiers of the duplicate files include index node numbers of the duplicate files.

[0148] In one possible design, when the value of the indicator field of the target duplicate file at the second moment is the third value, determining that the target duplicate file is not modified during the period from the first moment to the second moment includes:

[0149] When the value of the indicator field of the target duplicate file is the third value, if the index node number of the target duplicate file has not changed, it is determined that the target duplicate file has not been modified during the period from the first moment to the second moment.

[0150] In any possible design of any of the above aspects, the indication field is stored in a metadata area of ​​the electronic device.

[0151] In any possible design of any of the above aspects, the identifier of the first file includes a first index node number of the first file; and the identifier of the second file includes a second index node number of the second file.

[0152] In any possible design of any of the above aspects, the first condition includes one or more of the following conditions: before the first moment, the duplicate file was not mapped to the memory; before the first moment, the duplicate file was mapped to the memory, but the electronic device did not perform a write operation on the memory. BRIEF DESCRIPTION OF THE DRAWINGS

[0153] Figure 1A An example diagram of a duplicate file scanning process provided in an embodiment of the present application;

[0154] Figure 1B An example diagram of the i-mt ime field provided in an embodiment of the present application;

[0155] Figure 2 A schematic diagram of a write operation using a write interface provided in an embodiment of the present application;

[0156] Figure 3 A schematic diagram of a write operation in a write memory mode provided in an embodiment of the present application;

[0157] Figure 4 、 Figure 5 Another schematic diagram of a write operation provided in an embodiment of the present application;

[0158] Figure 6 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application;

[0159] Figure 7 A schematic diagram of the software structure of the electronic device provided in an embodiment of the present application;

[0160] Figure 8 Schematic diagram of the data area and metadata area provided in the embodiment of the present application;

[0161] Figure 9 A schematic diagram of a file processing method provided in an embodiment of the present application;

[0162] Figure 10A A schematic diagram of the interface provided in an embodiment of the present application;

[0163] Figure 10B 、 Figure 10C A schematic diagram of a scenario provided for an embodiment of the present application;

[0164] Figure 11 A schematic diagram of a database provided in an embodiment of the present application;

[0165] Figure 12 A schematic diagram of a scenario in which a file is modified according to an embodiment of the present application;

[0166] Figure 13 A schematic diagram of a scenario in which the file provided in the embodiment of the present application is not modified;

[0167] Figure 14 A schematic diagram of the interface provided in an embodiment of the present application;

[0168] Figure 15 A schematic diagram of a scenario in which V1 setting fails according to an embodiment of the present application;

[0169] Figure 16 A schematic diagram of a scenario in which a file is modified according to an embodiment of the present application;

[0170] Figure 17 A schematic diagram of a scenario in which the file provided in the embodiment of the present application is not modified;

[0171] Figure 18 A schematic diagram of a scenario in which V1 setting fails according to an embodiment of the present application;

[0172] Figure 19 A schematic diagram of a scenario provided for an embodiment of the present application;

[0173] Figure 20 A schematic diagram of the interface provided in an embodiment of the present application;

[0174] Figure 21 、 Figure 22 A schematic diagram of the structure of the device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0175] The terms "including," "having," and any variations thereof mentioned in the description of this application are intended to cover non-exclusive inclusions. For example, a process, method, system, product, or apparatus comprising a series of steps or units is not limited to the listed steps or units, but may optionally include other steps or units not listed, or may optionally include other steps or units inherent to the process, method, product, or apparatus.

[0176] It should be noted that in the embodiments of this 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 this application should not be interpreted as being more preferred or advantageous over other embodiments or designs. Rather, the use of words such as "exemplary" or "for example" is intended to present the relevant concepts in a concrete manner.

[0177] In this application, unless otherwise specified, "plurality" means two or more. "And / or" in this document is simply a description of an association between related objects, indicating that three possible relationships exist. For example, "A and / or B" can mean: A exists alone, A and B exist simultaneously, or B exists alone.

[0178] To facilitate understanding, the following first introduces relevant terms and concepts that may be involved in the embodiments of this application.

[0179] 1. File deduplication

[0180] In some scenarios, there are multiple duplicate files in the file system. These duplicate files originally occupied multiple storage spaces. After deduplication, the duplicate files only occupy one storage space. Duplicate files are files with exactly the same content. For example, Figure 1A , file 1 and file 2 constitute duplicate files. Before deduplication, file 1 and file 2 occupy storage space 1 and storage space 2 respectively. After the electronic device performs deduplication on file 1 and file 2, file 1 and file 2 point to the same storage space 1, which greatly frees up the storage space of the electronic device. In some schemes, the electronic device can scan the stored duplicate files. The scanning of duplicate files may include preliminary screening and binary comparison. Among them, during the preliminary screening, the electronic device intercepts part of the content in the file, and obtains a value by reading the part of the content. If the value of the intercepted content of the two files is the same, the electronic device preliminarily believes that the two files may be duplicate files. Afterwards, the electronic device performs a binary comparison on the two files, comparing the entire contents of the two files byte by byte. When the results of the binary comparison are consistent, it means that the two files are duplicate files.

[0181] In other scenarios, binary comparison can also be replaced by other steps for determining duplicate files, such as hash value comparison, etc. The embodiment of the present application does not limit the specific implementation of the duplicate file scanning process.

[0182] 2. i-mtime field

[0183] According to whether the file has been modified within a period of time, the modification status of the file can be divided into two types: one is modified within a period of time, and the other is not modified within a period of time.

[0184] In some schemes, the electronic device can set an i-mtime field, and the i-mtime field can be used to indicate the time when the file was last modified. Optionally, the i-mtime field can usually be stored in the metadata area of ​​the file system. Specifically, the i-mtime field can store the inode area of ​​the metadata area. For example, file 1 has been modified three times in history, and the modification times are 2022-8-22 (8:00), 2022-8-23 (10:00), and 2022-8-23 (18:00), respectively. As shown in Table 1, the field value of the i-mtime field of file 1 can be 2022-8-23 (18:00). Similarly, file 2 has been modified twice in history, with modification times being 2022-8-22 (18:00) and 2022-8-23 (10:00), respectively. As shown in Table 1, the field value of the i-mtime field of file 2 may be 2022-8-23 (10:00).

[0185] Table 1

[0186] i-mtime document 2022-8-23(18:00) File 1 2022-8-23(10:00) File 2

[0187] In some solutions, an application in an electronic device can query a file's i-mt ime field to determine whether the file has been modified within a certain period of time. As one possible implementation, the application queries the file's i-mt ime field at time point 1 and time point 2. If the values ​​of the i-mt ime field obtained in the two queries are consistent, it indicates that the file has not been modified between time point 1 and time point 2. Conversely, if the values ​​of the i-mt ime field obtained in the two queries are inconsistent, it indicates that the file has been modified between time point 1 and time point 2.

[0188] For example, Figure 1BIn (a), the application queries the i-mt ime field of file 1 at 10:00 and learns that file 1 was last modified at 8:00. The application then queries the i-mt ime field of file 1 again at 12:00 and learns that file 1 was last modified at 8:00. In this case, the field values ​​(indicating the last file modification time) obtained from the two queries are the same, and the application can determine that file 1 was not modified between 10:00 and 12:00.

[0189] For example, Figure 1B In (b), the application queries the i-mt ime field of file 1 at 10:00 and learns that file 1 was last modified at 8:00. The application then queries the i-mt ime field again at 12:00 and learns that file 1 was last modified at 11:00. In this case, the two queries yield different field values, allowing the application to determine that file 1 was modified between 10:00 and 12:00.

[0190] 3. Write interface

[0191] As a way of writing files, electronic devices can perform file writing operations through a write interface. In this way of writing files, each write operation will execute a piece of code in the file system, and the file system can modify the i-mtime field of the file to record the time when the file was last modified. For example, Figure 2 When the write interface is called at time t1 (10:00) to modify file 1, the electronic device executes the code in the file system, and the file system can modify the i-mtime field of file 1 to indicate that the time when file 1 was last modified is 10:00. Similarly, when the write interface is called at time t2 (12:00) to modify file 1, the electronic device executes the code in the file system, and the file system can modify the i-mtime field of file 1 to indicate that the time when file 1 was last modified is 12:00.

[0192] 4. mmap

[0193] As another way to write a file, the electronic device can map the file to a certain memory through the mmap interface. Subsequently, when writing a file, the file can be written to the memory. Writing to the memory can be understood as writing content to the memory mapped to the file, which is equivalent to indirectly writing to the corresponding file. In this way of writing a file, after a file is mapped to the corresponding memory, the electronic device will execute the relevant code in the file system when writing to the memory for the first time. In some examples, when writing to the same memory later, the code in the file system may no longer be executed to avoid being trapped in the file system and generating additional overhead.

[0194] For example, Figure 3 (a), the electronic device maps file 2 to memory 2. Figure 3 In (b), at time t1 (10:00), the electronic device performs the first write operation to memory 2 through the mmap interface. At this point, the electronic device executes the relevant code in the file system to write to memory 2. Therefore, the file system is able to detect that file 2 associated with memory 2 has been modified and accordingly modifies the i-mtime field of file 2 to indicate that file 2 was last modified at 10:00.

[0195] Afterwards, still Figure 3 In (b), at time t2, the electronic device writes to memory 2 through the mmap interface. Since memory 2 has been written to in the past, to avoid the system overhead caused by frequent file system calls, the electronic device does not call the file system to perform the write operation on memory 2 at time t2.

[0196] For example, Figure 4At time t1, the electronic device maps a file to a block of memory. Subsequently, at time t2 (10:05), the electronic device writes content to the memory, which is equivalent to writing the corresponding content to the memory-mapped file. Since this is the first write to the memory, the relevant code in the file system is executed. The file system detects the file modification and modifies the file's i-mtime field to indicate that the file was last modified at 10:05. Subsequently, at time t3 (10:06), an application in the electronic device queries the file's i-mtime field. At time t4 (10:07), the electronic device writes content to the same block of memory for the second time. To ensure frequent file system traps, the electronic device does not trap the file system code during this memory write. Therefore, the file system is unaware that the file associated with the memory has been modified and, accordingly, does not modify the file's i-mtime field. At time t5, the application again queries the file's i-mtime field. Since the field value of the i-mtime field queried at time t5 and t3 is both 10:05, the electronic device mistakenly believes that the file has not been modified during the time period t3-t5 (i.e., 10:05-10:07).

[0197] It can be seen that in some scenarios, when performing write operations through mmap, the electronic device will not fall into the file system, resulting in the file system being unable to perceive that the file has been modified, unable to track the modification of the file, and unable to update the field value of the i-mtime field in time, causing the electronic device to misjudge whether the file has been modified.

[0198] 5. Modifying the system time leads to misjudgment of file modification status

[0199] In some scenarios, whether the write operation is performed through the write interface or the mmap interface, if the system time is modified, the modification status of the file may be misjudged. For example, Figure 5 At time t1 (10:00), the file is modified. Afterwards, at time t2, an application in the electronic device queries the i-mtime field of the file and learns that the file was last modified at 10:00. At time t3, the system time of the electronic device is modified, for example, from 10:30 to 9:30. Afterwards, at time t4 (10:00 after the system time is modified), the file is modified again. At time t5, the application queries the i-mtime field of the file again. Since the field value of the i-mtime field queried at times t5 and t3 is both 10:00, the electronic device mistakenly believes that the file has not been modified during the time period t3-t5 (i.e., between 10:05 and 12:00).

[0200] Here, the system time can be modified by the user or automatically by the system.

[0201] It can be seen that since the system time has been modified, the system time may be the same when the file is modified twice, which may cause the electronic device to misjudge whether the file has been modified. This cannot meet the business needs of the electronic device to accurately determine whether the file has been modified. That is, it cannot reliably determine the modification status of the file, and the performance of the electronic device is low.

[0202] 6. inotify

[0203] In some solutions, you can also use the inotify mechanism to monitor file modifications. An application can use the inotify interface to notify the file system that it needs to monitor file modification status. Subsequently, when the file system detects a file modification event, it notifies the application of the file modification. This approach requires the application to be resident during the monitoring period, which consumes more system resources (such as memory resources) and incurs high overhead for electronic devices.

[0204] It can be seen that the above solutions for determining whether a file has been modified cannot enable the electronic device to obtain better performance. In order to solve the above technical problems, the embodiment of the present application provides a file processing method. The method can be applied to electronic devices. For example, the electronic device in the embodiment of the present application can Figure 6 This is achieved by the electronic equipment in the device. Figure 6 FIG2 is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application. The electronic device 200 includes at least one processor 201 , a memory 202 and at least one transceiver 203 .

[0205] The processor 201 may be a general-purpose central processing unit (CPU), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits for controlling the execution of the program of the present application.

[0206] The above components may include communication lines for transmitting information between the above components.

[0207] Transceiver 203 is used to communicate with other devices. In the embodiments of the present application, the transceiver can be a module, circuit, bus, interface, or other device capable of implementing communication functions, used to communicate with other devices. Optionally, the transceiver can be a standalone transmitter that can be used to send information to other devices, or a standalone receiver that can be used to receive information from other devices. The transceiver can also be a component that integrates the functions of sending and receiving information. The embodiments of the present application do not limit the specific implementation of the transceiver.

[0208] The memory 202 may be a read-only memory (ROM) or other type of static storage device that can store static information and instructions, a random access memory (RAM) or other type of dynamic storage device that can store information and instructions, or an electrically erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM) or other optical disc storage, an optical disc storage (including a compact disc, laser disc, optical disc, digital versatile disc, Blu-ray disc, etc.), a magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto. The memory may exist independently and be connected to the processor via a communication line. The memory may also be integrated with the processor.

[0209] The memory 202 is used to store computer-executable instructions for implementing the solution of the present application, and the execution is controlled by the processor 201. The processor 201 is used to execute the computer-executable instructions stored in the memory 202, thereby implementing the various methods provided in the following embodiments of the present application.

[0210] Optionally, the computer-executable instructions in the embodiments of the present application may also be referred to as application code, instructions, computer programs or other names, which are not specifically limited in the embodiments of the present application.

[0211] In a specific implementation, as an embodiment, the processor 201 may include one or more CPUs.

[0212] In a specific implementation, as an embodiment, the electronic device 200 may include multiple processors. Each of these processors may be a single-core (single-CPU) processor or a multi-core (multi-CPU) processor. The processor herein may refer to one or more devices, circuits, and / or processing cores for processing data (e.g., computer program instructions).

[0213] like Figure 6 It should be understood that the electronic device shown is only an example, and in actual application, the electronic device may have more Figure 6 More or fewer components may be shown, two or more components may be combined, or the illustrations may have different configurations of components.

[0214] The software system of the electronic device can adopt a layered architecture, an event-driven architecture, a micro-kernel architecture, a micro-service architecture, or a cloud architecture. For example, the software system of the electronic device can be The embodiment of the present invention takes the Android system with a layered architecture as an example to exemplify the software structure of the electronic device.

[0215] Figure 7 It is a software structure block diagram of the electronic device according to an embodiment of the present invention.

[0216] A layered architecture divides software into several layers, each with distinct roles and responsibilities. Layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into five layers: from top to bottom: the application layer (referred to as the application layer), the application framework layer (referred to as the framework layer), the Android runtime and system libraries, the hardware abstraction layer (HAL), and the kernel layer.

[0217] (1) Application layer

[0218] The application layer can include a series of application packages. Figure 7 As shown, the application package may include camera, gallery, calendar, call, map, navigation, wireless local area network (WLAN), Bluetooth, music, video, short message and other applications.

[0219] In the embodiment of the present application, the application may also include settings, mobile phone management applications, etc. Taking the mobile phone management application as an example, the mobile phone management application can call the interface provided by the file system to modify the field value of the U field of the corresponding file. Subsequently, the mobile phone management application can determine whether the corresponding file has been modified within a period of time based on the field value of the U field.

[0220] Optionally, the application may determine the value of the U field in at least one of the following ways.

[0221] The first way: the application can call the first interface provided by the file system, and the first interface returns the U field value of the file.

[0222] The second method: the application calls the second interface provided by the file system. The file system determines the U field value of the file during execution and determines whether to continue executing the remaining steps of the second interface based on the U field value.

[0223] Optionally, the above application may be an application running in user mode.

[0224] Applications running in "user mode" are called "user-mode programs." For example, applications such as Changlian Communication and Smart Life are user-mode programs. In some cases, user-mode programs need to use functions provided by the operating system (such as reading file contents). In these cases, user-mode programs call the application programming interface (API) provided by the operating system, falling from user mode to kernel mode to execute functions provided by the operating system kernel.

[0225] (2) Framework layer

[0226] The framework layer provides APIs and programming frameworks for applications in the application layer. The framework layer includes some predefined functions.

[0227] like Figure 7 As shown, the framework layer may include an activity manager, a window manager, a content provider, a view system, a phone manager, a resource manager, a notification manager, and the like.

[0228] The activity manager is responsible for launching all app processes, launching the four major app components (e.g., activities, services, broadcast receivers, and content providers), switching between apps and within app interfaces, and managing the lifecycles of various components. The window manager manages window programs. It can obtain the display size, determine whether a status bar is present, lock the screen, take screenshots, and more. The content provider stores and retrieves data and makes it accessible to applications. This data can include video, images, audio, incoming and outgoing calls, browsing history and bookmarks, and the phone book. The view system includes visual controls, such as those for displaying text and images. The view system can be used to build applications. A display interface can consist of one or more views. For example, a display interface containing a text notification icon can include a view for displaying text and a view for displaying images. The call manager provides communication functions for electronic devices, such as managing call states (including connected and ended calls). The resource manager provides applications with various resources, such as localized strings, icons, images, layout files, and video files. The Notification Manager allows applications to display notifications in the status bar. These messages can be displayed briefly and then disappear automatically without user interaction. For example, the Notification Manager is used to notify users of completed downloads and message reminders. The Notification Manager can also display notifications in the top status bar of the system as icons or scrolling text, such as notifications from background applications, or as dialog windows on the screen. Examples include text messages in the status bar, beeps, vibrations on electronic devices, and flashing indicator lights.

[0229] 3. Android Runtime and system libraries

[0230] like Figure 7 As shown, Android Runtime is responsible for the scheduling and management of the Android system.

[0231] The system library can include multiple functional modules, such as surface manager, media library, 3D graphics processing library (such as OpenGL ES), 2D graphics engine (such as SGL), etc.

[0232] The surface manager manages the display subsystem and provides fusion of 2D and 3D layers for multiple applications. The media library supports playback and recording of a variety of common audio and video formats, as well as static image files. The media library supports a variety of audio and video encoding formats, such as MPEG4, H.264, MP3, AAC, AMR, JPG, and PNG. The 3D graphics processing library implements 3D graphics drawing, image rendering, compositing, and layer processing. The 2D graphics engine is the drawing engine for 2D drawing.

[0233] (4) Kernel layer

[0234] The kernel layer is the layer between hardware and software.

[0235] In the embodiments of the present application, the kernel layer may include a file system. The file system is a core module of the operating system kernel, i.e., one of its main components. The file system is responsible for managing and storing file information, primarily creating files for users, storing, reading, modifying, and dumping files, controlling file access, and revoking files when they are no longer in use.

[0236] In some embodiments, the file system may run in kernel mode.

[0237] Applications running in "user mode" are called "user-mode programs." For example, applications such as Changlian Communication and Smart Life are user-mode programs. In some cases, user-mode programs need to use functions provided by the operating system (such as reading file contents). In these cases, user-mode programs call the application programming interface (API) provided by the operating system, falling from user mode to kernel mode to execute functions provided by the operating system kernel.

[0238] Data in a file system can include metadata and data. Metadata is used to describe the characteristics and attributes of a file. Optionally, metadata includes, but is not limited to, the following information: file system control information, data structure, and file description information, such as file length and file type. File types include, for example, regular files (regular inodes), directory files (directory inodes), symbol link inodes (symbol link inodes), and special files (special inodes).

[0239] Optionally, the metadata and data of the file can be stored in a storage device (such as a hard disk). Figure 8 , the storage area of ​​the storage device may include a metadata area and a data area.

[0240] The data of a file can be stored in a data area of ​​a storage device. Optionally, the data stored in the data area can be data obtained by performing file-level compression processing based on lossless compression technology. The data in the data area is stored in the physical storage space of a storage medium (such as a disk, flash memory, etc.) as a collection of disk blocks. The data of the same file can be stored in consecutive disk blocks, or can be stored crosswise in discontinuous disk blocks.

[0241] It should be understood that the introduction of the concept of disk blocks in this application does not mean that the storage medium is limited to disks. Disk blocks can be used to represent small physical storage spaces obtained by dividing the physical storage space of the storage medium.

[0242] like Figure 8 , the data storage location can be represented by the index of the block where the data is located. For example Figure 8 In the example, the file is stored in blocks 909, 912, and 914. The metadata area can store the block indexes 909, 912, and 914 of the file. Subsequently, when performing operations such as reading and writing on the file, the electronic device can read the index of the block where the file is located from the metadata area and access (e.g., read) the file at the location of the corresponding block based on the index.

[0243] In some embodiments, the file system can provide an interface for reading and writing files for user-mode programs. As a first possible implementation, the file system provides a read-write interface (e.g., read, write), and the user-mode program calls the read and write interfaces to read and write files.

[0244] As a second possible implementation, the file system provides a memory mapping interface (e.g., mmap). User-mode programs call the memory mapping interface to map files to memory and obtain the mapped memory address. The user-mode program can then access the file using memory access methods, for example, writing to the file using memory writes.

[0245] In some embodiments, for the first file access method described above, since each file access operation will call an interface provided by the file system, the file system can perceive each file access operation.

[0246] For the second file access method described above, the first file access after mapping is established (such as the first memory write) will cause a memory page fault. At this time, the file system function will be called, so the file system knows that the user-mode program has accessed the file. However, subsequent accesses (such as subsequent memory writes) do not necessarily cause a memory page fault, so the file system may not be aware that the user-mode program has modified the file.

[0247] In the embodiment of this application, Figure 8 As shown, the file system can add an unmodified field (also referred to as a U field) in the metadata area. The U field can indicate whether the corresponding file has been modified. Each file has a corresponding U field.

[0248] Optionally, the file system can set the initial value of the U field. For example, the initial value is set to V0.

[0249] The file system can provide an interface to the application, and the application can call the interface to modify the field value of the U field (for example, to V1). Subsequently, the application can determine whether the corresponding file has been modified based on the field value of the U field.

[0250] As follows, the technical solution of the embodiment of the present application is described in detail by taking a mobile phone as an example of an electronic device.

[0251] Example 1

[0252] like Figure 9 The technical solution of the embodiment of the present application may include the following steps:

[0253] S101: The file system sets the value of the U field of the first file to V0.

[0254] Optionally, the U field may be stored in the metadata area of ​​the file system.

[0255] S102 : At the first moment, the application program calls the interface of the file system and attempts to modify the value of the U field of the first file to V1.

[0256] For example, Figure 10A As shown in (a), the mobile phone displays the mobile phone manager application interface 901, which may include a "clean up and speed up" button 902. After detecting that the user has clicked the "clean up and speed up" button 902, the mobile phone may scan the data stored in the mobile phone for cleaning. The data to be cleaned may include multiple duplicate files, that is, multiple files with exactly the same content.

[0257] In some embodiments, during the process of scanning multiple duplicate files by the mobile phone manager application, the mobile phone manager application calls the interface of the file system to attempt to modify the field value of the U field corresponding to each of the multiple duplicate files from the initial value V0 to V1. Optionally, the process of scanning duplicate files may include preliminary screening and binary comparison. After the mobile phone manager application obtains the files that are initially identified as duplicate files (which may be referred to as candidate duplicate files for short), it may call the interface of the file system before binary comparison to attempt to modify the value of the U field of each candidate duplicate file to V1.

[0258] For example, Figure 12At time t6, after the user clicks the "Clean and Accelerate" button, the mobile phone can perform a preliminary screening of duplicate files. After the preliminary screening is completed, English grammar 1-4 is preliminarily identified as a group of candidate duplicate files, and computer technology 1 and 2 are a group of candidate duplicate files. Taking the attempt to modify the U field value of English grammar 2 in the candidate duplicate file to V1 as an example, the user clicks the "Clean and Accelerate" button, and after the mobile phone performs a preliminary screening of duplicate files, at time t1 (the first moment), the mobile phone manager application calls the interface of the file system and attempts to modify the field value of the U field corresponding to English grammar 2 from V0 to V1. Figure 12 In the example, since the mobile phone has not executed mmap for English grammar 2 before time t 1, the first condition is met, and the mobile phone manager application can successfully modify the value of the U field of English grammar 2 from V0 to V1.

[0259] Similarly, the mobile manager application can try to modify the value of the U field of other candidate duplicate files (ie, files initially identified as duplicate files) to V1.

[0260] As a possible implementation, when the application wants to set the U field of the first file to V1, it can call the file system interface to send a request message to the file system, which is used to request to modify the initial value of the U field of the first file to V1.

[0261] Optionally, V1 can be specified by the application or by the file system.

[0262] In some embodiments, after receiving the request message from the application, the file system determines whether a first condition for modifying the value of the U field of the first file is met. If the first condition is met, the file system may modify the value of the U field of the first file to V1. Conversely, if the first condition is not met, the file system does not modify the value of the U field of the first file to V1.

[0263] Optionally, the first condition includes: whether the file has been mapped to memory (for example, the application has mapped the file using mmap()).

[0264] For example, Figure 15 Before time t1, the mobile phone has mapped the file Computer Technology 1 to the memory, and the first condition is not met. Then, at time t1, the mobile phone manager application will not successfully modify the field value of the U field of Computer Technology 1 from V0 to V1.

[0265] Figure 10BThe figure shows some candidate duplicate files obtained through preliminary screening. After preliminary screening, the mobile phone manager application preliminarily identified English Grammar 1-5 as a group of candidate duplicate files, and Computer Technology 1-4 as another group of candidate duplicate files. At time t1, the mobile phone manager application can call the file system interface to attempt to modify the value of the U field of each candidate duplicate file to V1. For example, Table 2 shows the field values ​​of the U field of each candidate duplicate file after time t1.

[0266] Table 2

[0267] document U field English Grammar 1 V1 English Grammar 2 V1 English Grammar 3 V1 English Grammar 4 V1 English Grammar 5 V1 Computer Technology 1 V0 Computer Technology 2 V1 Computer Technology 3 V1 … …

[0268] As shown in Table 2, the U field value for Computer Technology 1 remains at its initial value, V0. One possible reason for this is that the phone had already mapped Computer Technology 1 to memory before time t1. The U field values ​​for other files, such as English Grammar 1-4 and Computer Technology 2, were modified to V1 by the Mobile Manager app, indicating that the phone had not yet mapped these files to memory before time t1.

[0269] Optionally, when the first condition is met, the file system returns a setting success message to the application, and the application can determine that the value of the U field of the file has been modified to V1.

[0270] Optionally, when the first condition is not met, the file system returns a setting failure return message to the application, and the application can determine that the value of the U field of the file is not set to V1 (still V0).

[0271] S103: When it is detected that the first file is modified, the file system modifies the value of the U field of the first file to V2.

[0272] In some scenarios, users can modify files. For example, Figure 12 Assume that before time t1, the phone had not performed any memory write operations on English grammar 2. At time t3, in response to the user's intention to modify English grammar 2, the phone performs its first memory write operation on English grammar 2. Specifically, the phone's first memory write operation on English grammar 2 inevitably executes relevant code in the file system. Thus, at time t3, the file system detects the modification of English grammar 2 and changes the U field of English grammar 2 from V1 to V2.

[0273] Optionally, the file system can also store the modification time of the file in the metadata area. Figure 12 , the file system can store t3 in the metadata area.,Subsequently, the application can determine the modification time of the file based on the,modification time stored in the metadata area.

[0274] S104. The application determines whether the value of the U field of the first file is successfully set to V1. If the value of the U field of the first file is set to V1, the application executes the following steps S106-S110. If the value of the U field of the first file is not set to V1, the application executes step S111.

[0275] Optionally, the application may receive a return message from the file system, where the return message is used to indicate whether the value of the U field of the first file is successfully set to V1.

[0276] It should be understood that when an application successfully sets the value of the U field of a duplicate file to V1, it means that the mobile phone has not mapped the file to the memory before time t1. In this case, the mobile phone can subsequently map the file to the memory, and if the file is modified by writing to the memory, the mobile phone will definitely execute the relevant code in the file system when the file is written to the memory for the first time. In this way, the file system can sense that the file has been modified and modify the value of the U field of the file (for example, from V1 to V2). The mobile phone can determine that the file has been modified based on the value of the U field of the file (V2). Conversely, if the mobile phone does not modify the file subsequently, the value of the U field of the file will still be V1. The mobile phone can determine that the file has not been modified based on the value of the U field of the file (V1).

[0277] Wherein, the value of V2 is different from that of V1. In some implementations, V2 may be equal to V0.

[0278] Alternatively, if the file is subsequently modified using the write interface, the phone will execute the file system's code each time a write operation is performed. The file system will still detect that the file has been modified and will modify the value of the file's U field (V2). Conversely, if the phone does not subsequently modify the file, the value of the file's U field will remain at V1. The phone can determine that the file has not been modified based on the value of the file's U field (V1).

[0279] In short, if the application can successfully set the value of the U field of the file to V1 at the first moment, regardless of whether the file is subsequently modified by writing to memory or using the write interface, the mobile phone can accurately determine whether the file has actually been modified based on whether the U field value of the file changes subsequently (for example, at the second moment).

[0280] On the contrary, if the application fails to successfully set the value of the U field of a certain file to V1 (still V0), it means that the mobile phone has previously mapped the file to the memory. In this case, if the file is subsequently modified by writing to the memory (not necessarily the first time writing to the memory), in order to reduce overhead, the mobile phone may not execute the relevant code in the file system. The file system cannot track the modification events of the file, and it cannot update the value of the U field of the file when the file is modified. For example, if the file is modified, the file system may not perceive that the file has been modified, so the value of the U field of the file is not updated. For another example, if the file has not been modified, the file system will not update the value of the U field of the file. In this way, regardless of whether the file is modified or not, the value of the U field of the file is V0 (it will not be updated to V2 by the file system), and the mobile phone cannot determine whether the file has been modified based on the value of the U field.

[0281] Considering that if the application fails to successfully set the value of the U field of a file to V1 at the first moment, the file system may not be able to perceive that the file has been modified, and the file system may not update the value of the U field of the file in a timely manner, resulting in the mobile phone being unable to determine whether the file has been modified based on the value of the U field at the second moment. In this case, to avoid data being mistakenly deduplicated, the mobile phone can execute the subsequent step S109 to determine that the first file is not a duplicate file, so as to avoid mistaken deduplication of the first file.

[0282] In some embodiments, when the application lacks the corresponding permission, it may also fail to successfully modify the value of the U field of the file from V0 to V1. In the embodiment of the present application, the system application authorized by the user has the permission to modify the U field to reduce the risk of misjudgment.

[0283] Alternatively, in some embodiments, when there is a lack of storage space, the application may not be able to successfully modify the value of the U field of the file to V1.

[0284] S105 , at the second moment, the application queries the value of the U field of the first file.

[0285] In some embodiments, if the value of the U field of some candidate duplicate files (files initially identified as duplicate files) is successfully modified to V1 at the first moment, the mobile phone can perform a binary comparison on these candidate duplicate files to determine the final duplicate file.

[0286] For example, Figure 10BAt time t6, the user clicks the "Clean Up and Accelerate" button, triggering the mobile phone to perform a preliminary screening of candidate duplicate files. The candidate duplicate files obtained in the preliminary screening include the group of candidate duplicate files of English grammar 1-5, and the group of candidate duplicate files of computer technology 1-4. At time t1, the mobile phone manager application attempts to set the value of the U field of each candidate duplicate file to V1. Assuming that at time t1, the value of the U field of English grammar 1-4 and computer technology 2-4 are successfully set to V1, the mobile phone manager application can perform a binary comparison on the group of candidate duplicate files of application grammar 1-4 and the group of candidate duplicate files of computer technology 2-4 to determine the final duplicate files. After binary comparison, English grammar 1-4 constitutes a group of duplicate files. Computer technology 2-4 constitutes a group of duplicate files.

[0287] In some embodiments, the mobile phone can store the information of duplicate files in a duplicate file information library. Optionally, the duplicate file information library can store the identifier of the duplicate file. Figure 11 The duplicate file information library may include an identifier for each duplicate file in the set of duplicate files "English Grammar 1-4" and an identifier for each duplicate file in the set of duplicate files "Computer Technology 2-4". Optionally, the identifiers for duplicate files include, but are not limited to, the name of the duplicate file, the inode number of the duplicate file, and whether the value of the U field of the duplicate file is successfully set to V1 at the first moment. The inode number of a file is used to uniquely identify a file. Files with different contents have different inode numbers.

[0288] In some embodiments, after scanning and obtaining each duplicate file, before presenting the scan results of the duplicate files to the user, at a second moment, the application can query the value of the U field of each duplicate file, and determine whether each duplicate file has been modified between the first moment and the second moment based on the value of the U field of each duplicate file at the second moment.

[0289] As a possible implementation, the application can query the value of the U field of the file itself. Alternatively, the application can send a query request to the file system, which queries the value of the U field of the file and returns the value of the U field of the file to the application.

[0290] Take the modification status of English grammar 2 in the duplicate file as an example. Figure 12After the initial screening is complete, at time t1, the value of the U field of English grammar 2, initially identified as a duplicate file (candidate duplicate file), is successfully set to V1. The mobile manager then performs a binary comparison on each candidate duplicate file, ultimately determining that English grammars 1-4 constitute a duplicate file group, and that 2-4 constitute a duplicate file group. After scanning each duplicate file and before displaying the duplicate file scan results to the user, at time t5, the mobile manager application can query the value of the U field of English grammar 2 and, based on the U field value at time t5, determine whether English grammar 2 has been modified between t1 and t5.

[0291] S106: The application determines whether the value of the U field of the first file is V1. If the value of the U field is V1, the application proceeds to step S107. If the value of the U field is not V1, the application proceeds to step S108.

[0292] S107: The application determines that the first file has not been modified.

[0293] For example, Figure 13 After the Mobile Manager application completes the duplicate file scan (binary comparison) and before displaying the scan results to the user, at time t5, the Mobile Manager application queries the value of the U field of the duplicate file, English Grammar 3, and learns that the field value is V1. Since the field value of the U field of English Grammar 3 at time t5 is the same as the field value at time t1, both are V1, the Mobile Manager application can determine that the English Grammar 3 file has not been modified between time t1 (when the Mobile Manager application calls the file system interface and attempts to change the field value of the U field of English Grammar 3 from V0 to V1) and time t5.

[0294] Similarly, the mobile manager app can query the value of the U field in English grammars 1, 3, and 4. If the U field value for English grammars 1, 3, and 4 is all V1, the file system has not detected any modifications to English grammars 1, 3, and 4. The mobile manager app can then determine that English grammars 1, 3, and 4 were also unmodified between t1 and t5. Therefore, English grammars 1, 3, and 4 still constitute duplicate files. The mobile manager app can then deduplicate these duplicate files to reduce storage space usage.

[0295] In some embodiments, the application determines the index node number of the first file and the value of the U field of the first file at the second moment. If the index node number of the first file remains unchanged and the value of the U field of the first file at the second moment is V1, it is determined that the first file has not been modified during the period from the first moment to the second moment.

[0296] S108: The application determines that the first file is modified.

[0297] For example, Figure 12 After the mobile phone manager application performs the binary comparison and obtains the scan results for duplicate files, before displaying the scan results to the user, at time t5, the mobile phone manager application can read the field value of the U field of English grammar 2 from the metadata area and learn that the field value is V2. Since the field value of the U field of English grammar 2 at time t5 is different from the field value at time t1, the mobile phone manager application can determine that the file English grammar 2 may have been modified between time t1 (at time t1, the mobile phone manager application requested the file system to change the field value of the U field of English grammar 3 from V0 to V1) and time t5. The mobile phone no longer regards English grammar 2 as a duplicate file. In this way, the mobile phone manager application will not perform deduplication on English grammar 2 subsequently.

[0298] Optionally, the metadata area may further store the modification time t3 of the English grammar 2. The mobile phone manager application may read the modification time from the metadata area and thereby learn that the modification time of the English grammar 2 is t3.

[0299] and Figure 4 In the illustrated solution, the file system misses detection of a second memory write operation, for example, and is unable to update the i-mtime field in a timely manner, causing the electronic device to mistakenly believe that the file has not been modified during the t3-t5 period. In contrast, using the technical solution of the embodiment of the present application, for a certain file, if the file is not mapped to the memory before the first moment, then once the mobile phone subsequently performs one or more memory write operations on the file between the first moment and the second moment, the first memory write operation will inevitably cause the mobile phone to execute the relevant code of the file system. In other words, at least the first memory write operation between the first moment and the second moment will be detected by the file system. In this way, the file system can determine that the file has been modified based on at least the first memory write operation between the first moment and the second moment. It can be seen that in the embodiment of the present application, the file system does not need to detect every memory write operation. Even if the file system misses a memory write operation, the file system can determine that the file has been modified based on at least the first memory write operation detected within a period of time. In this way, the detection accuracy of the electronic device can be improved.

[0300] S109: The application determines that the first file is not a duplicate file.

[0301] As mentioned above, at the first moment, the value of the U field of the first file was not successfully set to V1. This means that between the first moment and the second moment, the first file may have been modified (and may no longer be a duplicate file), but the file system may not be able to detect that the first file has been modified. In this case, the application will treat the first file as a modified file and the first file will no longer be a duplicate file. In addition, the application will not perform deduplication on the first file to avoid mistakenly deduplicating the first file, which is actually a non-duplicate file.

[0302] For example, Figure 15 , assuming that before time t1, the mobile phone has performed a memory write operation on Computer Technology 1 in the candidate duplicate files, then after the initial screening of duplicate files is completed, at time t1, the mobile phone manager application cannot successfully modify the value of the U field of Computer Technology 1 to V1 (the value of the U field is still V0). In this case, the mobile phone manager application can no longer perform a binary comparison on Computer Technology 1. The mobile phone manager application can regard Computer Technology 1 as a modified file (no longer a duplicate file) and no longer perform deduplication on Computer Technology 1 to avoid incorrect deduplication.

[0303] In some embodiments, after the mobile phone manager application determines the modification status of each duplicate file during the period t1-t5, it can present one or more groups of duplicate files that have not been modified to the user. Figure 10B ,During the period t 1-t5, the files that have not been modified include: English Grammar 1, 3, 4, Computer Technology 2, 3. That is, English Grammar 1, 3, 4 still constitute duplicate files, and Computer Technology 2, 3 still constitute duplicate files.

[0304] like Figure 10A (b), at time t2, the mobile phone may display interface 903. Interface 903 may include cards 905 corresponding to duplicate files in the mobile phone. Figure 10A (b) According to card 905, there are 8 groups of duplicate files stored in the mobile phone (including the duplicate files of English grammar 1, 3, and 4 and the duplicate files of computer calculation 2 and 3), and the duplicate files occupy a total of 229 MB of storage space.

[0305] In some examples, after detecting that the user clicks the "lossless compression" button 904, the mobile phone may display the following Figure 10A Interface 906 shown in (c) of FIG. Interface 906 can present detailed information of the above 8 groups of duplicate files. For example, Figure 10AIn (c), interface 906 displays information about the first set of duplicate files, "English Grammar 1, English Grammar 3, English Grammar 4." Interface 906 also displays information about the second set of duplicate files, "Computer Technology 2, Computer Technology 3." In response to a user action, such as swiping up, interface 906 can also display information about other duplicate files. The multiple files in each set of duplicate files occupy different amounts of storage space. For example, English Grammar 1-4 each occupy 24MB of storage space.

[0306] The user can select one or more groups of duplicate files and click the compression button 907. The mobile phone can deduplicate the one or more groups of duplicate files selected by the user according to the user's compression / deduplicate intention. Figure 10A In (c), if the user selects the duplicate files of English grammar, the phone can remove duplicates of the files of English grammar 1, 3, and 4 according to the user's compression intention. Figure 10C After deduplication, English Grammar 1, 3, and 4 only take up one storage space (24MB), which greatly frees up the storage space of the mobile phone.

[0307] In some embodiments, after deduplication, the electronic device can still display the set of files "English Grammars 1, 3, and 4" in the user interface, and the user can still open and use any file in this set normally. Compared to before deduplication, after deduplication, the storage space occupied by "English Grammars 1, 3, and 4" is reduced.

[0308] After performing deduplication processing using the Mobile Manager application, the user can close the Mobile Manager application.

[0309] Optionally, the above-mentioned file deduplication is a possible implementation method of file compression. File compression can also be implemented in other ways, which are not limited by the embodiments of this application.

[0310] The technical solution of the embodiment of the present application has different methods for determining whether a file has been modified within a period of time for different types of files, so as to meet the business needs of determining whether different types of files have been modified.

[0311] Specifically, for file 1 that has not been mapped to the memory before the first moment, the electronic device can modify the value of the U field of file 1 from the initial value V0 to V1 at the first moment. Afterwards, at the second moment, the electronic device can query the value of the U field of file 1 and determine whether the file 1 has been modified based on the value of the U field. In some cases, at the second moment, if the value of the U field of file 1 is a value other than V1 (such as V2), the electronic device can determine that the file 1 has been modified during the period from the first moment to the second moment. In other cases, at the second moment, if the value of the U field of file 1 is V1, the electronic device can determine that the file 1 has not been modified during the period from the first moment to the second moment.

[0312] For file 2 that has been mapped to the memory before the first moment, the electronic device does not modify the value of the U field of file 2 at the first moment (the value of the U field is still the initial value V0). This means that during the period from the first moment to the second moment, file 2 may be modified (may no longer be a duplicate file), but the file system may not be able to detect that file 2 has been modified. In this case, the electronic device regards file 2 as a modified file, and file 2 is no longer a duplicate file. In addition, the application does not perform deduplication processing on file 2 to avoid mistakenly deduplicating file 2, which is actually a non-duplicate file.

[0313] It should be noted that the above V2 can also be replaced by other values ​​other than V1 (such as V0). The embodiment of the present application does not limit the specific value to which the U field is modified when the file system senses that the file has been modified.

[0314] The above mainly uses the mobile phone manager application as an example to illustrate the method for determining the modification status of a file. It should be understood that the application can also be any other possible application. For example, the application can also be a file manager. The file manager can use the technical solution of the embodiment of the present application to determine whether the files in its directory have been modified within a period of time.

[0315] The above mainly takes the example of the user actively triggering the mobile phone to scan for duplicate files. In other embodiments, the mobile phone can scan the duplicate files in the mobile phone by itself, and deduplicate some duplicate files to reduce the storage space occupied. Taking the mobile phone actively scanning for duplicate files and performing deduplication as an example, for example, at time point 1, the application modifies the values ​​of the U fields of files A and B to V1. At time point 2, the application reads the contents of files A and B, and considers files A and B to be duplicate files. At time point 3, file A is modified, and the value of the U field of file A is modified to V2 by the file system. At time point 4, the application queries the values ​​of the U fields of files A and B, and learns that the value of the U field of file A is V1, and the value of the U field of file B is V2, which means that file A has been modified and file B has not been modified, and files A and B are no longer duplicate files. Therefore, the application does not perform deduplication on files A and B.

[0316] As another example, at time point 1, the application modifies the value of the U field in both files A and B to V1. At time point 2, the application reads the contents of files A and B and determines that files A and B are duplicates. At time point 3, the application queries the value of the U field in files A and B and learns that the value of the U field in both files A and B is V1. This means that since time point 1, neither file A or B has been modified and files A and B are still duplicates. Therefore, the application can perform deduplication on files A and B.

[0317] Example 2

[0318] The present application also provides a file processing method in which a file has been mapped to memory and can also include the following two situations: the file has been mapped to memory, but the electronic device has not written to the file-mapped memory; and the file has been mapped to memory, and the electronic device has written to the file-mapped memory. In these two situations, the electronic device can use different methods to determine whether the file has been modified. The following examples illustrate this.

[0319] For example, Figure 16 After initially screening candidate duplicate files, at time t1, the application wants to modify the value of the U field of file English Grammar 2 to V1. The application can call the file system's interface to send a request message to the file system. Upon determining that the file has been mmap'd (i.e., mapped to memory), but no content has been written to the mapped memory, the file system determines that the conditions for modifying the file's U field are met and can modify the value of the file's U field from its initial value V0 to V1. The application can then perform a binary comparison of English Grammar 3 and the other candidate duplicate files to determine the final duplicate file.

[0320] Afterwards, at time t3, the electronic device writes to the memory mapped to the file for the first time, and the electronic device calls the function of the file system, so the file system can perceive the write operation to the file. Figure 16 After the file system senses the write operation on the file, it can modify the value of the U field of the file from V1 to V2.

[0321] Afterwards, if Figure 16 After scanning and obtaining multiple duplicate files (for example, after binary comparison), and before displaying the duplicate file scan results to the user, at time t5, the application queries the value of the U field (V2) of the file. Since the value of the U field obtained at time t5 is different from the value of the U field at time t1, the application can determine that the file has been modified during the period t1-t5. On the contrary, if Figure 17 At time t5, the application queries the value of the U field (V1) of the file. Since the value of the U field queried at time t5 is the same as the value of the U field at time t1, the application can determine that the file has not been modified during the period t1-t5. The mobile phone can display the duplicate files that have not been modified during the period t1-t5 to the user. For example, if English grammar 1, 3, and 4 in the duplicate file have not been modified during the period t1-t5, the mobile phone can Figure 10A The interface shown in (c) displays information about English grammar 1, 3, and 4.

[0322] For example, Figure 18 After the initial screening of duplicate files is complete, at time t1, the application wants to modify the value of the U field of the file "Computer Technology 1" to V1. The application can call the file system's interface to send a request message to the file system. Upon determination, the file has been mmap'd (i.e., mapped to memory) and content has been written to the memory mapped to the file. Therefore, the file system determines that the conditions for modifying the file's U field are not met. Therefore, the file system does not modify the value of the file's U field, and the value of the file's U field remains V0.

[0323] If the value of a file's U field is not successfully set to V1 at time t1, it means that the file may have been modified (no longer a duplicate file) between time t1 and the display of the reconstructed file scan results, but the file system may not be able to detect the modification. In this case, the application will treat the file as modified and no longer a duplicate file. Furthermore, the application will not perform deduplication on the file to avoid mistakenly deduplicating files that are actually non-duplicate files.

[0324] In some embodiments, optionally, after the user clicks Figure 10AAfter pressing the compression button 907 shown in (c), before the mobile phone performs deduplication, the mobile phone manager application sends a deduplication request to the file system, and the file system can check the value of the U field of each duplicate file again to further determine whether each duplicate file has been modified since the first moment. Figure 19 After the user clicks the "Compress" button and before the phone performs deduplication, at time t9, the file system again queries the value of the U field for each duplicate file (English Grammar 1, 3, 4, Computer Technology 1, 2). It determines that the value of the U field for English Grammar 3 was successfully set to V1 at time t1, but the value of the U field is V0 at time t9. Therefore, the phone can determine that English Grammar 3 was modified between times t1 and t9. Similarly, the phone determines whether the other duplicate files were modified between times t1 and t9.

[0325] like Figure 19 Since English grammar 3 was modified between t1 and t9, it is no longer a duplicate file with English grammars 1 and 4. The mobile manager app does not perform deduplication on English grammar 3. Conversely, if English grammars 1 and 4 were not modified between t1 and t9, they are still duplicate files. The mobile manager app can perform deduplication on English grammars 1 and 4 at t10.

[0326] Optionally, after the user clicks the compression button 907, the file system checks the value of the U field of the file to ensure the atomicity of the U field value check and the deduplication operation, that is, the U field value is checked to determine whether the deduplication conditions are met. During the process of executing deduplication, the file will not be modified.

[0327] According to the technical solution of the embodiment of the present application, the application does not need to be resident running. In this way, the system overhead can be reduced while ensuring accurate judgment of the modification status of the file. Taking the above-mentioned deduplication scenario as an example, when it is necessary to clean up the duplicate files in the mobile phone, the user opens the mobile phone manager application and clicks the "clean up and speed up" button to trigger the mobile phone to execute the duplicate file scanning process. Afterwards, the user can close the mobile phone manager application. Subsequently, when the remaining storage space of the mobile phone is insufficient and there are phenomena such as freezing, the user can open the mobile phone manager application again and click the "clean up and speed up" button. The mobile phone can re-determine the duplicate files in the mobile phone based on the historical duplicate file scanning results and the modification status of some duplicate files to reduce the resource consumption caused by rescanning duplicate files.

[0328] For example, Figure 10AIn (c), after the user opens the mobile phone manager application, the mobile phone manager application scans and finds that: English grammar 1-4 is a group of duplicate files, and computer technology 1 and computer technology 2 are a group of duplicate files. The mobile phone can store the file identifiers of the duplicate files of English grammar 2-4 and the file identifiers of the duplicate files of computer technology 1 and computer technology 2 in the following file: Figure 11 The duplicate files shown are in the repository.

[0329] Later, when the storage space of the mobile phone is insufficient, the user opens the mobile phone manager application again and clicks the "clean up and speed up" button 902. The mobile phone manager application can query the storage space of the mobile phone again. Figure 11 In the duplicate file information database shown, the historical duplicate files of English Grammar 1-4 and the historical duplicate files of Computer Technology 2-4 are known, and the U field values ​​of the duplicate files of English Grammar 1-4 and Computer Technology 2-4 are queried to determine whether each duplicate file has been modified within a period of time based on the U field value of each duplicate file.

[0330] After judgment, assuming that English Grammar 1 and 2 are modified, Computer 4 is modified, and English Grammar 3, English Grammar 4, Computer Technology 3, and Computer Technology 2 are not modified. Then, the mobile phone manager application can determine that English Grammar 3 and English Grammar 4 still constitute duplicate files, and Computer Technology 3 and Computer Technology 2 still constitute duplicate files. Figure 14 At time t6, the mobile phone manager application can display the above-mentioned groups of duplicate files in interface 906.

[0331] It can be seen that when the mobile phone manager application is opened again to determine the duplicate files in the mobile phone, the mobile phone can reduce the scanning of some files (for example, there is no need to read the contents of historical duplicate files from the corresponding memory), which greatly reduces the operating consumption of the mobile phone.

[0332] In some embodiments, after the mobile phone manager application re-identifies the duplicate files in the mobile phone, it can update the Figure 11 Duplicate file repository shown.

[0333] The above-mentioned first condition is merely an example. It should be understood that any condition that can ensure that the write operation at time t1-t5 is perceived by the file system can be used as the first condition. Conversely, as long as it cannot be guaranteed that subsequent writes are perceived by the file system, the first condition is not satisfied. For example, as another feasible embodiment, it can be determined whether the file was mmaped before the first moment and whether mmap has write permission. If the file was mmaped before the first moment, but mmap does not have write permission, then the first condition is determined to be satisfied. If the file was mmaped before the first moment, but mmap has write permission, then the first condition is determined to be not satisfied.

[0334] The above description mainly uses the deduplication scenario as an example. It should be understood that the technical solution of the embodiment of the present application can also be applied to other scenarios.

[0335] The above description uses the example of the mobile phone scanning for duplicate files after the user clicks the "Clean Up" button. In other embodiments, the mobile phone can also perform a pre-scan process to scan duplicate files during idle time and store the scan results. In other words, the duplicate file scanning process in the above embodiment can also be a scanning process performed when the mobile phone is idle (such as at night). For example, Figure 12 The primary screening and binary comparison processes shown can be pre-executed overnight.

[0336] For example, the mobile phone can perform a scan for duplicate files at night. Assume that the scan finds English grammars 1-4 as a set of duplicate files, and during the scanning process, at time t1, an attempt is made to modify the value of the U field of English grammars 1-4 to V1. Then, as Figure 10A In (a), when the user clicks the "Clean Up" button 902 during the day, the mobile phone can query the value of the U field of English grammars 1-4. Assuming that the value of the U field of English grammars 1-4 is successfully set to V1 at time t1, and the value of the U field of English grammars 1, 3, and 4 is still V1, the mobile phone determines that English grammars 1, 3, and 4 have not been modified since time t1, and these three files still constitute duplicate files. The mobile phone can Figure 10A The interface shown in (c) shows the information of the three duplicate files.

[0337] By performing a pre-scan when the phone is idle, the time required for subsequent file deduplication can be saved, the efficiency of file deduplication can be improved, and the efficiency of human-computer interaction between users and electronic devices can be improved.

[0338] The embodiments of the present application do not limit the timing of the electronic device performing the duplicate file pre-scan. The electronic device can perform the duplicate file pre-scan process in appropriate scenarios. For example, at night, when the lock screen duration exceeds a threshold, a pre-scan is performed.

[0339] Alternatively, in some embodiments, the electronic device may also provide a setting entry so that the user can set the timing for performing the pre-scan. Figure 20 , a switch 201 is displayed in the settings interface 20 of the mobile phone. When the switch 201 is turned on, the mobile phone can perform a pre-scan when it is idle. In other embodiments, the mobile phone can also provide a settings entry so that the user can set the timing of the pre-scan. For example, the user can set the pre-scan to be performed at night or when the lock screen exceeds a certain threshold.

[0340] The above one or more interfaces are exemplary, and there may be other interface design methods. This application does not limit the specific design method of the interface.

[0341] It should be noted that the above-mentioned multiple embodiments can be combined and the combined scheme can be implemented. Optionally, some operations in the process of each method embodiment are optionally combined, and / or the order of some operations is optionally changed. In addition, the execution order between the steps of each process is only exemplary and does not constitute a limitation on the execution order between the steps. There can also be other execution orders between the steps. It is not intended to indicate that the execution order is the only order in which these operations can be performed. Ordinary technicians in this field will think of many ways to reorder the operations described herein. In addition, it should be pointed out that the process details involved in a certain embodiment of this article are also applicable to other embodiments in a similar manner, or different embodiments can be used in combination.

[0342] Furthermore, some steps in the method embodiments may be equivalently replaced with other possible steps. Alternatively, some steps in the method embodiments may be optional and may be deleted in certain usage scenarios. Alternatively, other possible steps may be added to the method embodiments.

[0343] Furthermore, the above method embodiments may be implemented separately or in combination.

[0344] Optionally, the electronic device may also determine whether V1 is successfully set in other occasions or scenarios. For example, before querying the field value of a file each time, it may determine whether V1 is successfully set.

[0345] Some other embodiments of the present application provide a device, which may be the above-mentioned electronic device (such as a mobile phone, etc.) or a server. The device may include: a display screen, a memory, and one or more processors. The display screen, the memory, and the processor are coupled. The memory is used to store computer program code, and the computer program code includes computer instructions. When the processor executes the computer instructions, the device can execute the various functions or steps performed by the mobile phone in the above-mentioned method embodiment. The structure of the device can refer to Figure 6 The electronic device shown (such as a terminal).

[0346] Among them, the core structure of the device can be expressed as Figure 21 As shown in the structure, the device includes: a processing module 1301 , an input module 1302 , a storage module 1303 and a display module 1304 .

[0347] The processing module 1301 may include at least one of a central processing unit (CPU), an application processor (AP), or a communication processor (CP). The processing module 1301 may perform operations or data processing related to the control and / or communication of at least one of the other components of the user electronic device. Specifically, the processing module 1301 may be used to control the content displayed on the main screen based on certain trigger conditions. The processing module 1301 is also used to process input instructions or data and determine a display style based on the processed data.

[0348] Optionally, the processing module 1301 may be implemented as Figure 6 The processor 201 is shown.

[0349] The input module 1302 is used to obtain user input instructions or data and transmit the obtained instructions or data to other modules of the electronic device. Specifically, the input method of the input module 1302 may include touch, gestures, proximity to the screen, etc., or voice input. For example, the input module can be the screen of the electronic device, obtain the user's input operation and generate an input signal based on the obtained input operation, and transmit the input signal to the processing module 1301.

[0350] The storage module 1303 may include a volatile memory and / or a non-volatile memory. The storage module is used to store at least one related instruction or data of other modules of the user terminal device.

[0351] Optionally, the storage module 1303 may be implemented as Figure 6 Memory 202 is shown.

[0352] The display module 1304 may include, for example, a liquid crystal display (LCD), a light emitting diode (LED) display, an organic light emitting diode (OLED) display, a microelectromechanical system (MEMS) display, or an electronic paper display, and is used to display user-viewable content (e.g., text, images, videos, icons, symbols, etc.).

[0353] Optionally, a communication module 1305 is also included to support the personal terminal communicating with other personal terminals (via a communication network). For example, the communication module can be connected to a network via wireless communication or wired communication to communicate with other personal terminals or a network server. Wireless communication can adopt at least one of cellular communication protocols, such as Long Term Evolution (LTE), Advanced Long Term Evolution (LTE-A), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Universal Mobile Telecommunications System (UMTS), Wireless Broadband (WiBro), or Global System for Mobile Communications (GSM). Wireless communication may include, for example, short-range communication. Short-range communication may include at least one of Wireless Fidelity (Wi-Fi), Bluetooth, Near Field Communication (NFC), Magnetic Stripe Transmission (MST), or GNSS.

[0354] Optionally, the communication module 1305 may be implemented as Figure 6 The transceiver 203 is shown.

[0355] It should be noted that each functional module of the device can execute one or more steps in the above method embodiment.

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

[0357] An embodiment of the present application further provides a computer storage medium, which includes computer instructions. When the computer instructions are executed on the above-mentioned electronic device, the electronic device executes the various functions or steps executed by the mobile phone in the above-mentioned method embodiment.

[0358] The embodiment of the present application further provides a computer program product, which, when executed on a computer, enables the computer to execute the functions or steps executed by the mobile phone in the above method embodiment.

[0359] 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.

[0360] In the several embodiments provided in this 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. For example, 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.

[0361] The units described as separate components may or may not be physically separate, 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 places. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0362] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.

[0363] 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 and includes several instructions for enabling a device (which can be a single-chip microcomputer, chip, etc.) or a processor (processor) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0364] The above content is only a specific embodiment of this application, but the scope of protection of this application is not limited to this. Any changes or replacements within the technical scope disclosed in this application should be included in the scope of protection of this application. Therefore, the scope of protection of this application should be based on the scope of protection of the claims.

Claims

1. A file processing method, characterized in that: Applied to an electronic device, the electronic device stores an indication field of a first file, the initial value of the indication field is a first value, and the indication field is modified by the electronic device to a second value when the first file is modified; the method comprises: At a first moment, attempting to modify a value of an indication field of the first file to a third value; the third value is different from the first value; the third value is different from the second value; If the value of the indication field of the first file is successfully modified to the third value, then at the second moment, obtaining the value of the indication field; According to the value of the indication field of the first file at the second moment, it is determined whether the first file is modified during a period from the first moment to the second moment.

2. The method according to claim 1, characterized in that The indication field is stored in a metadata area of ​​the electronic device.

3. The method according to claim 1 or 2, characterized in that: The attempting to modify the value of the indication field of the first file to a third value comprises: If the first condition is met, the value of the indication field is modified to the third value; under the first condition, the file system of the electronic device can detect the modification operation on the first file during the period from the first moment to the second moment.

4. The method according to any one of claims 1 to 3, characterized in that: After the first moment, the method further includes: detecting that the first file is modified, and modifying the value of the indication field of the first file to the second value; Determining, according to a value of the indication field of the first file at the second moment, whether the first file is modified during a period from the first moment to the second moment includes: If the value of the indication field of the first file at the second moment is the second value, it is determined that the first file is modified during the period from the first moment to the second moment; or, if the value of the indication field of the first file at the second moment is not the third value, it is determined that the first file is modified during the period from the first moment to the second moment.

5. The method according to any one of claims 1 to 3, characterized in that: Determining, according to a value of the indication field of the first file at the second moment, whether the first file is modified during a period from the first moment to the second moment includes: If the value of the indication field of the first file at the second moment is the third value, it is determined that the first file has not been modified during the period from the first moment to the second moment; or, if the value of the indication field of the first file at the second moment is not the second value, it is determined that the first file has not been modified during the period from the first moment to the second moment.

6. The method according to claim 1 or 2, characterized in that: The attempting to modify the value of the indication field of the first file to a third value comprises: if the first condition is not satisfied, not modifying the indication field to the third value; The method further includes: when the value of the indication field of the first file cannot be successfully modified to the third value, determining that the first file is modified within a period from the first moment to the second moment.

7. The method according to claim 3 or 6, characterized in that: The first condition includes one or more of the following conditions: before the first moment, the first file is not mapped to the memory; before the first moment, the first file is mapped to the memory, but the electronic device has not performed a write operation on the memory.

8. The method according to any one of claims 1 to 7, characterized in that: The method further comprises: Scan and obtain duplicate files in the electronic device, the duplicate files including the first file and the second file; the first file is stored in a first storage space, and the second file is stored in a second storage space; Determining that the first file and the second file are not modified during a period from the first moment to the second moment; A first interface is displayed; the first interface includes information about the first file and information about the second file.

9. The method according to claim 8, characterized in that Detecting a first operation input by a user in the first interface; The first file and the second file are compressed into the same storage space.

10. The method according to claim 8 or 9, characterized in that: After scanning the electronic device for duplicate files, the method further includes: The identifier of the first file and the identifier of the second file are stored.

11. The method according to claim 10, characterized in that The identifier of the first file includes a first index node number of the first file; the identifier of the second file includes a second index node number of the second file.

12. The method according to claim 11, characterized in that Determining, according to a value of the indication field of the first file at the second moment, whether the first file is modified during a period from the first moment to the second moment includes: If the value of the indication field of the first file at the second moment is the third value, and the index node number of the first file is the first index node number, it is determined that the first file has not been modified during the period from the first moment to the second moment.

13. A file processing method, characterized in that: Applied to electronic equipment, the method comprises: Displaying a second interface, the second interface including a plurality of duplicate files in the electronic device obtained by scanning; the plurality of duplicate files are respectively stored in a plurality of storage spaces of the electronic device; In response to an operation input by a user on the second interface, at a third moment, obtaining an indication field of each duplicate file in the plurality of duplicate files, wherein a value of the indication field of the duplicate file is used to indicate whether the duplicate file has been modified; According to the values ​​of the indication fields of the multiple duplicate files at the third moment, some duplicate files of the multiple duplicate files are compressed into the same storage space.

14. The method according to claim 13, characterized in that Compressing some of the duplicate files into the same storage space according to the values ​​of the indication fields of the multiple duplicate files at the third moment includes: If the value of the indication field of the first file among the multiple duplicate files is a third value at the third moment, compressing the first file; Alternatively, if the value of the indication field of the first file among the multiple duplicate files is not the third value at the third moment, compression is not performed on the first file.

15. The method according to claim 13 or 14, characterized in that The initial value of the indication field of each duplicate file is the first value.

16. The method according to any one of claims 13 to 15, characterized in that: Before displaying the second interface, the method further includes: Scanning to obtain a plurality of candidate duplicate files; the plurality of candidate duplicate files include the plurality of duplicate files; At a first moment, attempting to modify a value of an indication field of each of the plurality of candidate duplicate files to a third value; The multiple candidate duplicate files are compared to determine the multiple duplicate files from the multiple candidate duplicate files.

17. The method according to claim 16, characterized in that After determining the plurality of duplicate files, the method further includes: The information of the multiple duplicate files is stored in a database, wherein the information of the duplicate files includes any one or more of the following information: an index node number of the duplicate file, a path of the duplicate file, and a name of the duplicate file.

18. The method according to claim 16 or 17, characterized in that The multiple candidate duplicate files are obtained by scanning, including: Displaying a third interface, wherein the third interface includes a first control; An operation of the user on the first control is detected, and the plurality of candidate duplicate files are obtained by scanning.

19. The method according to claim 16 or 17, characterized in that The multiple candidate duplicate files are obtained by scanning, including: When the electronic device is idle, the plurality of candidate duplicate files are obtained by scanning.

20. The method according to any one of claims 16 to 19, characterized in that: Attempting to modify the value of the indication field of each candidate duplicate file in the plurality of candidate duplicate files to a third value comprises: If at least one candidate duplicate file among the multiple candidate duplicate files satisfies the first condition, the value of the indication field of the at least one candidate duplicate file is modified to the third value; under the first condition, the file system of the electronic device can detect the modification operation on the at least one candidate duplicate file within the time period from the first moment to the second moment.

21. The method according to claim 20, characterized in that At the second moment, acquiring a value of the indication field of the at least one duplicate file includes: at the second moment, acquiring a value of the indication field of the target duplicate file in the at least one duplicate file as a third value; The method further includes: determining, when the value of the indication field of the target duplicate file at the second moment is a third value, that the target duplicate file is not modified during a period from the first moment to the second moment.

22. The method according to claim 20, characterized in that The plurality of candidate duplicate files include a third file; After the first moment, the method further includes: detecting that the third file is modified, and modifying the value of the indication field of the third file to a second value; At the second moment, the value of the indication field of the third file obtained is not the third value; It is determined that the third file is modified during a period from the first time to the second time.

23. The method according to any one of claims 16 to 19, characterized in that: The plurality of candidate duplicate files include a fourth file; The step of attempting to modify the value of the indication field of each candidate duplicate file in the plurality of candidate duplicate files to a third value at the first moment includes: if the fourth file does not satisfy the first condition, not modifying the indication field of the fourth file to the third value; The method further includes: when the value of the indication field of the fourth file cannot be successfully modified to the third value, determining that the fourth file is modified within a period from the first moment to the second moment.

24. The method according to any one of claims 20 to 23, characterized in that: The first condition includes one or more of the following conditions: before the first moment, the duplicate file is not mapped to the memory; before the first moment, the duplicate file is mapped to the memory, but the electronic device has not performed a write operation on the memory.

25. The method according to any one of claims 16 to 24, characterized in that: After the first moment, the method further comprises: At a second moment, obtaining a value of the indication field of the at least one duplicate file and an index node number of the at least one duplicate file; When a third condition is met, the second interface is displayed; the third condition includes: the value of the indication field of the at least one duplicate file at the second moment is a third value, and the index node number of the at least one duplicate file is consistent with the index node number stored in the database.

26. The method according to any one of claims 13 to 25, characterized in that: The indication field is stored in a metadata area of ​​the electronic device.

27. An electronic device, characterized in that: include: Processor and memory; The memory is used to store computer-executable instructions, and the processor is coupled to the memory. When the electronic device is running, the processor executes the computer-executable instructions stored in the memory so that the electronic device executes the method as described in any one of claims 1-12, or executes the method as described in any one of claims 13-26.

28. A computer-readable storage medium, wherein instructions are stored in the computer-readable storage medium, characterized in that: When the instruction is executed on an electronic device, the electronic device executes the method as claimed in any one of claims 1 to 12, or executes the method as claimed in any one of claims 13 to 26.