File processing method and electronic equipment
By using indicator fields in the file system of electronic devices to determine the file modification status, the problem of low file management efficiency and high storage space usage is solved, and accurate file management and resource saving are achieved.
Patent Information
- Application Number
- CN202211095247.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-05
- Publication Date
- 2024-09-17
- Estimated Expiration
- 2042-09-05
AI Technical Summary
The file management efficiency in electronic devices is low, resulting in high storage space usage. It is difficult for existing technology to accurately determine whether a file has been modified, resulting in misjudgment and waste of resources.
By introducing the indication field (U field) into the file system, try to modify its value at a specific moment, and query its value at subsequent moments to determine whether the file has been modified, reduce resource consumption and avoid misjudgment.
It achieves accurate judgment of whether a file has been modified without continuously monitoring the file modification status, reduces storage space occupation and resource consumption, and avoids misjudgment and mistaken deduplication.
Smart Images

Figure CN117648288B
Abstract
Description
Technical Field
[0001] The present application relates to the field of terminal technology, and in particular to a file processing method and an electronic device. Background Art
[0002] At present, many electronic devices use the file system in the operating system to manage files. As the number of files stored in electronic devices increases dramatically, the file system has a file management bottleneck. In some scenarios, the files in the electronic device can occupy a large amount of storage space, resulting in a low available storage space of the electronic device. Summary of the invention
[0003] The present application provides a file processing method and an electronic device, which can efficiently manage files.
[0004] In order to achieve the above objectives, the embodiments of the present application provide the following technical solutions:
[0005] In a first aspect, a file processing method is provided, which is applied to an electronic device or a component (such as a chip system) supporting a function of an electronic device, wherein the electronic device stores an indication field of a first file, wherein an initial value of the indication field is a first value, and when the first file is modified, the indication field is modified by the electronic device to a second value; the method comprises:
[0006] At a first moment, an attempt is made 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;
[0007] If the value of the indication field of the first file is successfully modified to the third value, then at the second moment, the value of the indication field is obtained;
[0008] It is determined whether the first file is modified during a period from the first moment to the second moment according to the value of the indication field of the first file at the second moment.
[0009] For example, Fig.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 indication field) of English grammar 3 (an example of the first file) to V1 (an example of the third value), and at time t5 (an example of the second time), queries the value of the U field. The mobile phone can determine whether English grammar 3 has been modified within the period t1-t5 based on the value of the U field of English grammar 3 at time t5.
[0010] In an embodiment of the present application, the modification state of the first file can be determined by the value of the indication field of the first file, and then the first file can be managed accordingly according to the modification state of the first file. Among them, the electronic device does not need to continuously monitor the modification state 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 indication 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 indication field of the first file, and determines whether the first file is modified from the first moment to the second moment according to the value of the indication 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 is modified within a certain period of time, which can reduce the occupancy of storage space.
[0011] 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.
[0012] In a possible design, attempting to modify the value of the indication field of the first file to a third value includes:
[0013] 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.
[0014] In this way, once the file is modified during the period from the first moment to 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 is modified during the period from the first moment to the second moment. Conversely, if the value of the indicator field is still V1, it is determined that the file has not been modified during the period from the first moment to the second moment.
[0015] In one possible design, after the first moment, the method further includes:
[0016] 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.
[0017] Determining, according to a value of an 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:
[0018] 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.
[0019] For example, Fig.12 , after time t1 (an example of the first time), at time t3, it is detected that English grammar 2 is modified (the modification is the first memory write after time t1), and the mobile phone modifies 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 mobile phone queries the value of the U field of English grammar 2 and learns that the value of the U field of English grammar 2 at time t5 is V2 (no longer V1), and it is determined that English grammar 2 is modified within the period t1-t5.
[0020] In a possible design, judging whether the first file is modified during a period from the first moment to the second moment according to a value of the indication field of the first file at the second moment includes:
[0021] 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.
[0022] For example, Fig.13 After the mobile phone manager application scans the duplicate files (such as binary comparison) and before displaying the scan results to the user, at time t5, the mobile phone manager application queries the field value of the U field of the English grammar 3 file and learns that the field value is V1 (an example of the third value). 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 phone manager application can determine that the English grammar 3 file has not been modified from time t1 to time t5.
[0023] 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;
[0024] 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 time period from the first moment to the second moment.
[0025] For example, Fig.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, because the first condition is not met, 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 regards Computer Technology 1 as a modified file (no longer a duplicate file) and no longer performs deduplication on Computer Technology 1 to avoid incorrect deduplication.
[0026] 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.
[0027] For a certain file, if the file is not mapped to the memory before the first moment, once the mobile phone performs one or more memory write operations on the file during the period from the first moment to 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 during the period from the first moment to 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 during the period from the first moment to the second moment, and modify the value of the U field of the file to V2 accordingly. Subsequently, the application can query the value of the U field of the file, and determine whether the file has been modified during the period from the first moment to 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 each 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.
[0028] Similarly, for a certain file, if the file is mapped to the memory before the first moment, but the electronic device has not performed a write operation on the memory, then once 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 definitely cause the mobile phone to execute the relevant code of the file system. That is, once the file is modified between the first moment and the second moment, the modification will definitely be perceived by the file system.
[0029] Based on this principle, if the file is mapped to the memory before the 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, once the file is modified between the first moment and the second moment, the U field value of the file will be modified by the file system to a non-V1 value (such as V2), and the electronic device can determine whether the file has been modified between the first moment and the second moment based on the U field value of the file.
[0030] It can be seen that this solution can reduce the misjudgment of mmap scenarios.
[0031] In one possible design, the method further includes:
[0032] 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;
[0033] Determine that the first file and the second file are not modified during a period from the first moment to the second moment;
[0034] The first interface is displayed; the first interface includes information of the first file and information of the second file.
[0035] For example, English grammars 1-4 are scanned as 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 during the period from the first moment to the second moment, and English grammars 1, 3, and 4 are not modified during the period from the first moment to the second moment, it means that English grammars 1, 3, and 4 still constitute duplicate files. Fig. 10A (c), the mobile phone can display the first interface 906, and the first interface 906 includes information of the set of repeated files of English grammar 1, 3, and 4.
[0036] In one possible design, a first operation input by a user in a first interface is detected;
[0037] The first file and the second file are compressed into the same storage space.
[0038] For example, Fig. 10A In (c), the mobile phone detects the user clicking the compression button 907 (an example of the first operation), and compresses a group of duplicate files (English grammars 1, 3, and 4) selected by the user. The compressed English grammars 1, 3, and 4 point to the same storage space. In this way, the storage space can be released.
[0039] In one possible design, after scanning the electronic device for duplicate files, the method further includes:
[0040] Store the identifier of the first file and the identifier of the second file. For example, Fig.11 In the embodiment of the present invention, the electronic device stores the identification of the duplicate file in a duplicate file information library.
[0041] In a 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.
[0042] In this way, later, when the user opens the mobile phone manager and clicks the "Clean and Speed Up" button, the mobile phone can learn that the first file and the second file are historically duplicate files based on the stored duplicate file identifiers. The mobile phone can query the value of the U field of the first file and the second file to determine whether the first file and the second file still constitute duplicate files. The mobile phone does not need to rescan the contents of the first file and the second file, which helps to reduce the operating consumption of the mobile phone.
[0043] In a possible design, judging whether the first file is modified during a period from the first moment to the second moment according to a value of the indication field of the first file at the second moment includes:
[0044] If the value of the indicator field of the first file at the second time 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 time to the second time.
[0045] 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) supporting a function of an electronic device, and the method includes:
[0046] 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;
[0047] 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 is modified;
[0048] According to the values of the indication fields of the plurality of duplicate files at the third moment, some duplicate files among the plurality of duplicate files are compressed into the same storage space.
[0049] For example, Fig. 10A (c) The mobile phone displays interface 906 (an example of the second interface), and interface 906 includes multiple duplicate files obtained by scanning (a group of duplicate files of English grammar 1, 3, and 4, and a group of duplicate files of computer 2 and 3).
[0050] 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 group of duplicate files of English grammar 1, 3, 4 selected by the user, and compresses some files in English grammar 1, 3, 4 into the same storage space according to the values of the respective indication fields of English grammar 1, 3, 4 at the third moment.
[0051] In this solution, according to the user's operation, the indication field of the duplicate files in the second interface can be obtained, and according to the indication field of each duplicate file, some duplicate files can be compressed. On the one hand, the storage space of the electronic device can be released. On the other hand, it is not to compress all the duplicate files selected by the user, but to verify whether it is really necessary to compress the duplicate files according to the value of the indication field of the duplicate file selected by the user, so as to reduce the probability of erroneous compression, so as to avoid erroneous compression 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 erroneous deduplication caused by other processes modifying the duplicate files before deduplication is performed, and the deduplication program does not perceive that the duplicate files have been modified.
[0052] In one possible design, the initial value of the indication field of each duplicate file is the first value.
[0053] In one possible design, before displaying the second interface, the method further includes:
[0054] Scanning to obtain multiple candidate duplicate files; the multiple candidate duplicate files include multiple duplicate files;
[0055] 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;
[0056] The plurality of candidate duplicate files are compared to determine a plurality of duplicate files from the plurality of candidate duplicate files.
[0057] For example, Fig. 10B After the user clicks the "Clean Up" button, the mobile phone obtains multiple candidate duplicate files after preliminary screening. Among them, 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 mobile phone attempts to modify the value of the indication field of each candidate duplicate file in the multiple candidate duplicate files to V1 (an example of the third value).
[0058] In a possible design, multiple candidate duplicate files are obtained by scanning, including:
[0059] Display a third interface, where the third interface includes the first control;
[0060] An operation of the user on the first control is detected, and a plurality of candidate duplicate files are obtained by scanning.
[0061] For example, Fig. 10A In (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 Fig. 10B English grammar 1-5 shown in the figure), and obtain multiple duplicate files based on multiple candidate duplicate files (such as Fig. 10B English grammar 1-4 shown).
[0062] In a possible design, multiple candidate duplicate files are obtained by scanning, including:
[0063] When the electronic device is idle, multiple candidate duplicate files are scanned, for example, the electronic device performs the scan at night, or performs the scan after the screen is locked for a certain period of time.
[0064] 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.
[0065] In one possible design, after the first moment, the method further includes:
[0066] At a second moment, obtaining a value of an indication field of at least one duplicate file, obtaining a value of an indication field of at least one duplicate file and an index node number of at least one duplicate file;
[0067] 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.
[0068] For example, Fig. 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. 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 Fig. 10A The interface 906 (second interface) shown in (c) displays information of English grammar 1, 3, and 4.
[0069] In a 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:
[0070] If at least one candidate duplicate file among multiple candidate duplicate files satisfies 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.
[0071] 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 at least one duplicate file as a third value;
[0072] 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.
[0073] In one possible design, the plurality of candidate duplicate files include a third file;
[0074] 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;
[0075] At the second moment, the value of the indication field of the third file obtained is not the third value;
[0076] It is determined that the third file is modified during a period from the first time point to the second time point.
[0077] In one possible design, the plurality of candidate duplicate files include a fourth file;
[0078] At a first moment, 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: if the fourth file does not meet the first condition, not modifying the indication field of the fourth file to the third value;
[0079] 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.
[0080] In a possible design, according to the values of the indication fields of the multiple duplicate files at the third moment, compressing some duplicate files among the multiple duplicate files into the same storage space includes:
[0081] If the value of the indication field of the first file among the multiple duplicate files at the third moment is a third value, compressing the first file;
[0082] 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.
[0083] Exemplarily, if the value of the indication 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;
[0084] 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.
[0085] For example, Fig.19 After the user clicks the "Compress" button and before the phone performs deduplication, at time t9 (the third time), the mobile phone manager application again queries the value of the U field of each duplicate file (English Grammar 1, 3, 4, Computer Technology 1, 2). After judgment, the value of the U field of English Grammar 3 was successfully set to V1 at time t1, but the value of the U field at time t9 was V0, so the mobile phone manager application can determine that English Grammar 3 has been modified during the period from time t1 to time t9. Similarly, the mobile phone manager application determines whether other duplicate files have been modified during the period from t1 to t9.
[0086] like Fig.19 , since English grammar 3 has been modified during the period t1-t9, it is no longer a duplicate file with English grammars 1 and 4, and the mobile manager application does not perform deduplication on English grammar 3. On the contrary, during the period t1-t9, English grammars 1 and 4 have not been modified, so English grammars 1 and 4 still constitute duplicate files, and the mobile manager application can perform deduplication on English grammars 1 and 4 at t10.
[0087] In this way, by verifying whether a file is a duplicate file before actual compression and deduplication, the probability of erroneous deduplication can be reduced and the accuracy of deduplication can be improved.
[0088] In one possible design, the method further includes:
[0089] 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.
[0090] In a possible design, when the value of the indication 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:
[0091] 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.
[0092] In a third aspect, a file processing device is provided, which is applied to an electronic device or a chip system. Taking the application to an electronic device as an example, 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 to a second value by the electronic device when the first file is modified; the device includes:
[0093] Processing modules for:
[0094] At a first moment, an attempt is made 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;
[0095] If the value of the indication field of the first file is successfully modified to the third value, then at the second moment, the value of the indication field is obtained;
[0096] It is determined whether the first file is modified during a period from the first moment to the second moment according to the value of the indication field of the first file at the second moment.
[0097] In a possible design, attempting to modify the value of the indication field of the first file to a third value includes:
[0098] 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.
[0099] In a possible design, the processing module is further used to detect, after the first moment, that the first file is modified, and to modify the value of the indication field of the first file to a second value.
[0100] Determining, according to a value of an 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:
[0101] 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.
[0102] In a possible design, judging whether the first file is modified during a period from the first moment to the second moment according to a value of the indication field of the first file at the second moment includes:
[0103] If the value of the indication field of the first file at the second time is the third value, it is determined that the first file has not been modified during the period from the first time to the second time.
[0104] 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;
[0105] 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.
[0106] 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.
[0107] In a possible design, the processing module is further configured to:
[0108] 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;
[0109] Determine that the first file and the second file are not modified during a period from the first moment to the second moment;
[0110] The device also includes a display module, which is used to display a first interface; the first interface includes information of the first file and information of the second file.
[0111] In a 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;
[0112] The processing module is used to compress the first file and the second file into the same storage space according to the first operation detected by the input module.
[0113] In a possible design, the device further includes a storage module. The storage module is used to store the identifier of the first file and the identifier of the second file after scanning the duplicate files in the electronic device.
[0114] In a 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.
[0115] In a possible design, judging whether the first file is modified during a period from the first moment to the second moment according to a value of the indication field of the first file at the second moment includes:
[0116] If the value of the indicator field of the first file at the second time 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 time to the second time.
[0117] In a fourth aspect, a file processing device is provided, which is applied to an electronic device or a chip system, and the device includes:
[0118] A display module, used for displaying 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;
[0119] 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 among the plurality of duplicate files, wherein a value of the indication field of the duplicate file is used to indicate whether the duplicate file is modified;
[0120] The processing module is further used to compress some of the duplicate files in the multiple duplicate files into the same storage space according to the values of the indication fields of the multiple duplicate files at the third moment.
[0121] In one possible design, the initial value of the indication field of each duplicate file is the first value.
[0122] In a possible design, the processing module is further used 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;
[0123] 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.
[0124] In a possible design, multiple candidate duplicate files are obtained by scanning, including:
[0125] Controlling the display module to display a third interface, where the third interface includes a first control;
[0126] An operation of the user on the first control is detected, and a plurality of candidate duplicate files are obtained by scanning.
[0127] In a possible design, multiple candidate duplicate files are obtained by scanning, including:
[0128] When the electronic device is idle, multiple candidate duplicate files are scanned and obtained.
[0129] In one possible design, the processing module is further used to obtain a value of an indication field of at least one duplicate file at a second moment after the first moment;
[0130] 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.
[0131] In a 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:
[0132] If at least one candidate duplicate file among multiple candidate duplicate files satisfies 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.
[0133] 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 at least one duplicate file as a third value;
[0134] The processing module is further configured to determine that the target duplicate file has not been modified during a period from the first moment to the second moment when the value of the indication field of the target duplicate file at the second moment is a third value.
[0135] In one possible design, the plurality of candidate duplicate files include a third file;
[0136] The processing module is also used to:
[0137] 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;
[0138] At the second moment, the value of the indication field of the third file obtained is not the third value;
[0139] It is determined that the third file is modified during a period from the first time point to the second time point.
[0140] In one possible design, the plurality of candidate duplicate files include a fourth file;
[0141] At a first moment, 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: if the fourth file does not meet the first condition, not modifying the indication field of the fourth file to the third value;
[0142] 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.
[0143] In a possible design, according to the values of the indication fields of the multiple duplicate files at the third moment, compressing some duplicate files among the multiple duplicate files into the same storage space includes:
[0144] If the value of the indication field of the first file among the multiple duplicate files at the third moment is a third value, compressing the first file;
[0145] 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.
[0146] 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.
[0147] In a possible design, when the value of the indication 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:
[0148] 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.
[0149] In any possible design of any of the above aspects, the indication field is stored in a metadata area of the electronic device.
[0150] 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.
[0151] 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 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. BRIEF DESCRIPTION OF THE DRAWINGS
[0152] Figure 1A An example diagram of a duplicate file scanning process provided in an embodiment of the present application;
[0153] Figure 1B An example diagram of the i-mtime field provided in an embodiment of the present application;
[0154] Figure 2 A schematic diagram of a write operation of a write interface method provided in an embodiment of the present application;
[0155] Figure 3 A schematic diagram of a write operation of a write memory method provided in an embodiment of the present application;
[0156] Figure 4 , Figure 5 Another schematic diagram of a write operation provided by an embodiment of the present application;
[0157] Figure 6 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application;
[0158] Figure 7 A schematic diagram of the software structure of an electronic device provided in an embodiment of the present application;
[0159] Figure 8 A schematic diagram of a data area and a metadata area provided in an embodiment of the present application;
[0160] Fig. 9 A schematic diagram of a file processing method provided in an embodiment of the present application;
[0161] Fig. 10A A schematic diagram of an interface provided in an embodiment of the present application;
[0162] Fig. 10B , Fig. 10C A schematic diagram of a scenario provided for an embodiment of the present application;
[0163] Fig.11 A schematic diagram of a database provided in an embodiment of the present application;
[0164] Fig.12 A schematic diagram of a scenario in which a file is modified provided in an embodiment of the present application;
[0165] Fig.13 A schematic diagram of a scenario in which a file provided in an embodiment of the present application is not modified;
[0166] Fig.14 A schematic diagram of an interface provided in an embodiment of the present application;
[0167] Fig.15 A schematic diagram of a scenario in which V1 setting fails provided in an embodiment of the present application;
[0168] Fig.16 A schematic diagram of a scenario in which a file is modified provided in an embodiment of the present application;
[0169] Fig.17 A schematic diagram of a scenario in which a file provided in an embodiment of the present application is not modified;
[0170] Fig.18 A schematic diagram of a scenario in which V1 setting fails provided in an embodiment of the present application;
[0171] Fig.19 A schematic diagram of a scenario provided for an embodiment of the present application;
[0172] Fig. 20 A schematic diagram of an interface provided in an embodiment of the present application;
[0173] Fig.21 , Fig. 22 A schematic diagram of the structure of the device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0174] The terms "including" and "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 device comprising a series of steps or units is not limited to the listed steps or units, but may optionally include other steps or units that are not listed, or may optionally include other steps or units that are inherent to these processes, methods, products or devices.
[0175] It should be noted that, in the embodiments of the present application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific way.
[0176] In the description of this application, unless otherwise specified, the meaning of "plurality" refers to two or more. "And / or" in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone.
[0177] To facilitate understanding, the following first introduces relevant terms and concepts that may be involved in the embodiments of the present application.
[0178] 1. File deduplication
[0179] In some scenarios, there are multiple duplicate files in the file system. The multiple duplicate files originally occupied multiple storage spaces. After deduplication, the multiple 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 values of the intercepted contents of the two files are 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.
[0180] In other scenarios, binary comparison can also be replaced by other steps for determining duplicate files, such as hash value comparison, etc. The embodiments of the present application do not limit the specific implementation of the scanning process for duplicate files.
[0181] 2. i-mtime field
[0182] 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.
[0183] 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 generally be stored in the metadata area of the file system. Specifically, the i-mtime field can store the inode area of the metadata area. Exemplarily, 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, and the modification times are 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 can be 2022-8-23 (10:00).
[0184] Table 1
[0185] i-mtime document 2022-8-23(18:00) File 1 2022-8-23(10:00) File 2
[0186] In some schemes, an application in an electronic device can query the i-mtime field of a file to find out whether the file has been modified within a period of time. As a possible implementation method, the application queries the i-mtime field of the file at time point 1 and time point 2 respectively. If the field values of the i-mtime field queried twice are consistent, it means that the file has not been modified from time point 1 to time point 2. Conversely, if the field values of the i-mtime field queried twice are inconsistent, it means that the file has been modified from time point 1 to time point 2.
[0187] For example, Figure 1BIn (a), the application queries the i-mtime field of file 1 at 10:00 and learns that the last modification time of file 1 is 8:00. The application queries the i-mtime field of file 1 again at 12:00 and learns that the last modification time of file 1 is 8:00. In this case, the field values (used to indicate the last modification time of the file) obtained from the two queries are the same, and the application can determine that file 1 has not been modified during the period from 10:00 to 12:00.
[0188] For example, Figure 1B In (b), the application queries the i-mtime field of file 1 at 10:00 and learns that the last modification time of file 1 is 8:00. The application queries the i-mtime field of file 1 again at 12:00 and learns that the last modification time of file 1 is 11:00. In this case, the field values obtained from the two queries are different, and the application can determine that file 1 was modified between 10:00 and 12:00.
[0189] 3. Write interface
[0190] As a way to write a file, an electronic device can perform a file write operation through a write interface. In this way of writing a file, 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 will execute 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 was 10:00. Similarly, when the write interface is called at time t2 (12:00) to modify file 1, the electronic device will execute 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 was 12:00.
[0191] 4. mmap
[0192] As another way to write files, the electronic device can map the file to a certain memory through the mmap interface. Later, when writing files, the file can be written by writing 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 files, 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, later, when writing in the same memory, it is possible that the code in the file system will no longer be executed to avoid falling into the file system and generating additional overhead.
[0193] For example, Figure 3 (a), the electronic device maps file 2 to memory 2. Figure 3 (b), at time t1 (10:00), the electronic device writes to memory 2 for the first time through the mmap interface. At this time, the electronic device executes the relevant code in the file system to write to memory 2. Therefore, the file system can sense that file 2 associated with memory 2 has been modified, and accordingly modify the i-mtime field of file 2 to indicate that the time when file 2 was last modified is 10:00.
[0194] Afterwards, still Figure 3 (b), at time t2, the electronic device performs a write operation on memory 2 through the mmap interface. Since a write operation has been performed on memory 2 in the past, in order to avoid the system overhead caused by frequent falls into the file system, at time t2, the electronic device no longer falls into the file system to perform a write operation on memory 2.
[0195] For example, Figure 4 At time t1, the electronic device maps the file to a certain memory. Afterwards, at time t2 (10:05), the electronic device writes content to the memory, which is equivalent to writing the corresponding content to the file mapped to the memory. Since this is the first write to the memory, the relevant code in the file system will be executed, and the file system can sense that the file has been modified, and modify the i-mtime field of the file to indicate that the time when the file was last modified is 10:05. Afterwards, at time t3 (10:06), an application in the electronic device queries the i-mtime field of the file. At time t4 (10:07), the electronic device writes content to the same memory for the second time, and in order to frequently fall into the file system, the electronic device does not fall into the code in the file system when writing the memory this time. Therefore, the file system cannot sense that the file associated with the memory has been modified, and accordingly does not modify the i-mtime field of the file. 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 time t5 and time 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., during 10:05-10:07).
[0196] 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.
[0197] 5. Modifying the system time leads to misjudgment of file modification status
[0198] 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. Later, 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. Later, at time t4 (the system time is modified to 10:00), 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., during 10:05-12:00).
[0199] Here, the system time can be modified by the user or automatically by the system.
[0200] 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.
[0201] 6. inotify
[0202] In some solutions, you can also use the inotify mechanism to monitor whether a file has been modified. The application can use the inotify interface to notify the file system that it needs to monitor the modification status of the file. Later, when the file system monitors the event that the file has been modified, it will notify the application that the file has been modified. This method requires the application to run resident during the period of monitoring, which occupies more system resources (such as memory resources) and has a high overhead for electronic devices.
[0203] It can be seen that the above-mentioned solutions for determining whether a file has been modified cannot enable the electronic device to obtain better performance. To solve the above-mentioned technical problems, the present application embodiment provides a file processing method. The method can be applied to electronic devices. For example, the electronic device in the present application embodiment can Figure 6 This is achieved by using electronic devices in the system. Figure 6 The electronic device 200 includes at least one processor 201 , a memory 202 and at least one transceiver 203 .
[0204] 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.
[0205] The above components may include communication lines for transmitting information between the above components.
[0206] Transceiver 203, used to communicate with other devices. In the embodiment of the present application, the transceiver can be a module, circuit, bus, interface or other device capable of realizing communication function, used to communicate with other devices. Optionally, the transceiver can be an independently arranged transmitter, which can be used to send information to other devices, and the transceiver can also be an independently arranged receiver, which is used to receive information from other devices. The transceiver can also be a component that integrates the functions of sending and receiving information, and the embodiment of the present application does not limit the specific implementation of the transceiver.
[0207] The memory 202 may be a read-only memory (ROM) or other types of static storage devices that can store static information and instructions, a random access memory (RAM) or other types of dynamic storage devices 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, optical disc storage (including compressed optical 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 the 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 through a communication line. The memory may also be integrated with the processor.
[0208] 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.
[0209] Optionally, the computer-executable instructions in the embodiments of the present application may also be referred to as application code, instructions, computer program or other names, which are not specifically limited in the embodiments of the present application.
[0210] In a specific implementation, as an embodiment, the processor 201 may include one or more CPUs.
[0211] 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 here may refer to one or more devices, circuits, and / or processing cores for processing data (e.g., computer program instructions).
[0212] like Figure 6 It should be understood that the electronic device shown in the figure is only an example, and in actual applications, the electronic device may have more Figure 6 More or fewer components may be shown, two or more components may be combined, or there may be a different configuration of components.
[0213] The software system of the electronic device may 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 may be System, etc. The embodiment of the present invention takes the Android system of layered architecture as an example to exemplify the software structure of the electronic device.
[0214] Figure 7 It is a software structure block diagram of the electronic device according to an embodiment of the present invention.
[0215] The layered architecture divides the software into several layers, each with clear roles and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the 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 library, the hardware abstraction layer (HAL), and the kernel layer.
[0216] (1) Application layer
[0217] 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.
[0218] In the embodiment of the present application, the application program may also include settings, mobile phone housekeeper and other applications. Taking the mobile phone housekeeper application as an example, the mobile phone housekeeper application may 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 housekeeper application may determine whether the corresponding file has been modified within a period of time according to the field value of the U field.
[0219] Optionally, the application may determine the value of the U field in at least one of the following ways.
[0220] The first method: the application may call the first interface provided by the file system, and the first interface returns the U field value of the file.
[0221] 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 to execute the remaining steps of the second interface based on the U field value.
[0222] Optionally, the above application may be an application running in user mode.
[0223] Applications running in "user mode" can be called "user mode programs". For example, applications such as Changlian Communication and Smart Life are all user mode programs. In some cases, user mode programs need to use some functions provided by the operating system (such as reading file contents). At this time, the user mode program will call the application programming interface (API) provided by the operating system, fall from user mode to kernel mode to execute functions provided by the operating system kernel.
[0224] (2) Framework layer
[0225] The framework layer provides API and programming framework for the application programs in the application layer. The framework layer includes some predefined functions.
[0226] 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.
[0227] Among them, the activity manager is responsible for starting all APP processes, starting the four major components of APP (such as activity, service, broadcast receiver, content provider), switching between APPs and between APP internal interfaces, and the life cycle of various components. The window manager is used to manage window programs. The window manager can obtain the size of the display screen, determine whether there is a status bar, lock the screen, capture the screen, etc. The content provider is used to store and obtain data and make the data accessible to the application. The data may include video, images, audio, dialed and received calls, browsing history and bookmarks, phone books, etc. The view system includes visual controls, such as controls for displaying text, controls for displaying pictures, etc. The view system can be used to build applications. The display interface can be composed of one or more views. For example, a display interface including a text notification icon can include a view for displaying text and a view for displaying pictures. The phone manager is used to provide communication functions for electronic devices. For example, the management of call status (including connected, hung up, etc.). The resource manager provides various resources for the application, such as localized strings, icons, pictures, layout files, video files, etc. The notification manager enables applications to display notification information in the status bar. It can be used to convey notification-type messages and can disappear automatically after a short stay without user interaction. For example, the notification manager is used to notify download completion, message reminders, etc. The notification manager can also be a notification that appears in the system top status bar in the form of a chart or scroll bar text, such as notifications of applications running in the background, or a notification that appears on the screen in the form of a dialog window. For example, a text message is displayed in the status bar, a prompt sound is emitted, an electronic device vibrates, an indicator light flashes, etc.
[0228] 3. Android Runtime and System Libraries
[0229] like Figure 7 As shown, Android Runtime is responsible for the scheduling and management of the Android system.
[0230] The system library may 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.
[0231] Among them, the surface manager is used to manage the display subsystem and provide fusion of 2D and 3D layers for multiple applications. The media library supports playback and recording of multiple commonly used audio and video formats, as well as static image files. The media library can support multiple audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc. The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, synthesis, and layer processing. The 2D graphics engine is a drawing engine for 2D drawing.
[0232] (4) Kernel layer
[0233] The kernel layer is the layer between hardware and software.
[0234] In the embodiment of the present application, the kernel layer may include a file system. The file system is a core module of the operating system kernel, that is, one of the main components. The file system is responsible for managing and storing file information, mainly creating files for users, storing, reading, modifying, and dumping files, controlling file access, and revoking files when users no longer use them.
[0235] In some embodiments, the file system may run in kernel mode.
[0236] Applications running in "user mode" can be called "user mode programs". For example, applications such as Changlian Communication and Smart Life are all user mode programs. In some cases, user mode programs need to use some functions provided by the operating system (such as reading file contents). At this time, the user mode program will call the application programming interface (API) provided by the operating system, fall from user mode to kernel mode to execute functions provided by the operating system kernel.
[0237] The data in the file system may include metadata and data. Metadata is used to describe the characteristics and attributes of the file. Optionally, metadata includes but is not limited to the following information: file system control information, data structure, file description information, such as file length, file type, etc. File types include, for example, regular files (regular inode), directory files (directory inode), soft links (symbol link inode), special files (special inode), etc.
[0238] 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.
[0239] The data of a file may be stored in a data area of a storage device. Optionally, the data stored in the data area may be data obtained after file-level compression processing based on lossless compression technology. The data in the data area is stored in a physical storage space of a storage medium (e.g., a disk, a flash memory, etc.) as a set of disk blocks. The data of the same file may be stored in continuous disk blocks, or may be cross-stored in discontinuous disk blocks.
[0240] It should be understood that the introduction of the concept of disk block in the present application does not mean that the storage medium is limited to a disk, and the disk block can be used to represent a small physical storage space obtained by dividing the physical storage space of the storage medium.
[0241] 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 may 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 may 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 according to the index.
[0242] In some embodiments, the file system can provide an interface for reading and writing files for the user state program. As a first possible implementation, the file system provides a read and write interface (eg, read, write), and the user state program calls the read and write interface to read and write files.
[0243] As a second possible implementation method, the file system provides a memory mapping interface (e.g., mmap), and the user-mode program calls the memory mapping interface to map the file to the memory and obtain the mapped memory address. After that, the user-mode program can access the file through memory access, for example, write to the file by writing to the memory.
[0244] 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.
[0245] For the second file access method mentioned above, the first file access after the mapping is established (such as the first memory write) will cause a memory page fault, and the file system function will be called at this time, so the file system knows that the user-mode program has accessed the file. Subsequent accesses (such as subsequent memory writes) may not necessarily cause a memory page fault, so the file system may not be able to perceive that the user-mode program has modified the file.
[0246] In the present application embodiment, Figure 8 As shown, the file system can add an unmodified field (referred to as U field) in the metadata area, and the U field can indicate whether the corresponding file has been modified. Each file has a corresponding U field.
[0247] Optionally, the file system can set the initial value of the U field. For example, the initial value is set to V0.
[0248] 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.
[0249] 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. As follows, the file deduplication scenario is first described as an example.
[0250] Embodiment 1
[0251] like Fig. 9 The technical solution of the embodiment of the present application may include the following steps:
[0252] S101. The file system sets the value of the U field of the first file to V0.
[0253] Optionally, the U field may be stored in the metadata area of the file system.
[0254] 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.
[0255] For example, Fig. 10A As shown in (a), the mobile phone displays an interface 901 of the mobile phone manager application, and the interface 901 may include a "clean up and speed up" button 902. After detecting that the user clicks the "clean up and speed up" button 902, the mobile phone may scan the data to be cleaned stored in the mobile phone. The data to be cleaned may include multiple duplicate files, that is, multiple files with exactly the same content.
[0256] In some embodiments, during the process of the mobile phone manager application scanning multiple duplicate files, 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.
[0257] For example, Fig.12At time t6, after the user clicks the "Clean Up" button, the mobile phone can perform an initial screening of duplicate files. After the initial 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 Up" button, and after the mobile phone performs an initial screening of duplicate files, at time t1 (the first moment), the mobile phone housekeeper application calls the file system interface and attempts to modify the field value of the U field corresponding to English grammar 2 from V0 to V1. Fig.12 In the example, since the mobile phone has not executed mmap for English grammar 2 before time t1, 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.
[0258] Similarly, the mobile phone 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.
[0259] 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, where the request message is used to request to modify the initial value of the U field of the first file to V1.
[0260] Optionally, V1 can be specified by the application or by the file system.
[0261] In some embodiments, after receiving the request message from the application, the file system determines whether the first condition for modifying the value of the U field of the file is met. When the first condition is met, the file system can modify the value of the U field of the first file to V1. On the contrary, when the first condition is not met, the file system does not modify the value of the U field of the first file to V1.
[0262] Optionally, the first condition includes: whether the file has been mapped to memory (for example, the application has mapped the file using mmap()).
[0263] For example, Fig.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 change the field value of the U field of Computer Technology 1 from V0 to V1.
[0264] Fig. 10BSome of the candidate duplicate files obtained by the initial screening are shown. After the initial 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 a group of candidate duplicate files. At time t1, the mobile phone manager application can call the interface of the file system to try to modify the value of the U field of each candidate duplicate file to V1. For example, Table 2 shows the field value of the U field of each candidate duplicate file after time t1.
[0265] Table 2
[0266]
[0267]
[0268] As shown in Table 2, the field value of the U field of Computer Technology 1 is still the initial value V0. One possible reason is that before time t1, the mobile phone has mapped the file Computer Technology 1 to the memory. The field values of the U fields of other files, such as English Grammar 1-4 and Computer Technology 2, are all modified to V1 by the mobile phone manager application, indicating that before time t1, the mobile phone has not mapped these files to the memory.
[0269] Optionally, when the first condition is met, the file system returns a message indicating successful setting 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, Fig.12 , assuming that before time t1, the mobile phone has not performed a memory write operation on English grammar 2. At time t3, in response to the user's intention to modify English grammar 2, the mobile phone performs the first memory write operation on English grammar 2. Specifically, the mobile phone will definitely execute the relevant code in the file system when performing the first memory write operation on English grammar 2. In this way, at time t3, the file system can sense that English grammar 2 has been modified, 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. Fig.12 , the file system can store t3 in the metadata area. Later, 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 following steps S106-S110 are executed. If the value of the U field of the first file is not set to V1, step S111 is executed.
[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 the application successfully sets the value of the U field of a duplicate file to V1, which 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 also execute the relevant code of the file system each time it writes, and the file system can still sense that the file has been modified and modify the value of the U field of the file (V2). Conversely, if the phone does not modify the file subsequently, the value of the U field of the file remains V1. The phone can determine that the file has not been modified based on the value of the U field of the file (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 is actually modified based on whether the value of the U field 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, and the file system cannot track the modification events of the file, and it is also impossible to update the value of the U field of the file when the file is modified. For example, when a 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 the application fails to successfully set the value of the U field of a certain 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 time, 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, in order 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 result in failure 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 program 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, Fig. 10BAt time t6, the user clicks the "Clean Up" 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 housekeeper application attempts to set the value of the U field of each candidate duplicate file to V1. Assuming that at time t1, the values of the U fields of English Grammar 1-4 and Computer Technology 2-4 are successfully set to V1, the mobile phone housekeeper 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 may store information about duplicate files in a duplicate file information library. Optionally, the duplicate file information library may store identifiers of duplicate files. Fig.11 , the duplicate file information library may include the identification of each duplicate file in the group of duplicate files of English grammar 1-4, and the identification of each duplicate file in the group of duplicate files of computer technology 2-4. Optionally, the identification of duplicate files includes but is not limited to: the name of the duplicate file, the inode number (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. Among them, the inode number of the 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 and 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 queries the value of the U field of the file itself. Alternatively, the application sends a query request to the file system, and the file system 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. Fig.12After the initial screening is completed, at time t1, the value of the U field of English grammar 2, which is initially identified as a duplicate file (candidate duplicate file), is successfully set to V1. Afterwards, the mobile manager performs a binary comparison on each candidate duplicate file, and finally determines that English grammars 1-4 constitute a group of duplicate files, and computer calculations 2-4 constitute a group of duplicate files. After scanning each duplicate file, before displaying the scan results of the duplicate files to the user, at time t5, the mobile manager application can query the value of the U field of English grammar 2, and determine whether English grammar 2 has been modified during the period t1-t5 based on the value of the U field at time 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 following step S107 is executed. If the value of the U field is not V1, the following step S108 is executed.
[0292] S107: The application determines that the first file has not been modified.
[0293] For example, Fig.13 After the mobile phone manager application scans the duplicate files (binary comparison) and before displaying the scan results to the user, at time t5, the mobile phone manager application queries the field 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 phone manager application can determine that the file English Grammar 3 has not been modified from time t1 (at time t1, the mobile phone manager application calls the interface of the file system and tries to change the field value of the U field of English Grammar 3 from V0 to V1) to time t5.
[0294] Similarly, the mobile phone manager application can query the field value of the U field of English grammar 1, 3, and 4. If the U field value of English grammar 1, 3, and 4 is V1, it means that the file system has not detected that English grammar 1, 3, and 4 have been modified. Then, the mobile phone manager application can determine that during the period from time t1 to time t5, the three files English grammar 1, 3, and 4 have not been modified. Therefore, English grammar 1, 3, and 4 still constitute duplicate files. Subsequently, the mobile phone manager application can deduplicate this group of duplicate files to reduce the storage space occupied.
[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, Fig.12 , after the mobile phone housekeeper application performs binary comparison and obtains the scan results of the duplicate files, before displaying the scan results to the user, at time t5, the mobile phone housekeeper 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 housekeeper application can determine that the file English Grammar 2 may have been modified between time t1 (at time t1, the mobile phone housekeeper 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 housekeeper application will not perform deduplication on English Grammar 2 subsequently.
[0298] Optionally, the metadata area may also 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 scheme shown, the file system misses the second memory write operation, and cannot update the i-mtime field in time, causing the electronic device to mistakenly believe that the file has not been modified in the t3-t5 period. In contrast, the technical solution of the embodiment of the present application is adopted. For a certain file, if the file is not mapped to the memory before the first moment, once the subsequent mobile phone performs one or more memory write operations on the file during the period from the first moment to 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 during the period from the first moment to 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 during the period from the first moment to the second moment. It can be seen that in the embodiment of the present application, the file system does not need to detect each 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.
[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 is not successfully set to V1, which means that during the period from the first moment to the second moment, the first file may be modified (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 regards the first file as a modified file, and the first file is no longer a duplicate file. In addition, the application does not perform deduplication processing on the first file to avoid mistakenly deduplicating the first file, which is actually a non-duplicate file.
[0302] For example, Fig.15 , assuming that before time t1, the mobile phone has performed an overwrite memory 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 performing erroneous 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. Fig. 10B , during the period t1-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 Fig. 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. Fig. 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, 4 and the duplicate files of computer calculation 2, 3), and the duplicate files occupy a total of 229MB 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 Fig. 10A Interface 906 shown in (c) of FIG. Interface 906 can present detailed information of the above 8 groups of duplicate files. For example, Fig. 10AIn (c), the information of the first group of duplicate files "English Grammar 1, English Grammar 3, English Grammar 4" is presented in interface 906. The information of the second group of duplicate files "Computer Technology 2, Computer Technology 3" is also presented in interface 906. In response to the user's operation such as sliding up, interface 906 can also present information of other duplicate files. Multiple files in each group of duplicate files occupy multiple storage spaces respectively. 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. Fig. 10A In (c), if the user selects the English grammar group of duplicate files, the mobile phone can remove duplicates from the English grammar 1, 3, and 4 files according to the user's compression intention. Fig. 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 performing deduplication, the electronic device can still display the group of files of English grammar 1, 3, and 4 in the user interface, and the user can still open and use any file in the group of files normally. Compared with before deduplication, after deduplication, the storage space occupied by English grammar 1, 3, and 4 is reduced.
[0308] After performing the deduplication process 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 in the embodiments of the present 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. Thereafter, 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 mistaken deduplication of file 2, which is actually a non-duplicate file.
[0313] It should be noted that the above V2 may also be replaced by other values other than V1 (eg, 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 takes the application as a 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, etc. 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 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 duplicate files and performing deduplication as an example, illustratively, 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 that files A and B are 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, 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 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 that files A and B are duplicate files. At time point 3, the application queries the values of the U fields of files A and B and learns that the values of the U fields of files A and B are V1, which means that since time point 1, files A and B have not been modified and files A and B still constitute duplicate files. Therefore, the application can perform deduplication on files A and B.
[0317] Embodiment 2
[0318] The embodiment of the present application also provides a file processing method, in which the file has been mapped to the memory, and can also include the following two situations: the file has been mapped to the memory, but the electronic device has not written to the memory mapped by the file; the file has been mapped to the memory, and the electronic device has written to the memory mapped by the file. In the above two situations, the electronic device can use different methods to determine whether the file has been modified. As follows, it is explained with examples.
[0319] For example, Fig.16 After the candidate duplicate files are initially screened, at time t1, the application wants to modify the value of the U field of the file English Grammar 2 to V1. The application can call the file system interface to send a request message to the file system. After judging, the file has been mmap (i.e., mapped to memory) before, but no content has been written to the memory mapped by the file. Then, the file system determines that the conditions for modifying the U field of the file are met, and then the value of the U field of the file can be modified from the initial value V0 to V1. After that, the application can perform a binary comparison between English Grammar 3 and other candidate duplicate files to determine the final duplicate file.
[0320] Afterwards, at time t3, the electronic device writes to the memory mapped by 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. Fig.16 After the file system senses the write operation on the file, it can change the value of the U field of the file from V1 to V2.
[0321] Afterwards, if Fig.16 After scanning and obtaining multiple duplicate files (for example, after binary comparison), before displaying the scan results of the duplicate files to the user, at time t5, the application queries the value of the U field of the file (V2). 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. Fig.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 the English grammars 1, 3, and 4 in the duplicate files have not been modified during the period t1-t5, the mobile phone can Fig. 10A The interface shown in (c) displays information about English grammar 1, 3, and 4.
[0322] For example, Fig.18 After the initial screening of duplicate files is completed, at time t1, the application wants to modify the value of the U field of the file Computer Technology 1 to V1, then the application can call the file system interface to send a request message to the file system. After judging that the file has been mmap (i.e. mapped to memory) and the content has been written to the memory mapped by the file, then the file system determines that the conditions for modifying the U field of the file are not met, so the file system does not modify the value of the U field of the file, and the value of the U field of the file remains V0.
[0323] When the value of the U field of a file is not successfully set to V1 at time t1, it means that the file may have been modified (no longer a duplicate file) during the period from time t1 to the display of the reconstructed file scan results, but the file system may not be able to detect that the file has been modified. In this case, the application regards the file as a modified file and the file is no longer a duplicate file. In addition, the application does not perform deduplication processing on the file to avoid mistakenly deduplicating a file that is actually a non-duplicate file.
[0324] In some embodiments, optionally, after the user clicks on Fig. 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. Fig.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 of each duplicate file (English Grammar 1, 3, 4, Computer Technology 1, 2). After judgment, the value of the U field of English Grammar 3 was successfully set to V1 at time t1, but the value of the U field at time t9 was V0, so the phone can determine that English Grammar 3 was modified during the period from time t1 to time t9. Similarly, the phone determines whether other duplicate files have been modified during time t1-t9.
[0325] like Fig.19 , since English grammar 3 has been modified during the period t1-t9, it is no longer a duplicate file with English grammars 1 and 4, and the mobile manager application does not perform deduplication on English grammar 3. On the contrary, during the period t1-t9, English grammars 1 and 4 have not been modified, so English grammars 1 and 4 still constitute duplicate files, and the mobile manager application 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 checking the U field value and the deduplication operation, that is, from checking the U field value to determining that the deduplication conditions are met to executing the deduplication operation, 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 run resident. 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 housekeeper application and clicks the "Clean and Speed Up" button to trigger the mobile phone to execute the duplicate file scanning process. After that, the user can close the mobile phone housekeeper application. Later, 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 housekeeper application again and click the "Clean 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, Fig. 10A(c), after the user opens the mobile phone housekeeper application, the mobile phone housekeeper application scans and obtains: 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 manner: Fig.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. Fig.11 In the duplicate file information library shown, the historical duplicate files of English Grammar 1-4 and the historical duplicate files of Computer Technology 2-4 are obtained, and the U field values of the duplicate files English Grammar 1-4 and Computer Technology 2-4 are queried, so as 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 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. Fig.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 and the duplicate files in the mobile phone are determined, 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 Fig.11 Duplicate file repository shown.
[0333] The above first condition is only 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. Otherwise, as long as the subsequent write cannot be guaranteed to be perceived by the file system, the first condition is not satisfied. Exemplarily, as another feasible embodiment, it can be determined whether the file is mmap before the first moment and whether mmap has write permission. If the file is mmap before the first moment, but mmap does not have write permission, it is determined that the first condition is satisfied. If the file is mmap before the first moment, but mmap has write permission, it is determined that the first condition is 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 performing a duplicate file scan after the user clicks the "Clean Up Speed" button. In other embodiments, the mobile phone can also perform a pre-scan process, perform a duplicate file scan during an idle period, and store the scan results. In other words, the duplicate file scan process in the above embodiment can also be a scan process performed when the mobile phone is idle (such as at night). For example, Fig.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 results in English grammars 1-4 being a set of duplicate files, and during the scanning process, at time t1, an attempt can be made to modify the value of the U field of English grammars 1-4 to V1. Then, as Fig. 10A (a), the user clicks the "Clean Up" button 902 during the day, and the mobile phone can query the value of the U field of English grammars 1-4. Assuming that the values of the U fields of English grammars 1-4 are all successfully set to V1 at time t1, and the values of the U fields of English grammars 1, 3, and 4 are 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 Fig. 10A The interface shown in (c) shows the information of these 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 embodiment of the present application does not limit the timing of the electronic device performing the pre-scan of duplicate files. The electronic device can perform the pre-scan process of duplicate files in appropriate scenarios. For example, at night, the pre-scan is performed when the lock screen duration exceeds a threshold.
[0339] Alternatively, in some embodiments, the electronic device may also provide a setting entry so that the user can set the timing of performing the pre-scan. Fig. 20 , a switch 201 is displayed in the setting 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 setting 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. A person of ordinary skill in the art will think of a variety of ways to reorder the operations described herein. In addition, it should be noted 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] In addition, some steps in the method embodiment may be equivalently replaced by other possible steps. Alternatively, some steps in the method embodiment may be optional and may be deleted in certain usage scenarios. Alternatively, other possible steps may be added to the method embodiment.
[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 and scenarios. For example, before querying the field value of the file each time, it determines 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 executed by the mobile phone in the above-mentioned method embodiment. The structure of the device can refer to Figure 6 The electronic device (such as a terminal) is shown.
[0346] The core structure of the device can be expressed as Fig.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 elements of the user electronic device. Specifically, the processing module 1301 may be used to control the content displayed on the main screen according to certain trigger conditions. The processing module 1301 is also used to process the input instructions or data and determine the display style according to 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 the instructions or data input by the user and transmit the obtained instructions or data to other modules of the electronic device. Specifically, the input mode of the input module 1302 may include touch, gesture, approaching the screen, etc., or voice input. For example, the input module may be the screen of the electronic device, obtain the user's input operation and generate an input signal according to 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 instruction or data related to 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 micro-electromechanical system (MEMS) display, or an electronic paper display, and is used to display content (e.g., text, images, videos, icons, symbols, etc.) that can be viewed by a user.
[0353] Optionally, a communication module 1305 is also included to support the personal terminal (through the communication network) to communicate with other personal terminals. For example, the communication module can be connected to the network via wireless communication or wired communication to communicate with other personal terminals or network servers. 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 mobile communication system (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, such as Fig. 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 a memory of an electronic device). For another example, the interface circuit 1402 can be used to send signals to other devices (such as 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 are not specifically limited in the embodiments of the present application.
[0357] An embodiment of the present application also 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 each function or step executed by the mobile phone in the above-mentioned method embodiment.
[0358] The embodiment of the present application also provides a computer program product. When the computer program product is run on a computer, the computer is enabled to execute each function or step executed by the mobile phone in the above method embodiment.
[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 the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0361] The units described as separate components may or may not be physically separated, and the components shown as units may be one physical unit or multiple physical units, that is, they may be located in one place or distributed in multiple different places. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0362] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[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, including several instructions to enable a device (which can be a single-chip microcomputer, chip, etc.) or a processor (processor) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read only memory (ROM), random access memory (RAM), disk or optical disk and other media that can store program code.
[0364] The above contents are only specific implementation methods of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions within the technical scope disclosed in the present application shall be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.
Claims
1. A file processing method, characterized in that: Applied to 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, calling an interface of the file system to modify the value of the 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; the file system interface is used to modify the value of the indication field of the first file; 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 step of modifying the value of the indication field of the first file to a third value includes: 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: Also includes: If the first condition is not met, the indication field is not modified to the third value; When the value of the indication field of the first file cannot be successfully modified to the third value, it is determined 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, calling an interface of the file system to modify the value of the indication field of each candidate duplicate file in the plurality of candidate duplicate files to a third value; the interface of the file system is used to modify the value of the indication field of the candidate duplicate file; 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: Modifying 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; and further include: At the first moment, if the fourth file does not meet the first condition, the indication field of the fourth file is not modified to the third value; When the value of the indication field of the fourth file cannot be successfully modified to the third value, it is determined 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 an indication field of 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.
29. A computer program product, characterized in that The computer program product comprises a program or an instruction. When the computer program product is run on a computer, the computer is caused to execute the method according to any one of claims 1 to 12, or execute the method according to any one of claims 13 to 26.
30. A file processing device, characterized in that: The device includes a processor, configured to support the device to implement the method as described in any one of claims 1-12; or, configured to support the device to implement the method as described in any one of claims 13-26.
Citation Information
Cited By
File processing method and electronic device
EP4528529A1
File processing method and electronic device
WO2024051654A1
