WO2024051654A1 - 文件处理方法及电子设备 - Google Patents

文件处理方法及电子设备 Download PDF

Info

Publication number
WO2024051654A1
WO2024051654A1 PCT/CN2023/116818 CN2023116818W WO2024051654A1 WO 2024051654 A1 WO2024051654 A1 WO 2024051654A1 CN 2023116818 W CN2023116818 W CN 2023116818W WO 2024051654 A1 WO2024051654 A1 WO 2024051654A1
Authority
WO
WIPO (PCT)
Prior art keywords
file
value
time
duplicate
moment
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Ceased
Application number
PCT/CN2023/116818
Other languages
English (en)
French (fr)
Inventor
覃鸿巍
裘杰
钱璟
姜俊超
汪坷
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Huawei Technologies Co Ltd
Original Assignee
Huawei Technologies Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Huawei Technologies Co Ltd filed Critical Huawei Technologies Co Ltd
Priority to CN202380064000.5A priority Critical patent/CN119836627A/zh
Priority to EP23862348.2A priority patent/EP4528529A4/en
Publication of WO2024051654A1 publication Critical patent/WO2024051654A1/zh
Priority to US19/069,237 priority patent/US20250321934A1/en
Anticipated expiration legal-status Critical
Ceased legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/11File system administration, e.g. details of archiving or snapshots
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/16File or folder operations, e.g. details of user interfaces specifically adapted to file systems
    • G06F16/164File meta data generation
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/17Details of further file system functions
    • G06F16/174Redundancy elimination performed by the file system
    • G06F16/1744Redundancy elimination performed by the file system using compression, e.g. sparse files
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/16File or folder operations, e.g. details of user interfaces specifically adapted to file systems
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/17Details of further file system functions
    • G06F16/1734Details of monitoring file system events, e.g. by the use of hooks, filter drivers, logs
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/17Details of further file system functions
    • G06F16/1737Details of further file system functions for reducing power consumption or coping with limited storage space, e.g. in mobile devices

Definitions

  • This application relates to the field of terminal technology, and in particular to file processing methods and electronic devices.
  • This application provides document processing methods and electronic equipment to efficiently manage documents.
  • a file processing method is provided, which is applied to electronic equipment or components (such as chip systems) that support the functions of electronic equipment.
  • the electronic equipment stores an indication field of the first file, and the initial value of the indication field is the first value, indicating that The field is modified by the electronic device to the second value when the first file is modified; the method includes:
  • the value of the indication field of the first file at the second time it is determined whether the first file has been modified during the period from the first time to the second 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), query the value of the U field.
  • the mobile phone can determine whether English Grammar 3 has been modified during the period t1-t5 based on the value of the U field of English Grammar 3 at time t5.
  • the modification status of the first file can be determined based on the value of the indication field of the first file, and then the first file can be managed accordingly based on the modification status of the first file.
  • the electronic device does not need to continue to monitor the modification status of the first file from the first moment to the second moment, but can stop monitoring at other times other than the first moment and the second moment, so as to reduce the time required for the electronic device to monitor. LF.
  • the electronic device may try to modify the value of the indication field of the first file to V1 through the first application. After the first moment, the electronic device may exit the first application.
  • 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 has been modified between the first moment and the second moment based on the value of the indication field. It can be seen that in the embodiment of the present application, when the first application does not need to be resident, the electronic device can also determine whether the first file has been modified within a certain period of time, which can reduce the occupation of storage space.
  • try to modify the value of the indicated field of the first file to a third value including:
  • 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 of the first file within the period from the first moment to the second moment. operate.
  • the file system can ensure that it senses the modification and modifies the value of the indication field of the file to a non-V1 value (such as the second value V2). Subsequently, the electronic device can query the value of the indication field of the file. If the value of the indication field is modified to a value other than V1, the electronic device determines that the file was modified between the first moment and the second moment. On the contrary, if the value of the indication field The value is still V1, then it is determined that the file has not been modified from the first moment to the second moment.
  • a non-V1 value such as the second value V2
  • the method after the first moment, the method also includes:
  • the value of the indication field of the first file at the second time is the second value, it is determined that the first file was modified during the period from the first time to the second time, or if the indication field of the first file is at the second time.
  • the value at time is not the third value, then it is determined that the time from the first time to the Within the period of time 2, the first file is modified.
  • judging whether the first file has been modified during the period from the first moment to the second moment is based on the value of the indication field of the first file at the second moment, including:
  • 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, or if the indication field of the first file is at the third time. If the value 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.
  • the Mobile Butler application scans duplicate files (such as binary comparison) and before displaying the scan results to the user, at time t5, the Mobile Butler application queries the field value of the U field of the English Grammar 3 file and learns 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 butler application can determine that the file English Grammar 3 has not been modified between time t1 and time t5. Pass.
  • trying to modify the value of the indication field of the first file to the third value includes: if the first condition is not met, not modifying the indication field to the third value;
  • the method further includes: when the value of the indication field of the first file cannot be successfully modified to the third value, determining that the first file is modified within the period from the first moment to the second moment.
  • the mobile phone has performed a write memory operation for computer technology 1 in the candidate duplicate file
  • the preliminary screening of duplicate files is completed, at time t1, because the first condition is not met
  • the mobile phone The housekeeper 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).
  • the mobile butler application treats computer technology 1 as a modified file (no longer a duplicate file) and will no longer perform deduplication on computer technology 1 to avoid mistaken deduplication.
  • 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 to the memory.
  • the file system can determine that the file is modified based on at least the first memory write operation between the first moment and the second moment, and accordingly modify the value of the U field of the file to V2.
  • the application can query the value of the U field of the file, and determine whether the file has been modified between the first moment and the second moment based on the value of the U field.
  • the file system does not need to detect every write memory operation. Even if the file system misses the detection of write memory operations, the file system can still determine the file based on at least the first write memory operation detected within a period of time. has been modified. In this way, the detection accuracy of electronic equipment can be improved.
  • 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). The electronic device can determine the location of the file based on the U field value of the file. Whether it was modified between the first moment and the second moment.
  • the approach also includes:
  • the duplicate files include a first file and a second file; the first file is stored in the first storage space, and the second file is stored in the second storage space;
  • the first interface includes information about the first file and information about the second file.
  • English Grammar 1-4 is scanned and obtained as a set of duplicate files. These four duplicate files are stored in storage spaces 1-4 respectively. If it is determined that English Grammar 2 was modified between the first moment and the second moment, English Grammar 1, 3, 4 from the first moment to the second moment If it has not been modified during this period, it means that English Grammar 1, 3, and 4 still constitute duplicate files. As shown in (c) of Figure 10A, the mobile phone can display a first interface 906.
  • the first interface 906 includes information on a group of repeated files of English Grammar 1, 3, and 4.
  • a first operation input by the user in the first interface is detected
  • the mobile phone after detecting the user's operation of clicking the compression button 907 (an example of the first operation), the mobile phone performs compression on a set of duplicate files (English grammar 1, 3, 4) selected by the user.
  • the following English grammars 1, 3, and 4 point to the same storage space. In this way, storage space can be freed up.
  • the method further includes:
  • the identification of the first file and the identification of the second file are stored.
  • the electronic device stores the identification of duplicate files in the duplicate file information database.
  • the identification of the first file includes the first index node number of the first file; the identification of the second file includes the second index node number of the second file.
  • the phone can learn that the first file and the second file are historically duplicate files based on the identifiers of the stored duplicate files.
  • the mobile phone can query the values of the U fields 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 reduce the operating consumption of the mobile phone.
  • judging whether the first file has been modified during the period from the first moment to the second moment is based on the value of the indication field of the first file at the second moment, including:
  • the value of the indication 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 within the period from the first time to the second time, the first file Not modified.
  • the second aspect provides a file processing method that is applied to electronic equipment or components that support the functions of electronic equipment (such as chip systems).
  • the method includes:
  • Display a second interface which includes multiple duplicate files in the scanned electronic device; the multiple duplicate files are respectively stored in multiple storage spaces of the electronic device;
  • the indication field of each duplicate file in the plurality of duplicate files is obtained, and the value of the indication field of the duplicate file is used to indicate whether the duplicate file has been modified;
  • the mobile phone displays an interface 906 (an example of the second interface).
  • the interface 906 includes multiple duplicate files obtained by scanning (the group of duplicate files of English Grammar 1, 3, and 4, and the computer 2, 3 this set of duplicate files).
  • the mobile phone obtains the indication fields of the set of repeated files of English Grammar 1, 3, and 4 selected by the user, and according to the respective indication fields of English Grammar 1, 3, and 4 At the third time value, some files in English Grammar 1, 3, and 4 are compressed into the same storage space.
  • the indication fields of duplicate files in the second interface can be obtained according to the user's operation, and some duplicate files can be compressed according to the indication fields of each duplicate file.
  • it can release the storage space of the electronic device, and on the other hand, it can free up the storage space of the electronic device.
  • it instead of compressing all the duplicate files selected by the user, it verifies whether the duplicate files really need to be compressed based on the value of the indication field of the duplicate files selected by the user, so as to reduce the probability of mistaken compression and avoid mistaken compression. Affect the normal operation of electronic equipment. It can be seen that this solution can achieve accurate file compression, thereby accurately releasing the storage space of electronic devices. Moreover, it can effectively avoid the problem of mistaken deduplication caused by other processes modifying duplicate files before deduplication is performed, and the deduplication program does not sense that the duplicate files have been modified.
  • the initial value of the indication field of each duplicate file is the first value.
  • the method before displaying the second interface, the method also includes:
  • a plurality of candidate duplicate files are compared to determine a plurality of duplicate files from the plurality of candidate duplicate files.
  • the scan yields multiple candidate duplicate files, including:
  • the user's operation on the first control is detected, and multiple candidate duplicate files are scanned and obtained.
  • 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). It is detected that the user clicks the cleanup acceleration button 902.
  • the mobile phone scans and obtains multiple candidate duplicate files (such as English Grammar 1-5 shown in Figure 10B), and obtains multiple duplicate files based on the multiple candidate duplicate files (such as the English grammar shown in Figure 10B). English Grammar 1-4).
  • the scan yields multiple candidate duplicate files, including:
  • the electronic device When the electronic device is idle, multiple candidate duplicate files are scanned. For example, the electronic device performs scanning at night, or performs scanning after the screen is locked for a certain period of time.
  • the method after the first moment, the method also includes:
  • the second interface 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 the same as the one stored in the database. The index node numbers are consistent.
  • the mobile phone queries the value of the U field (indicator field) of English Grammar 1-4, where the value of the U field of English Grammar 2 is V0 ( Not V1), the values of the U fields of English Grammar 1, 3, and 4 are all V1, then the mobile phone can determine that English Grammar 1, 3, and 4 have not been modified during the period t1-t5.
  • the mobile phone can display the information of English grammar 1, 3, and 4 on the interface 906 (second interface) as shown in (c) of Figure 10A.
  • an attempt is made to modify the value of the indicated field of each of the multiple candidate duplicate files to a third value, including:
  • the value of the indication field of the 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 During the period from the first moment to the second moment, the modification operation of the file is repeated for at least one candidate.
  • obtaining the value of the indicator field of at least one duplicate file includes: at the second moment, obtaining the value of the indicator field of the target duplicate file in the at least one duplicate file as a third value. ;
  • 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 has not been modified during the period from the first moment to the second moment.
  • the plurality of candidate duplicate files includes a third file
  • the method further includes: detecting that the third file is modified, and modifying the value of the indication field of the third file to the second value;
  • the plurality of candidate duplicate files includes a fourth file
  • the method also 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 the period from the first moment to the second moment.
  • some of the duplicate files among the multiple duplicate files are compressed into the same storage space based on the value of the indicator field of the multiple duplicate files at the third moment, including:
  • the value of the indication field of the first file among the plurality of duplicate files at the third time is not the third value, compression is not performed on the first file.
  • the value of the indication field of the first file among the multiple duplicate files at the third moment is the third value, then perform compression on the first file;
  • the value of the indication field of the first file among the plurality of duplicate files at the third time is not the third value, compression is not performed on the first file.
  • the mobile phone manager application queries each duplicate file again (English Grammar 1, 3, 4, Computer Technology 1, 2) The value of the U field. It is judged that 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. Then the Mobile Butler application can determine that the value of English Grammar 3 during the period from time t1 to time t9 has been modified. In the same way, the Mobile Manager application determines whether other duplicate files have been modified between t1 and t9.
  • the approach also includes:
  • the information of multiple duplicate files is stored in the database.
  • the information of the duplicate files includes any one or more of the following information: the index node number of the duplicate file, the path of the duplicate file, and the name of the duplicate file.
  • the value of the indication field of the target duplicate file at the second moment is the third value, it is determined that the target duplicate file has not been modified during the period from the first moment to the second moment, including :
  • the value of the indication field of the target duplicate file is the third value, if the index node number of the target duplicate file does not change, it is determined that the target duplicate file has not been modified during the period from the first moment to the second moment.
  • a file processing device which is applied to electronic equipment or chip systems.
  • the electronic equipment stores an indication field of the first file.
  • the initial value of the indication field is the first value.
  • the indication field When the first file is modified, it is modified to the second value by the electronic device; the device includes:
  • Processing module for:
  • the value of the indication field of the first file at the second time it is determined whether the first file has been modified during the period from the first time to the second time.
  • try to modify the value of the indicated field of the first file to a third value including:
  • 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 of the first file within the period from the first moment to the second moment. operate.
  • the processing module is also configured to detect that the first file is modified after the first moment, and modify the value of the indication field of the first file to the second value.
  • the value of the indication field of the first file at the second time is the second value, it is determined that the first file was modified during the period from the first time to the second time.
  • judging whether the first file has been modified during the period from the first moment to the second moment is based on the value of the indication field of the first file at the second moment, including:
  • 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.
  • trying to modify the value of the indication field of the first file to the third value includes: if the first condition is not met, not modifying the indication field to the third value;
  • the processing module is also configured to determine that the first file is modified within the 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.
  • 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 to the memory.
  • the processing module is also used to:
  • the duplicate files include a first file and a second file; the first file is stored in the first storage space, and the second file is stored in the second storage space;
  • the device also includes a display module, which is used to display a first interface; the first interface includes information on the first file and information on the second file.
  • the device further includes an input module configured to detect the first operation input by the user in the first interface;
  • the processing module is configured to compress the first file and the second file into the same storage space according to the first operation detected by the input module.
  • the device also includes a storage module.
  • the storage module is configured to store the identification of the first file and the identification of the second file after scanning the electronic device for duplicate files.
  • the identification of the first file includes the first index node number of the first file; the identification of the second file includes the second index node number of the second file.
  • judging whether the first file has been modified during the period from the first moment to the second moment is based on the value of the indication field of the first file at the second moment, including:
  • the value of the indication 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 within the period from the first time to the second time, the first file Not modified.
  • a file processing device which is applied to electronic equipment or chip systems.
  • the device includes:
  • a display module configured to display a second interface.
  • the second interface includes multiple duplicate files in the scanned electronic device; the multiple duplicate files are respectively stored in multiple storage spaces of the electronic device;
  • a processing module configured to respond to an operation input by the user on the second interface and, at the third moment, obtain an indication field of each of the multiple duplicate files.
  • the value of the indication field of the duplicate file is used to indicate whether the duplicate file is Revise;
  • the processing module is also configured to compress some of the multiple duplicate files into the same storage space based on the value of the indication field of the multiple duplicate files at the third moment.
  • the initial value of the indication field of each duplicate file is the first value.
  • the processing module is also used to scan and obtain multiple candidate duplicate files before displaying the second interface; the multiple candidate duplicate files include multiple duplicate files;
  • the processing module is also configured to, at the 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.
  • the scan yields multiple candidate duplicate files, including:
  • the display module is controlled to display a third interface, and the third interface includes the first control;
  • the user's operation on the first control is detected, and multiple candidate duplicate files are scanned and obtained.
  • the scan yields multiple candidate duplicate files, including:
  • the processing module is also used to obtain the value of the indication field of at least one duplicate file at the second moment after the first moment;
  • the display module is also configured to display a second interface according to the value of the indication field of at least one duplicate file at the second moment; the plurality of duplicate files in the second interface have modified statuses within the period from the first moment to the second moment. are unmodified files.
  • an attempt is made to modify the value of the indicated field of each of the multiple candidate duplicate files to a third value, including:
  • the value of the indication field of the 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 During the period from the first moment to the second moment, the modification operation of the file is repeated for at least one candidate.
  • obtaining the value of the indicator field of at least one duplicate file includes: at the second moment, obtaining the value of the indicator field of the target duplicate file in the at least one duplicate file as a third value. ;
  • the processing module is also configured to determine that the target duplicate file has not been modified during the 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.
  • the plurality of candidate duplicate files includes a third file
  • Processing module also used for:
  • the plurality of candidate duplicate files includes a fourth file
  • the processing module is also configured to determine that the fourth file is modified within the 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.
  • some of the duplicate files among the multiple duplicate files are compressed into the same storage space based on the value of the indicator field of the multiple duplicate files at the third moment, including:
  • the value of the indication field of the first file among the plurality of duplicate files at the third time is not the third value, compression is not performed on the first file.
  • the storage module is used to store identifications of multiple duplicate files, and the identifications of the duplicate files include index node numbers of the duplicate files.
  • the value of the indication field of the target duplicate file at the second moment is the third value, it is determined that the target duplicate file has not been modified during the period from the first moment to the second moment, including :
  • the value of the indication field of the target duplicate file is the third value, if the index node number of the target duplicate file does not change, it is determined that the target duplicate file has not been modified during the period from the first moment to the second moment.
  • the indication field is stored in the metadata area of the electronic device.
  • the identification of the first file includes the first index node number of the first file; the identification of the second file includes the second index node number of the second file.
  • 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 memory, but the electronic device has not performed a write operation to the memory.
  • Figure 1A is an example diagram of a repetitive file scanning process provided by an embodiment of the present application.
  • Figure 1B is an example diagram of the i-mtime field provided by the embodiment of the present application.
  • Figure 2 is a schematic diagram of a write operation in a write interface mode provided by an embodiment of the present application
  • Figure 3 is a schematic diagram of a write operation in a memory write mode provided by an embodiment of the present application.
  • FIGS. 4 and 5 are additional schematic diagrams of write operations provided by embodiments of the present application.
  • Figure 6 is a schematic diagram of the hardware structure of an electronic device provided by an embodiment of the present application.
  • Figure 7 is a schematic diagram of the software structure of the electronic device provided by the embodiment of the present application.
  • Figure 8 is a schematic diagram of the data area and metadata area provided by the embodiment of the present application.
  • Figure 9 is a schematic diagram of a file processing method provided by an embodiment of the present application.
  • Figure 10A is a schematic diagram of the interface provided by an embodiment of the present application.
  • FIGS. 10B and Figure 10C are schematic diagrams of scenarios provided by embodiments of the present application.
  • Figure 11 is a schematic diagram of the database provided by the embodiment of the present application.
  • Figure 12 is a schematic diagram of a scene in which a file provided by the embodiment of the present application is modified
  • Figure 13 is a schematic diagram of a scenario where the files provided by the embodiment of the present application have not been modified
  • Figure 14 is a schematic diagram of the interface provided by the embodiment of the present application.
  • Figure 15 is a schematic diagram of a scenario where V1 setting fails provided by the embodiment of the present application.
  • Figure 16 is a schematic diagram of a scene in which a file provided by the embodiment of the present application is modified
  • Figure 17 is a schematic diagram of a scenario where the files provided by the embodiment of the present application have not been modified
  • Figure 18 is a schematic diagram of a scenario where V1 setting fails provided by the embodiment of the present application.
  • Figure 19 is a schematic diagram of a scene provided by an embodiment of the present application.
  • Figure 20 is a schematic diagram of the interface provided by the embodiment of the present application.
  • Figures 21 and 22 are schematic structural diagrams of the device provided by the embodiment of the present application.
  • Duplicate files are files with exactly the same content. For example, as shown in 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 scenarios, electronic devices can scan stored duplicate files. Scanning for duplicate files may include preliminary screening and binary comparison.
  • the electronic device intercepts part of the content in the file and obtains a value by reading the part of the content. If the value of the excerpted content of two files is the same, the electronic device initially thinks that the two files may be duplicate files. Afterwards, the electronic device performs a binary comparison on the two files and compares 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.
  • binary comparison can also be replaced by other steps for determining duplicate files, such as hash value comparison.
  • the embodiments of this application do not limit the specific implementation of the scanning process for duplicate files.
  • 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.
  • the electronic device can set the i-mtime field, which can be used to indicate the time when the file was last modified.
  • the i-mtime field can usually be stored in the file system's metadata area.
  • the i-mtime field can store the index node (inode) area of the metadata area.
  • 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).
  • the field value of the i-mtime field of file 1 can be 2022-8-23 (18:00).
  • file 2 has been modified twice in history, and the modification times were 2022-8-22 (18:00) and 2022-8-23 (10:00).
  • i of file 2 The field value of the -mtime field can be 2022-8-23 (10:00).
  • an application in an electronic device can learn whether the file has been modified within a period of time by querying the i-mtime field of the file.
  • 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 in the two queries are consistent, it means that the period from time point 1 to time point 2 is the same. The internal files have not been modified. On the contrary, if the field values of the i-mtime field in the two queries are inconsistent, it means that the file has been modified between time point 1 and time point 2.
  • the application queries the i-mtime field of file 1 at 10:00 and learns that the last modified time of file 1 was 8:00.
  • the application queries the file again at 12:00.
  • the i-mtime field of 1 indicates that the last modified time of file 1 is 8:00.
  • the field values obtained by the two queries (used to indicate the time when the file was last modified) are the same, and the application can determine that file 1 has not been modified between 10:00 and 12:00.
  • the application queries the i-mtime field of file 1 at 10:00 and learns that the last modified time of file 1 is 8:00.
  • the application queries again at 12:00.
  • the i-mtime field of file 1 indicates that the last modified time of file 1 is 11:00.
  • the field values obtained by the two queries are different, and the application can determine that file 1 was modified between 10:00 and 12:00.
  • each write operation will execute a piece of code in the file system.
  • the file system can modify the i-mtime field of the file to record the time when the file was last modified. For example, as shown in Figure 2, when calling the write interface to modify file 1 at time t1 (10:00), 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 identify File 1 was last modified at 10:00. Similarly, when calling the write interface to modify file 1 at time t2 (12:00), the electronic device will execute the code in the file system. The file system can modify the i-mtime field of file 1 to identify the last time file 1 was The modified time is 12:00.
  • electronic devices can map files to a certain memory through the mmap interface. Subsequently, when writing a file, the file can be written by writing to the memory.
  • Writing memory can be understood as writing content into the memory mapped by the file, which is equivalent to writing to the corresponding file indirectly.
  • the relevant code in the file system will be executed. In some examples, it may be possible to no longer execute code in the file system when writing to the same memory later, to avoid being trapped in the file system and incurring additional overhead.
  • the electronic device maps file 2 to memory 2 .
  • the electronic device writes to memory 2 for the first time through the mmap interface.
  • 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 modify the i-mtime field of file 2 accordingly to identify the time when file 2 was last modified as 10:00.
  • the electronic device maps the file to a certain piece of memory.
  • the electronic device writes content into the memory, which is equivalent to writing the corresponding content into the memory-mapped file. Since this write is the first write to the memory, the relevant code in the file system will be executed.
  • the file system can sense that the file has been modified and modify the i-mtime field of the file to identify the last time the file was The modified time is 10:05.
  • an application in the electronic device queries the i-mtime field of the file.
  • the electronic device writes content to the same memory for the second time, and in order to frequently get stuck in the file system, the electronic device does not get stuck in the code in the file system when writing the memory this time. Therefore, the file system cannot detect that the file associated with the memory has been modified, and accordingly the i-mtime field of the file is not modified.
  • the application queries the i-mtime field of the file again. Since the field values of the i-mtime field queried at t5 and t3 are both 10:05, the electronic device mistakenly believes that the file has not been modified during the t3-t5 period (that is, between 10:05-10:07).
  • the electronic device when performing a write operation through mmap, the electronic device will not be trapped in the file system, causing the file system to be unable to detect 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 a timely manner, causing the electronic device to fail.
  • the device misjudges whether the file has been modified.
  • the modification status of the file may be misjudged. For example, as shown in 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 last modified time of the file is 10:00. At time t3, the system time of the electronic device is modified, for example, from 10:30 to 9:30. After that, at time t4 (10:00 after modifying the system time), the file is modified again. At time t5, the application queries the i-mtime field of the file again. Since the field values of the i-mtime field queried at t5 and t3 are both 10:00, the electronic device mistakenly believes that the file has not been modified during the t3-t5 period (that is, between 10:05-12:00).
  • the system time can be modified by the user or automatically by the system.
  • the system time may be the same when the file is modified twice, which will cause the electronic device to misjudge whether the file has been modified, which cannot meet the business needs of the electronic device to accurately determine whether the file has been modified. That is, the modification status of the file cannot be reliably judged, and the performance of the electronic device is low.
  • the application can notify the file system through the inotify interface that it needs to monitor the modification status of the file. Subsequently, the file system monitors the event that the file has been modified and will notify the application that the file has been modified.
  • This method requires the application to run permanently during the period of time that needs to be monitored, occupying more system resources (such as memory resources), and the cost of electronic equipment is relatively large.
  • FIG. 6 shows a schematic diagram of the hardware structure of an electronic device provided by an embodiment of the present application.
  • the electronic device 200 includes at least one processor 201, a memory 202 and at least one transceiver 203.
  • the processor 201 can be a general central processing unit (CPU), a microprocessor, an application-specific integrated circuit (ASIC), or one or more processors used to control the execution of the program of the present application. integrated circuit.
  • CPU central processing unit
  • ASIC application-specific integrated circuit
  • Communication lines may be included between the above-mentioned components for transmitting information between the above-mentioned components.
  • the transceiver may be a module, a circuit, a bus, an interface, or other device that can implement communication functions and is used to communicate with other devices.
  • the transceiver can be an independently configured transmitter, and the transmitter can be used to send information to other devices.
  • the transceiver can also be an independently configured receiver, and can be used to receive information from other devices.
  • the transceiver may also be a component that integrates the functions of sending and receiving information. The embodiments of this application do not limit the specific implementation of the transceiver.
  • Memory 202 may be a read-only memory (ROM) or other type of static storage device that can store static information and instructions, a random access memory (random access memory (RAM)) or other type that can store information and instructions.
  • a dynamic storage device can also be an electrically erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM) or other optical disk storage, optical disc storage (including compressed optical discs, laser discs, optical discs, digital versatile discs, Blu-ray discs, etc.), disk storage media or other magnetic storage devices, or can be used to carry or store desired program code in the form of instructions or data structures and can be used by a computer Any other medium for access, but not limited to this.
  • the memory can exist independently and be connected to the processor through communication lines. Memory can also be integrated with the processor.
  • the memory 202 is used to store computer execution instructions for implementing the solution of the present application, and is controlled by the processor 201 for execution.
  • the processor 201 is used to execute computer execution instructions stored in the memory 202, thereby implementing various methods provided by the following embodiments of the application.
  • the computer execution instructions in the embodiments of the present application may also be called application codes, instructions, computer programs or other names, which are not specifically limited in the embodiments of the present application.
  • the processor 201 may include one or more CPUs.
  • the electronic device 200 may include multiple processors. Each of these processors may be a single-CPU processor or a multi-CPU processor.
  • a processor here may refer to one or more devices, circuits, and/or processing cores for processing data (eg, computer program instructions).
  • Figure 6 shows an exemplary structural diagram of an electronic device. It should be understood that the illustrated electronic device is only an example, and in actual applications the electronic device may have more or fewer components than shown in Figure 6, and two or more components may be combined. Or could have different component configurations.
  • Software systems of electronic devices can adopt layered architecture, event-driven architecture, microkernel architecture, microservice architecture, or cloud architecture.
  • the software system of the electronic device may be system etc.
  • the embodiment of the present invention takes the Android system with a layered architecture as an example to illustrate the software structure of the electronic device.
  • Figure 7 is a software structure block diagram of an electronic device according to an embodiment of the present invention.
  • the layered architecture divides the software into several layers, and each layer has clear roles and division of labor.
  • the layers communicate through software interfaces.
  • the Android system is divided into five layers, from top to bottom: application layer (referred to as application layer), application framework layer (referred to as framework layer), Android runtime (Android runtime) and system library. Hardware Abstraction Layer (HAL) and kernel layer.
  • application layer referred to as application layer
  • framework layer application framework layer
  • Android runtime Android runtime
  • HAL Hardware Abstraction Layer
  • kernel layer kernel layer.
  • the application layer can include a series of application packages. As shown in Figure 7, the application package can include camera, gallery, calendar, call, map, navigation, wireless local area network (WLAN), Bluetooth, music, video, short message and other applications.
  • the application package can include camera, gallery, calendar, call, map, navigation, wireless local area network (WLAN), Bluetooth, music, video, short message and other applications.
  • WLAN wireless local area network
  • the application program may also include settings, mobile phone manager and other applications.
  • the Mobile Butler application can call the interface provided by the file system to modify the field value of the U field of the corresponding file. Subsequently, the Mobile Butler application can determine whether the corresponding file has been modified within a period of time based on the field value of the U field.
  • the application can determine the value of the U field through at least one of the following methods.
  • the first method the application program can call the first interface provided by the file system, and the first interface returns the U field value of the file.
  • the second method the application calls the second interface provided by the file system.
  • the file system determines the U field value of the file during execution, and determines whether to continue executing the remaining steps of the second interface based on the U field value.
  • the above application can be an application running in user mode.
  • API application programming interface
  • the framework layer provides APIs and programming frameworks for applications in the application layer.
  • the framework layer includes some predefined functions.
  • the framework layer can include activity manager, window manager, content provider, view system, phone manager, resource manager, notification manager, etc.
  • the activity manager is responsible for the startup of all APP processes, the startup of the four major components of the APP (such as activity, service, broadcast receiver, content provider), the interface between APPs and within the APP. switching and the life cycle of various components.
  • a window manager is used to manage window programs. The window manager can obtain the display size, determine whether there is a status bar, lock the screen, capture the screen, etc.
  • Content providers are used to store and retrieve data and make this data accessible to applications. Said data can include videos, images, audio, calls made and received, browsing history and bookmarks, phone books, etc.
  • the view system includes visual controls, such as controls that display text, controls that display pictures, etc.
  • a view system can be used to build applications.
  • the display interface can be composed of one or more views.
  • a display interface including a text message notification icon may include a view for displaying text and a view for displaying pictures.
  • Telephone managers are used to provide communication functions of electronic devices. For example, call status management (including connected, hung up, etc.).
  • the resource manager provides various resources to applications, such as localized strings, icons, pictures, layout files, video files, etc.
  • the notification manager allows applications to display notification information in the status bar, which can be used to convey notification-type messages and can automatically disappear 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 notifications that appear in the status bar at the top of the system in the form of charts or scroll bar text, such as notifications for applications running in the background, or notifications that appear on the screen in the form of conversation windows. For example, text information is prompted in the status bar, a beep sounds, the electronic device vibrates, the indicator light flashes, etc.
  • Android Runtime is responsible for the scheduling and management of the Android system.
  • System libraries can include multiple functional modules. For example: surface manager (surface manager), media libraries (Media Libraries), 3D graphics processing libraries (for example: OpenGL ES), 2D graphics engines (for example: SGL), etc.
  • the surface manager is used to manage the display subsystem and provides the integration of 2D and 3D layers for multiple applications.
  • the media library supports playback and recording of a variety of commonly used audio and video formats, as well as static image files, etc.
  • the media library can support a variety of 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, composition, and layer processing.
  • 2D Graphics Engine is a drawing engine for 2D drawing.
  • the kernel layer is the layer between hardware and software.
  • the kernel layer may include a file system.
  • the file system is the core module of the operating system kernel, which is one of the main components.
  • the file system is responsible for managing and storing file information, mainly creating files for users, saving, reading, modifying, and dumping files, controlling file access, and revoking files when users no longer use them.
  • the file system may run in kernel mode.
  • API application programming interface
  • Metadata in the file system can include metadata as well as data.
  • metadata is used to describe the characteristics and attributes of files.
  • 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 are, for example, regular files (regular inode), directory files (directory inode), soft links (symbol link inode), special files (special inode), etc.
  • the file's metadata and data can be stored on a storage device (such as a hard disk).
  • a storage device such as a hard disk.
  • the storage of storage devices Areas may include metadata areas as well as data areas.
  • the data of the file can be stored in the data area of the storage device.
  • the data stored in the data area may be data obtained by file-level compression based on lossless compression technology.
  • the data in the data area is stored as a collection of disk blocks in the physical storage space of the storage medium (such as a disk, flash memory, etc.). Among them, the data of the same file can be stored in consecutive disk blocks, or it can also be interleaved and stored in discontinuous disk blocks.
  • Disk blocks can be used to represent small physical storage spaces obtained by dividing the physical storage space of the storage medium.
  • the data storage location can be represented by the index of the block where the data is located.
  • files are stored in blocks 909, 912, and 914.
  • the metadata area can store the block index 909, 912, 914 of the file.
  • the electronic device can read the index of the block where the file is located from the metadata area, and access (such as read) the file at the location of the corresponding block based on the index.
  • a file system may provide an interface for user-mode programs to read and write files.
  • the file system provides read and write interfaces (for example: read, write), and user-mode programs call the read and write interfaces to read and write files.
  • the file system provides a memory mapping interface (for example: mmap).
  • 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, writing the file by writing to the memory.
  • the file system since each file access operation calls an interface provided by the file system, the file system can be aware of each file access operation.
  • the file system can add an unmodified field (which can be referred to as the U field) in the metadata area, and the U field can indicate whether the corresponding file has been modified.
  • U field can indicate whether the corresponding file has been modified.
  • Each file has a corresponding U field.
  • the file system can set the initial value of the U field.
  • the initial value is set to V0.
  • the file system can provide an interface to the application program, and the application program can call the interface to modify the field value of the U field (for example, modify it to V1). Subsequently, the application can determine whether the corresponding file has been modified based on the field value of the U field.
  • the technical solution of the embodiment of the present application may include the following steps:
  • the file system sets the value of the U field of the first file to V0.
  • the U field can be saved in the metadata area of the file system.
  • the mobile phone displays an interface 901 of the mobile phone manager application, and the interface 901 may include a "cleanup acceleration" button 902 .
  • the mobile phone can scan the data stored in the mobile phone to be cleaned.
  • the data to be cleaned can include multiple duplicate files, that is, multiple files with exactly the same content.
  • the Mobile Butler application calls the interface of the file system to try to modify the field value of the U field corresponding to the multiple duplicate files from the initial value V0 to V1.
  • the process of scanning for duplicate files may include preliminary screening and binary comparison. After the mobile butler application obtains files initially identified as duplicate files (can be referred to as candidate duplicate files) through preliminary screening, it can call the file system interface before binary comparison and try to change the value of the U field of each candidate duplicate file to V1. .
  • the mobile phone can perform a preliminary screening of duplicate files.
  • English Grammar 1-4 is initially identified as a set of candidate duplicate files, and the computer Techniques 1 and 2 are a set of candidate duplicate files. Take the example of trying to change the U field value of English Grammar 2 in candidate duplicate files to V1.
  • the mobile phone performs the initial screening of duplicate files, at time t 1 (the first moment), the mobile butler application Call the file system interface and try to change the field value of the U field corresponding to English Grammar 2 from V0 to V1.
  • the Mobile Butler application can successfully convert the U word of English Grammar 2 The value of the segment is modified from V0 to V1.
  • the mobile phone manager application can try to modify the value of the U field of other candidate duplicate files (that is, files initially identified as duplicate files) to V1.
  • the application when the application wants to set the U field of the first file to V1, it can call the interface of the file system to send a request message to the file system.
  • the request message is used to request that the U field of the first file be set to V1.
  • the initial value is modified to V1.
  • V1 can be specified by the application or by the file system.
  • 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 may modify the value of the U field of the first file. The value is changed 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.
  • the first condition includes: whether the file has been mapped to memory (for example, the application has used mmap() to map the file).
  • the mobile phone before time t1, the mobile phone has mapped the file Computer Technology 1 into the memory. If the first condition is not met, then at time t1, the mobile phone manager application will not successfully map the U field of Computer Technology 1. The field value is modified from V0 to V1.
  • Figure 10B shows some candidate duplicate files obtained through preliminary screening.
  • the Mobile Butler application initially identified English Grammar 1-5 as a group of candidate duplicate files, and Computer Technology 1-4 as a group of candidate duplicate files.
  • 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.
  • Table 2 shows the field values of the U field of each candidate duplicate file after time t1.
  • the field value of the U field of Computer Technology 1 is still the initial value V0.
  • the mobile phone has mapped the file Computer Technology 1 into the memory.
  • the field values of the U fields of other files, such as English Grammar 1-4 and Computer Technology 2 were modified to V1 by the mobile phone manager application, indicating that the mobile phone did not map these files to memory before time t1.
  • the file system when the first condition is met, the file system returns a successful setting message to the application program, and the application program can determine based on this that the value of the U field of the file has been modified to V1.
  • the file system returns a setting failure message to the application program, and the application program can determine based on this that the value of the U field of the file is not set to V1 (is still V0).
  • users can modify files.
  • the mobile phone has not performed a memory write operation for English Grammar 2.
  • the mobile phone writes the memory for English Grammar 2 for the first time.
  • the file system can sense that English Grammar 2 has been modified, and modify the U field of English Grammar 2 from V1 to V2.
  • the file system can also store the modification time of the file in the metadata area.
  • the file system can store t3 in the metadata area.
  • the application can determine the modification time of the file based on the modification time stored in the metadata area.
  • step 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 performed. If the value of the U field of the first file is not set to V1, step S111 is executed.
  • the application program may receive a return message from the file system, the return message being used to indicate whether the value of the U field of the first file is successfully set to V1.
  • the application successfully sets the value of the U field of a duplicate file to V1, which means that the mobile phone did not map the file to memory before time t1.
  • the subsequent mobile phone can map the file to the memory, and if the memory writing method is used, If the file is modified in this way, 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.
  • 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 (V2) of the file.
  • the mobile phone does not subsequently modify the file, 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 (V1) of the file.
  • V2 and V1 are different.
  • V2 may be equal to V0.
  • the phone will also execute the relevant code of the file system every time it writes.
  • the file system can still sense that the file has been modified and modify the value of the U field of the file. (V2).
  • the mobile phone does not subsequently modify the file, 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 (V1) of the file.
  • the mobile phone can use the U field of the file to modify the file. Whether the value changes subsequently (such as the second moment), accurately determine whether the file has actually been modified.
  • the application failed to successfully set the value of the U field of a certain file to V1 (still V0), which means that the mobile phone has previously mapped the file to memory.
  • V1 still V0
  • the mobile phone may not execute the relevant code in the file system, and the file system cannot track the modification event of the file. It is 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 sense that the file has been modified, and therefore, the value of the U field of the file is not updated.
  • the file system will not update the value of the U field of the file. In this way, no matter whether the file is modified or not, the value of the U field of the file is V0 (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.
  • the file system may not be able to sense that the file has been modified, and the file system may not update the U field value of the file in a timely manner.
  • the mobile phone cannot determine whether the file has been modified based on the value of the U field at the second moment.
  • the mobile phone can perform subsequent step S109 to determine that the first file is not a duplicate file, so as to avoid mistakenly deduplicating the first file.
  • the application when the application lacks corresponding permissions, it may also result in the failure to successfully modify the value of the U field of the file from V0 to V1.
  • the system application authorized by the user has the authority to modify the U field to reduce the risk of misjudgment.
  • the application may not be able to successfully modify the value of the file's U field to V1 when there is a lack of storage space.
  • the mobile phone can perform binary comparison on these candidate duplicate files, so that Determine the final duplicate files.
  • the mobile phone to perform a preliminary screening of candidate duplicate files.
  • the candidate duplicate files obtained by the preliminary screening include the group of candidate duplicate files of English Grammar 1-5, and the computer Techniques 1-4 are the set of candidate duplicate files.
  • the Mobile Manager application attempts to set the value of the U field of each candidate duplicate file to V1.
  • the Mobile Butler application can apply the candidate duplicate files of Grammar 1-4 and Computer Technology 2 -4 This set of candidate duplicate files is subjected to binary comparison to determine the final duplicate file.
  • English Grammar 1-4 constitute a set of duplicate files.
  • Computer Technology 2-4 constitute a set of duplicate files.
  • the mobile phone can store information about duplicate files into a duplicate file information database.
  • the identification of duplicate files can be stored in the duplicate file information base.
  • the duplicate file information database may include the identifier of each duplicate file in the group of duplicate files of English Grammar 1-4, and the identifier of each duplicate file in the group of duplicate files of Computer Technology 2-4.
  • the identification of the duplicate file includes but is not limited to: the name of the duplicate file, the inode number of the duplicate file, and whether the value of the U field of the duplicate file was successfully set to V1 at the first moment. Among them, the index node number of the file is used to uniquely identify a file. Files with different contents have different index node numbers.
  • the application can query the value of the U field of each duplicate file and determine the value of the U field based on the U field of each duplicate file. The value at the second time determines whether each duplicate file has been modified between the first time and the second time.
  • the application itself queries the value of the U field of the file.
  • 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.
  • the application program determines whether the value of the U field of the first file is V1. If the value of the U field is V1, perform the following step S107. If the value of the U field is not V1, perform the following step S108.
  • the application determines that the first file has not been modified.
  • the Mobile Butler application After the Mobile Butler application scans the duplicate files (binary comparison) and before displaying the scan results to the user, at time t5, the Mobile Butler application queries the field value of the U field of the duplicate file English Grammar 3. , knowing that the field value is V1. Since the field value of the U field in English Grammar 3 at time t5 is the same as the field value at time t1, both are V1, the Mobile Butler application can determine that at time t1 (time t1, the Mobile Butler application calls the file system interface and tries to From the time the field value of the U field of English Grammar 3 was modified from V0 to V1) to time t5, the file English Grammar 3 has not been modified.
  • the Mobile Butler application can query the field values of the U fields of English Grammar 1, 3, and 4. If the U field values of English Grammar 1, 3, and 4 are all V1, it means that the file system has not detected English Grammar 1 and 3. ,4 is modified. Then, the Mobile Butler application can determine that the three files English Grammar 1, 3, and 4 have not been modified between time t1 and time t5. Therefore, English Grammar 1, 3, and 4 still constitute duplicate files. Subsequently, the Mobile Manager application can deduplicate this group of duplicate files to reduce the storage space occupied.
  • 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 U field of the first file is at the second moment, If the value of 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.
  • the application determines that the first file is modified.
  • the Mobile Butler application can read English grammar 2 from the metadata area.
  • the field value of the U field 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 Butler application can determine that at time t1 (time t1, the Mobile Butler application requests the file system to change the field value of the U field of English Grammar 3
  • the file English Grammar 2 may have been modified between the time when the value was modified from V0 to V1) and time t5. Phone no longer treats English Grammar 2 as a duplicate file. In this way, the Mobile Manager application will not perform duplication deduplication in English Grammar 2 in the future.
  • the modification time t3 of English Grammar 2 can also be stored in the metadata area.
  • the mobile butler application can read the modification time from the metadata area, and accordingly learn that the modification time of English Grammar 2 is t3.
  • the file system misses detection such as the second write memory operation and cannot update the i-mtime field in time, causing the electronic device to mistakenly believe that the file has not been modified during the t3-t5 period.
  • the technical solution of the embodiment is that for a certain file, if the file is not mapped to the memory before the first moment, once the subsequent mobile phone writes the file to the memory one or more times between the first moment and the second moment operation, the first memory write operation will definitely cause the phone to execute file system-related code. That is to say, at least the first memory write operation between the first moment and the second moment will be detected by the file system.
  • the file system can determine that the file is modified based on at least the first memory write operation between the first moment and the second moment. It can be seen that in the embodiment of the present application, the file system does not need to detect every write memory operation. Even if the file system misses the detection of write memory operations, the file system can still determine the file based on at least the first write memory operation detected within a period of time. has been modified. In this way, the detection accuracy of electronic equipment can be improved.
  • the application determines that the first file is not a duplicate file.
  • the value of the U field of the first file was 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 (possibly is no longer a duplicate file), but the file system may not be able to detect that the first file has been modified.
  • the application treats the first file as a modified file and the first file is no longer a duplicate.
  • the application program does not perform deduplication processing on the first file to avoid mistakenly deduplicating the first file that is actually a non-duplicate file.
  • the mobile phone manager application cannot successfully transfer the computer technology 1
  • the value of the U field of 1 is modified to V1 (the value of the U field is still V0).
  • the mobile phone manager application can no longer perform binary comparison on the computer technology 1.
  • the mobile butler application can treat computer technology 1 as a modified file (no longer a duplicate file) and no longer perform deduplication on computer technology 1 to avoid mistaken deduplication.
  • the mobile phone manager application determines the modification status of each duplicate file during the period t1-t5
  • it may The user is presented with one or more duplicate files that have not been modified.
  • the unmodified files include: English Grammar 1, 3, and 4, and Computer Technology 2 and 3. That is, English Grammar 1, 3, and 4 still constitute duplicate files, and Computer Technology 2 and 3 still constitute duplicate files.
  • the mobile phone can display interface 903.
  • the interface 903 may include a card 905 corresponding to the duplicate file in the mobile phone.
  • card 905 there are 8 sets of duplicate files stored in the mobile phone (including the set of duplicate files of English Grammar 1, 3, and 4 and the set of duplicate files of Computer Calculation 2 and 3).
  • the duplicate files occupy a total of 229MB. of storage space.
  • the mobile phone may display an interface 906 as shown in (c) of Figure 10A.
  • the interface 906 can present detailed information of the above eight groups of duplicate files. For example, as shown in (c) of FIG. 10A , the interface 906 displays the information of the first set of duplicate files "English Grammar 1, English Grammar 3, and English Grammar 4". The interface 906 also presents the information of the second set of duplicate files "Computer Technology 2, Computer Technology 3". In response to the user's operation such as sliding up, the interface 906 may also present information about other duplicate files. Multiple files in each set of duplicate files occupy multiple storage spaces. For example, English Grammar 1-4 each takes up 24MB of storage space.
  • the user can check one or more groups of duplicate files and click the compression button 907.
  • the mobile phone can deduplicate one or more sets of duplicate files selected by the user based on the user's compression/deduplication intention. For example, as shown in (c) of Figure 10A, if the user checks the group of duplicate files of English Grammar, the mobile phone can deduplicate the group of files of English Grammar 1, 3, and 4 according to the user's compression intention. As shown in Figure 10C, after deduplication, English Grammar 1, 3, and 4 only occupy one storage space (24MB), which greatly frees up the storage space of the mobile phone.
  • the electronic device can still display the group of files English Grammar 1, 3, and 4 in the user interface, and the user can still open and use any file in this group of files normally. Compared with before and after deduplication, the storage space occupied by English Grammar 1, 3, and 4 has been reduced.
  • file deduplication is a possible implementation method of file compression.
  • File compression can also be done in other ways, which are not limited by the embodiments of this application.
  • the electronic device can modify the value of the U field of the file 1 from the initial value V0 to V1 at the first moment. Then, at the second moment, the electronic device can query the value of the U field of the 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. 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.
  • V1 such as V2
  • the electronic device does not modify the value of the U field of the file 2 at the first moment (the value of the U field is still the initial value V0). This means that between the first moment and 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 is modified. In this case, the electronic device regards file 2 as a modified file, and file 2 is no longer a duplicate file. Furthermore, the application does not perform deduplication on File 2 to avoid mistaken deduplication of File 2 which is actually a non-duplicate file.
  • V2 can also be replaced by other values other than V1 (for example, V0).
  • V1 for example, V0.
  • the embodiment of this application does not impose any restrictions on the specific value of the U field that is modified when the file system senses that the file has been modified.
  • the above mainly takes the application as a mobile butler application as an example to explain the method of determining the modification status of a file. It should be understood that the application can also be any other possible application.
  • 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.
  • the mobile phone can scan the duplicate files on the mobile phone by itself and deduplicate some duplicate files to reduce the occupation of storage space.
  • the mobile phone actively scanning for duplicate files and performing deduplication Take the mobile phone actively scanning for duplicate files and performing deduplication as an example.
  • the application changes the values of the U fields of files A and B to V1.
  • the application reads the contents of files A and B and considers files A and B to be duplicate files.
  • file A is modified, and the value of the U field of file A is modified to V2 by the file system.
  • the application queries the values of the U fields of files A and B and learns that the value of the U field of file A is V1 and the value of the U field of file B is V2, which means that file A has been modified and file B has been modified. Not modified, files A and B are no longer duplicate files. Therefore, the application does not perform deduplication on files A and B.
  • the application modifies the values of the U fields of files A and B to V1.
  • the application reads the contents of files A and B and considers files A and B to be duplicate files.
  • the application queries the files A and B
  • the value of the U field indicates that the value of the U field of files A and B is V1, which means that since time point 1, neither files A nor B have been modified, and files A and B still constitute duplicate files. Therefore, the application can perform deduplication on files A and B.
  • Embodiments of the present application also provide a file processing method.
  • the file has been mapped to the memory.
  • This method 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 into memory, and the electronic device has written to the memory mapped by the file.
  • the electronic device can use different methods to determine whether the file has been modified. The following is explained with examples.
  • the application program wants to modify the value of the U field of the file English Grammar 2 to V1
  • the application program can call the interface of the file system to The file system sends a request message. It is judged that the file has been mmapd (that is, 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 the file can be The value of the U field of the file is modified from the initial value V0 to V1.
  • the application can then perform a binary comparison of English Grammar 3 with other candidate duplicate files to determine the final duplicate file.
  • the electronic device performs a write operation on the memory mapped by the file for the first time.
  • the electronic device will call the function of the file system, so the file system can sense this write operation on the file.
  • the file system can modify the value of the U field of the file from V1 to V2.
  • the application queries the value of the U field (V2) of the file, Since the value of the U field obtained from the query 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.
  • the application queries the value of the U field (V1) of the file. Since the value of the U field obtained by the query at time t5 is the same as the value of the U field at time t1, the application can determine the value of the U field at time t1.
  • the file has not been modified during the t1-t5 period.
  • the mobile phone can display duplicate files that have not been modified during the t1-t5 period to the user. For example, during the period t1-t5, if English Grammar 1, 3, and 4 in the duplicate file have not been modified, the mobile phone can display the information of English Grammar 1, 3, and 4 in the interface shown in (c) of Figure 10A .
  • the application program wants to modify the value of the U field of the computer technology 1 file to V1
  • the application program can call the interface of the file system to The file system sends a request message. It is judged that the file has been mmapd before (that is, it has been 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. Therefore, the file The system does not modify the value of the U field of the file, and the value of the U field of the file is still V0.
  • the application treats the file as a modified file and the file is no longer a duplicate. Also, the application does not perform deduplication on the file to avoid mistakenly deduplicating files that are actually non-duplicate files.
  • the mobile phone manager application sends a deduplication request to the file system, and the file system can check each item again.
  • the value of the U field of the duplicate file is used to further determine whether each duplicate file has been modified since the first moment. For example, as shown in Figure 19, after the user clicks the "Compress" button and before the mobile phone performs deduplication, at time t9, the file system queries the U of each duplicate file (English Grammar 1, 3, 4, Computer Technology 1, 2) again. The value of the field.
  • the mobile phone After judging that 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, the mobile phone can determine that English Grammar 3 was modified between time t1 and time t9. Pass. In the same way, the mobile phone determines whether other duplicate files have been modified at t1-t9.
  • the file system checks the U field value of the file to ensure that the U field value is checked and the atomicity of the deduplication operation is checked, that is, the U field value is checked to determine that the deduplication condition is met, During the deduplication process, the files will not be modified.
  • the application does not need to run permanently. In this way, system overhead can be reduced while ensuring accurate judgment of the modification status of the file.
  • the user opens the Phone Manager app and clicks the "Clean Acceleration" button to trigger the phone to perform a scanning process for duplicate files. Afterwards, the user can turn off the phone Housekeeper application. Later, when the remaining storage space of the phone is insufficient and a phenomenon such as lag occurs, the user can open the Phone Manager app again and click the "Clean Acceleration" button.
  • the phone can scan the duplicate files based on the historical results and modify some duplicate files. Status, re-determine duplicate files in the phone to reduce resource consumption caused by re-scanning duplicate files.
  • the Mobile Butler application scans and obtains: English Grammar 1-4 are a set of duplicate files, and Computer Technology 1 and Computer Technology 2 are a set of duplicate files.
  • the mobile phone can store the file identifiers of the group of duplicate files English Grammar 2-4 and the file identifiers of the group of duplicate files Computer Technology 1 and Computer Technology 2 in the duplicate file information database as shown in Figure 11.
  • the Mobile Butler application can query the duplicate file information database as shown in Figure 11 and learn English Grammar 1-4. Group the duplicate files in history, as well as the group of historical duplicate files in Computer Technology 2-4, and query the U field values of the duplicate files in English Grammar 1-4 and Computer Technology 2-4, so that according to the The U field value determines whether each duplicate file has been modified within a period of time.
  • the mobile butler 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. As shown in Figure 14, at time t6, the mobile butler application can display the above groups of duplicate files in the interface 906.
  • the 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 cost of the phone. operating consumption.
  • the duplicate file information database such as shown in Figure 11 can be updated.
  • the above first condition is only an example. It should be understood that any condition that can ensure that the write operation at t1-t5 is sensed by the file system can be used as the first condition. On the contrary, as long as subsequent writes cannot be guaranteed to be sensed by the file system, the first condition can be used. One condition is not met. Illustratively, as another feasible embodiment, it can be determined whether the file was mmapted before the first moment, and whether mmap has write permission. If the file was mmapted before the first moment, but mmap does not have write permission, the first condition is determined to be met. If the file was mmapted before the first moment, but mmap has write permission, the first condition is definitely not met.
  • the mobile phone can also perform a pre-scanning process, scan the duplicate files during idle periods, and store the scan results.
  • the repeated file scanning process in the above embodiment can also be a scanning process executed when the mobile phone is idle (such as at night).
  • the preliminary screening and binary comparison process shown in Figure 12 can be performed in advance at night.
  • the mobile phone can perform scanning for duplicate files at night. Assume that the scan obtains English Grammar 1-4 as a set of duplicate files, and during the scanning process, at time t1, try to modify the value of the U field of English Grammar 1-4 to V1. Afterwards, as shown in (a) of Figure 10A, the user clicks the "Clean Up Acceleration" button 902 during the day, and the mobile phone can query the value of the U field of English Grammar 1-4. Assume that the values of the U field of English Grammar 1-4 are all successfully set to V1 at time t1, and the values of the U field of English Grammar 1, 3, and 4 are still V1, then the mobile phone determines that English Grammar 1, 3, and 4 have been set since t1. Since they have not been modified since the beginning of time, these three files still constitute duplicate files. The mobile phone can display the information of these three duplicate files in an interface such as shown in (c) of Figure 10A.
  • the embodiments of the present application do not limit the timing when the electronic device performs pre-scanning of repeated files.
  • the electronic device can perform a pre-scanning process for duplicate files in appropriate scenarios. For example, at night, a pre-scan is performed when the lock screen duration exceeds a threshold.
  • the electronic device may also provide a setting portal so that the user can set the timing for performing the pre-scan.
  • a switch 201 is displayed in the setting interface 20 of the mobile phone. When switch 201 is turned on, the phone can perform pre-scanning when idle.
  • the mobile phone can also provide a setting portal 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 screen lock exceeds a certain threshold.
  • the electronic device can also determine whether V1 is set successfully at other opportunities and scenarios. For example, before querying the field value of the file each time, determine whether V1 is set successfully.
  • 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, memory, and one or more processors.
  • the display, memory and processor are coupled.
  • the memory is used to store computer program code, which includes computer instructions.
  • the processor executes the computer instructions, the device can perform each function or step performed by the mobile phone in the above method embodiment.
  • the structure of the device may refer to the electronic equipment (such as a terminal) shown in Figure 6 .
  • the core structure of the device can be represented as the structure shown in Figure 21.
  • the device includes: a processing module 1301, an input module 1302, a storage module 1303 and a display module 1304.
  • the processing module 1301 may include at least one of a central processing unit (CPU), an application processor (Application Processor, AP), or a communication processor (Communication Processor, CP).
  • the processing module 1301 may perform operations or data processing related to control and/or communication of at least one of the other elements of the user electronic device. Specifically, the processing module 1301 can be used to control the content displayed on the home 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.
  • the processing module 1301 may be implemented as the processor 201 shown in FIG. 6 .
  • the input module 1302 is used to obtain instructions or data input by the user, and transmit the obtained instructions or data to other modules of the electronic device.
  • the input method of the input module 1302 may include touch, gesture, proximity to the screen, etc., or may be voice input.
  • the input module may be a screen of an electronic device, obtains the user's input operation, generates an input signal according to the obtained input operation, and transmits the input signal to the processing module 1301 .
  • the storage module 1303 may include volatile memory and/or non-volatile memory.
  • the storage module is used to store at least one related instruction or data among other modules of the user terminal device.
  • the storage module 1303 may be implemented as the memory 202 shown in FIG. 6 .
  • the display module 1304 may include, for example, a liquid crystal display (LCD), a light emitting diode (LED) display, an organic light emitting diode (OLED) display, a microelectromechanical systems (MEMS) display, or an electronic paper display. Used to display user-viewable content (e.g., text, images, videos, icons, symbols, etc.).
  • LCD liquid crystal display
  • LED light emitting diode
  • OLED organic light emitting diode
  • MEMS microelectromechanical systems
  • a communication module 1305 is also included for supporting the personal terminal to communicate with other personal terminals (through a communication network).
  • the communication module may be connected to the network via wireless communication or wired communication to communicate with other personal terminals or network servers.
  • Wireless communications may employ at least one of cellular communications protocols, such as Long Term Evolution (LTE), Long Term Evolution-Advanced (LTE-A), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Universal Mobile Communications System (UMTS), Wireless Broadband (WiBro) or Global System for Mobile Communications (GSM).
  • Wireless communications may include, for example, short-range communications.
  • Short-range communication may include at least one of Wireless Fidelity (Wi-Fi), Bluetooth, Near Field Communication (NFC), Magnetic Stripe Transmission (MST), or GNSS.
  • the communication module 1305 may be implemented as a transceiver 203 such as shown in FIG. 6 .
  • each functional module of the device can perform one or more steps in the above method embodiment.
  • the chip system includes at least one processor 1401 and at least one interface circuit 1402.
  • the processor 1401 and the interface circuit 1402 may be interconnected by wires.
  • interface circuitry 1402 may be used to receive signals from other devices, such as memory of an electronic device.
  • interface circuit 1402 may be used to send signals to other devices (eg, processor 1401).
  • the interface circuit 1402 can read instructions stored in the memory and send the instructions to the processor 1401.
  • the electronic device can be caused to perform various steps in the above embodiments.
  • the chip system may also include other discrete devices, which are not specifically limited in the embodiments of this application.
  • Embodiments of the present application also provide a computer storage medium.
  • the computer storage medium includes computer instructions.
  • the electronic device When the computer instructions are run on the above-mentioned electronic device, the electronic device causes the electronic device to perform various functions or steps performed by the mobile phone in the above-mentioned method embodiments. .
  • An embodiment of the present application also provides a computer program product.
  • the computer program product When the computer program product is run on a computer, the The computer executes each function or step executed by the mobile phone in the above method embodiment.
  • the disclosed devices and methods can be implemented in other ways.
  • the device embodiments described above are only illustrative.
  • the division of modules or units is only a logical function division.
  • there may be other division methods for example, multiple units or components may be The combination can either be integrated into another device, or some features can be omitted, or not implemented.
  • the coupling or direct coupling or communication connection between each other shown or discussed may be through some interfaces, and the indirect coupling or communication connection of the devices or units may be in electrical, mechanical or other forms.
  • the units described as separate components may or may not be physically separated.
  • the components shown as units may be one physical unit or multiple physical units, that is, they may be located in one place, or they may be distributed to multiple different places. . Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
  • each functional unit in various embodiments of the present application may be integrated into one processing unit, or each unit may exist physically alone, or two or more units may be integrated into one unit.
  • the above integrated units can be implemented in the form of hardware or software functional units.
  • the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it may be stored in a readable storage medium.
  • the technical solutions of the embodiments of the present application are essentially or contribute to the existing technology, or all or part of the technical solution can be embodied in the form of a software product, and the software product is stored in a storage medium , including several instructions to cause a device (which can be a microcontroller, a chip, etc.) or a processor to execute all or part of the steps of the methods described in various embodiments of this application.
  • the aforementioned storage media include: U disk, mobile hard disk, read only memory (ROM), random access memory (RAM), magnetic disk or optical disk and other media that can store program code.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Human Computer Interaction (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

一种文件处理方法及电子设备,涉及终端技术领域,可以降低对存储空间的占用,该方法应用于电子设备,所述电子设备存储有第一文件的指示字段,所述指示字段的初始值为第一值,所述指示字段在所述第一文件被修改时被所述电子设备修改为第二值;所述方法包括:在第一时刻,尝试将所述第一文件的指示字段的值修改为第三值;所述第三值与所述第一值不同;所述第三值与所述第二值不同;若成功将所述第一文件的指示字段的值修改为所述第三值,则在第二时刻,获取所述指示字段的值;根据所述第一文件的指示字段在所述第二时刻的值,判断在所述第一时刻至所述第二时刻的时段内,所述第一文件是否被修改。

Description

文件处理方法及电子设备
本申请要求于2022年09月05日提交国家知识产权局、申请号为202211095247.7、发明名称为“文件处理方法及电子设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及终端技术领域,尤其涉及文件处理方法及电子设备。
背景技术
目前,很多电子设备利用操作系统中的文件系统管理文件。随着电子设备中存储的文件的数量剧增,文件系统出现了文件管理瓶颈。在一些场景中,电子设备中的文件可占用较多的存储空间,导致电子设备的可用存储空间较低。
发明内容
本申请提供文件处理方法及电子设备,可以高效的管理文件。
为了实现上述目的,本申请实施例提供了以下技术方案:
第一方面,提供一种文件处理方法,应用于电子设备或支持电子设备功能的组件(比如芯片系统),电子设备存储有第一文件的指示字段,指示字段的初始值为第一值,指示字段在第一文件被修改时被电子设备修改为第二值;方法包括:
在第一时刻,尝试将第一文件的指示字段的值修改为第三值;第三值与第一值不同;第三值与第二值不同;
若成功将第一文件的指示字段的值修改为第三值,则在第二时刻,获取指示字段的值;
根据第一文件的指示字段在第二时刻的值,判断在第一时刻至第二时刻的时段内,第一文件是否被修改。
示例性的,如图13,在t 1时刻(第一时刻的一个示例),手机将英语语法3(第一文件的一个示例)的U字段(指示字段的一个示例)的值成功修改为V1(第三值的一个示例),并在t5时刻(第二时刻的一个示例),查询U字段的值。手机可以根据英语语法3的U字段在t5时刻的值,判断在t1-t5时段内,英语语法3是否被修改。
本申请实施例中,可以通过第一文件的指示字段的值判断第一文件的修改状态,进而后续可以根据第一文件的修改状态,对第一文件进行相应管理。其中,电子设备无需在第一时刻至第二时刻期间持续监听第一文件的修改状态,而是可以第一时刻、第二时刻之外的其他时刻,中止监听,以降低电子设备用于监听的资源消耗。比如,在第一时刻,电子设备可以通过第一应用尝试将第一文件的指示字段的值修改为V1,在第一时刻之后,电子设备可以退出第一应用。第二时刻,电子设备再次打开第一应用,获取第一文件的指示字段的值,并根据该指示字段的值,判断第一文件在第一时刻至第二时刻期间是否被修改。可见,本申请实施例中,第一应用无需常驻的情况下,电子设备也可以判断第一文件在某个时段内是否被修改,能够降低对存储空间的占用。
并且,本方案与系统时间无关,因此,即便用户修改系统时间,也不会导致误判。
在一种可能的设计中,尝试将第一文件的指示字段的值修改为第三值,包括:
若满足第一条件,则将指示字段的值修改为第三值;在第一条件下,电子设备的文件系统能够检测到在第一时刻至第二时刻的时段内,针对第一文件的修改操作。
如此,一旦文件在第一时刻至第二时刻期间内被修改,则文件系统能够确保感知到该修改,并将该文件的指示字段的值修改为非V1值(比如第二值V2)。后续,电子设备能够查询该文件的指示字段的值,如果指示字段的值被修改为非V1的值,则电子设备确定该文件在第一时刻至第二时刻期间被修改,反之,如果指示字段的值仍为V1,则确定该文件在第一时刻至第二时刻期间未被修改。
在一种可能的设计中,在第一时刻之后,方法还包括:
检测到第一文件被修改,将第一文件的指示字段的值修改为第二值。
根据第一文件的指示字段在第二时刻的值,判断在第一时刻至第二时刻的时段内,第一文件是否被修改,包括:
若第一文件的指示字段在第二时刻的值为第二值,则确定在第一时刻至第二时刻的时段内,第一文件被修改,或者,若第一文件的指示字段在第二时刻的值不是第三值,则确定在第一时刻至第 二时刻的时段内,第一文件被修改。
示例性的,如图12,t1时刻(第一时刻的一个示例)之后,在t3时刻,检测到英语语法2被修改(该修改为t1时刻之后的首次写内存),手机将英语语法2的U字段的值修改为V2(第二值的一个示例)。在t5时刻(第二时刻的一个示例),手机查询英语语法2的U字段的值,获知英语语法2的U字段在t5时刻的值为V2(不再是V1),则确定在t1-t5时段内,英语语法2被修改。
在一种可能的设计中,根据第一文件的指示字段在第二时刻的值,判断在第一时刻至第二时刻的时段内,第一文件是否被修改,包括:
若第一文件的指示字段在第二时刻的值为第三值,则确定在第一时刻至第二时刻的时段内,第一文件未被修改,或者,若第一文件的指示字段在第二时刻的值不是第二值,则确定在第一时刻至第二时刻的时段内,第一文件未被修改。
比如,如图13,手机管家应用扫描完重复文件(比如二进制比对)之后,向用户显示扫描结果之前,在t5时刻,手机管家应用查询英语语法3这一文件的U字段的字段值,获知字段值为V1(第三值的一个示例)。由于英语语法3的U字段在t5时刻的字段值与在t1时刻的字段值相同,均为V1,则手机管家应用可以确定在t1时刻至t5时刻期间内,英语语法3这一文件未被修改过。
在一种可能的设计中,尝试将第一文件的指示字段的值修改为第三值,包括:若不满足第一条件,则不将指示字段修改为第三值;
方法还包括:在不能成功将第一文件的指示字段的值修改为第三值时,确定在第一时刻至第二时刻的时段内,第一文件被修改。
示例性的,如图15,假设t1时刻之前,手机针对候选重复文件中的计算机技术1执行过写内存操作,则重复文件的初筛完成后,在t1时刻,由于不满足第一条件,手机管家应用无法成功将计算机技术1的U字段的值修改为V1(U字段的值仍为V0)。此种情况下,手机管家应用将计算机技术1视为已被修改过的文件(不再是重复文件),不再对计算机技术1执行去重,以免执行误去重。
在一种可能的设计中,第一条件包括如下一项或多项条件:在第一时刻之前,第一文件未被映射到内存;在第一时刻之前,第一文件被映射到内存,但电子设备未对内存执行过写入操作。
对于某个文件来说,如果第一时刻前未将该文件映射到内存,则后续手机一旦在第一时刻至第二时刻期间内对该文件进行一次或多次写内存操作,其中的首次写内存操作必定会使得手机执行文件系统的相关代码。也就是说,第一时刻至第二时刻期间内的至少首次写内存操作会被文件系统检测到。如此,文件系统可以至少根据第一时刻至第二时刻期间内的至少首次写内存操作,确定该文件被修改,并据此将该文件的U字段的值修改为V2。后续,应用程序可以查询该文件的U字段的值,并根据U字段的值,判断该文件在第一时刻至第二时刻期间是否被修改。可见,本申请实施例中,文件系统无需检测每次写内存操作,即便文件系统存在漏检写内存操作的现象,文件系统也能根据检测到的一段时间内的至少首次写内存操作,确定文件被修改过。如此,能够提升电子设备的检测精度。
同理,对于某个文件来说,若在第一时刻之前,文件被映射到内存,但电子设备未对内存执行过写入操作,则后续手机一旦在第一时刻至第二时刻期间内对该文件进行一次或多次写内存操作,其中的首次写内存操作必定会使得手机执行文件系统的相关代码。即,一旦文件在第一时刻至第二时刻期间被修改,该修改必定会被文件系统感知到。
基于此原理,若在第一时刻之前,文件被映射到内存,但电子设备未对内存执行过写入操作,则电子设备可以在第一时刻,将该文件的U字段的值修改为V1。后续,一旦该文件在第一时刻至第二时刻期间被修改,则文件的U字段值会被文件系统修改为非V1值(比如V2),电子设备可以根据文件的U字段值,判断文件在第一时刻至第二时刻期间内是否被修改。
可见,本方案,能够降低mmap场景的误判。
在一种可能的设计中,方法还包括:
扫描得到电子设备中的重复文件,重复文件包括第一文件和第二文件;第一文件存储在第一存储空间,第二文件存储在第二存储空间;
确定第一时刻至第二时刻的时段内,第一文件、第二文件未被修改;
显示第一界面;第一界面包括第一文件的信息以及第二文件的信息。
比如,扫描得到英语语法1-4为一组重复文件,这四个重复文件分别存储在存储空间1-4中,若确定英语语法2在第一时刻至第二时刻期间内被修改,英语语法1、3、4在第一时刻至第二时刻 期间内未被修改,则意味着英语语法1、3、4仍构成重复文件。如图10A的(c),手机可显示第一界面906,第一界面906包括英语语法1、3、4这组重复文件的信息。
在一种可能的设计中,检测到用户在第一界面中输入的第一操作;
将第一文件以及第二文件压缩至同一存储空间。
比如,如图10A的(c),检测到用户点击压缩按钮907的操作(第一操作的一个示例),手机对用户选择的一组重复文件(英语语法1、3、4)执行压缩,压缩后的英语语法1、3、4指向同一存储空间。如此,可以释放存储空间。
在一种可能的设计中,在扫描电子设备中的重复文件之后,方法还包括:
存储第一文件的标识和第二文件的标识。比如,图11中,电子设备将重复文件的标识存储在重复文件信息库中。
在一种可能的设计中,第一文件的标识包括第一文件的第一索引节点编号;第二文件的标识包括第二文件的第二索引节点编号。
如此,后续,用户打开手机管家,并点击“清理加速”按钮时,手机可以根据存储的重复文件的标识,获知第一文件和第二文件历史上是重复文件。手机可以查询第一文件和第二文件的U字段的值,以便确定第一文件、第二文件是否仍构成重复文件。手机无需重新扫描第一文件、第二文件的内容,有助于降低手机的运行消耗。
在一种可能的设计中,根据第一文件的指示字段在第二时刻的值,判断在第一时刻至第二时刻的时段内,第一文件是否被修改,包括:
若第一文件的指示字段在第二时刻的值为第三值,且第一文件的索引节点编号为第一索引节点编号,则确定在第一时刻至第二时刻的时段内,第一文件未被修改。
第二方面,提供一种文件处理方法,应用于电子设备或支持电子设备功能的组件(比如芯片系统),方法包括:
显示第二界面,第二界面包括扫描得到的电子设备中的多个重复文件;多个重复文件分别存储在电子设备的多个存储空间;
响应于用户在第二界面上输入的操作,在第三时刻,获取多个重复文件中每个重复文件的指示字段,重复文件的指示字段的值用于指示重复文件是否被修改;
根据多个重复文件的指示字段在第三时刻的值,将多个重复文件中的部分重复文件压缩至同一存储空间。
比如,如图10A的(c),手机显示界面906(第二界面的一个示例),界面906包括扫描得到的多个重复文件(英语语法1、3、4这组重复文件,以及计算机2、3这组重复文件)。
响应于用户在界面906上点击压缩按钮907,在第三时刻,手机获取用户选择的英语语法1、3、4这组重复文件的指示字段,并根据英语语法1、3、4各自的指示字段在第三时刻的值,将英语语法1、3、4中的部分文件压缩至同一存储空间。
该方案中,能够根据用户的操作,获取第二界面中重复文件的指示字段,并根据各重复文件的指示字段,对部分重复文件进行压缩,一方面,能够释放电子设备的存储空间,另一方面,并非对用户选中的全部重复文件进行压缩,而是根据用户选中的重复文件的指示字段的值,校验是否确实需要对其中的重复文件进行压缩,以降低误压缩的概率,以免误压缩影响电子设备正常运行。可见,该方案能够实现精准的文件压缩,进而能够精准地释放电子设备的存储空间。并且,能够有效避免在执行去重之前,因为其他进程修改了重复文件,去重程序不感知重复文件被修改,而造成的误去重问题。
在一种可能的设计中,每个重复文件的指示字段的初始值为第一值。
在一种可能的设计中,显示第二界面之前,方法还包括:
扫描得到多个候选重复文件;多个候选重复文件包括多个重复文件;
在第一时刻,尝试将多个候选重复文件中每个候选重复文件的指示字段的值修改为第三值;
对多个候选重复文件进行比对,以从多个候选重复文件中确定多个重复文件。
比如,如图10B,用户点击“清理加速”按钮之后,手机经初筛,得到多个候选重复文件。其中,英语语法1-5构成一组候选重复文件,计算机技术1-4构成一组候选重复文件。在t 1时刻(第一时刻的一个示例),手机尝试将多个候选重复文件中每个候选重复文件的指示字段的值修改为V1(第三值的一个示例)。
在一种可能的设计中,扫描得到多个候选重复文件,包括:
显示第三界面,第三界面包括第一控件;
检测到用户对第一控件的操作,扫描得到多个候选重复文件。
示例性的,如图10A的(a),手机显示界面901(第三界面的一个示例),界面901包括清理加速按钮902(第一控件)。检测到用户点击清理加速按钮902,手机扫描得到多个候选重复文件(比如图10B所示的英语语法1-5),并根据多个候选重复文件得到多个重复文件(比如图10B所示的英语语法1-4)。
在一种可能的设计中,扫描得到多个候选重复文件,包括:
当电子设备空闲时,扫描得到多个候选重复文件。比如,电子设备夜间执行扫描,或者,锁屏时长达到一定时长后执行扫描。
通过在手机空闲时执行预扫描,可节约后续执行文件去重所需的时间,提高文件去重的效率,提升用户与电子设备之间的人机交互效率。
在一种可能的设计中,在第一时刻之后,方法还包括:
在第二时刻,获取至少一个重复文件的指示字段的值在第二时刻,获取至少一个重复文件的指示字段的值以及至少一个重复文件的索引节点编号;
当满足第三条件时,显示第二界面;第三条件包括:至少一个重复文件的指示字段在第二时刻的值为第三值,且,至少一个重复文件的索引节点编号与数据库中存储的索引节点编号一致。
示例性的,如图10B,在t5时刻(第二时刻的一个示例),手机查询英语语法1-4的U字段(指示字段)的值,其中,英语语法2的U字段的值为V0(不是V1),英语语法1、3、4的U字段的值均为V1,则手机可确定英语语法1、3、4在t1-t5时段内未被修改。手机可以在如图10A的(c)所示界面906(第二界面)上显示英语语法1、3、4的信息。
在一种可能的设计中,尝试将多个候选重复文件中每个候选重复文件的指示字段的值修改为第三值,包括:
若多个候选重复文件中的至少一个候选重复文件满足第一条件,则将至少一个候选重复文件的指示字段的值修改为第三值;在第一条件下,电子设备的文件系统能够检测到在第一时刻至第二时刻的时段内,针对至少一个候选重复文件的修改操作。
在一种可能的设计中,在第二时刻,获取至少一个重复文件的指示字段的值,包括:在第二时刻,获取到至少一个重复文件中目标重复文件的指示字段的值为第三值;
方法还包括:在目标重复文件的指示字段在第二时刻的值为第三值的情况下,确定在第一时刻至第二时刻的时段内,目标重复文件未被修改。
在一种可能的设计中,多个候选重复文件包括第三文件;
在第一时刻之后,方法还包括:检测到第三文件被修改,将第三文件的指示字段的值修改为第二值;
在第二时刻,获取到第三文件的指示字段的值不是第三值;
确定在第一时刻至第二时刻的时段内,第三文件被修改。
在一种可能的设计中,多个候选重复文件包括第四文件;
在第一时刻,尝试将多个候选重复文件中每个候选重复文件的指示字段的值修改为第三值,包括:若第四文件不满足第一条件,则不将第四文件的指示字段修改为第三值;
方法还包括:在不能成功将第四文件的指示字段的值修改为第三值时,确定在第一时刻至第二时刻的时段内,第四文件被修改。
在一种可能的设计中,根据多个重复文件的指示字段在第三时刻的值,将多个重复文件中的部分重复文件压缩至同一存储空间,包括:
若多个重复文件中第一文件的指示字段在第三时刻的值为第三值,则对第一文件执行压缩;
或者,若多个重复文件中第一文件的指示字段在第三时刻的值不是第三值,则不对第一文件执行压缩。
示例性的,若多个重复文件中第一文件的指示字段在第三时刻的值为第三值,则对第一文件执行压缩;
或者,若多个重复文件中第一文件的指示字段在第三时刻的值不是第三值,则不对第一文件执行压缩。
示例性的,如图19,用户点击“压缩”按钮之后,手机执行去重之前,在t9时刻(第三时刻),手机管家应用再次查询各重复文件(英语语法1、3、4、计算机技术1、2)的U字段的值。经判断,英语语法3的U字段的值在t1时刻被成功设置为V1,但在t9时刻U字段的值为V0,则手机管家应用可以确定t1时刻至t9时刻这段时间内,英语语法3被修改过。同理,手机管家应用判断其他重复文件在t1-t9时刻是否被修改过。
如图19,由于英语语法3在t1-t9时段内被修改过,因此,其不再与英语语法1、4构成重复文件,手机管家应用不对英语语法3执行去重。反之,t1-t9时段内,英语语法1、4未被修改,则英语语法1、4仍构成重复文件,手机管家应用可以在t10时刻对英语语法1、4进行去重。
如此,通过在实际压缩去重之前,对文件是否为重复文件进行校验,能够降低误去重的概率,提升去重的精准度。
在一种可能的设计中,方法还包括:
将多个重复文件的信息存储在数据库中,重复文件的信息包括如下任一项或多项信息:重复文件的索引节点编号、重复文件的路径、重复文件的名称。
在一种可能的设计中,在目标重复文件的指示字段在第二时刻的值为第三值的情况下,确定在第一时刻至第二时刻的时段内,目标重复文件未被修改,包括:
在目标重复文件的指示字段的值为第三值的情况下,若目标重复文件的索引节点编号未发生改变,则确定在第一时刻至第二时刻的时段内,目标重复文件未被修改。
第三方面,提供一种文件处理装置,应用于电子设备或芯片系统,以应用于电子设备为例,电子设备存储有第一文件的指示字段,指示字段的初始值为第一值,指示字段在第一文件被修改时被电子设备修改为第二值;装置包括:
处理模块,用于:
在第一时刻,尝试将第一文件的指示字段的值修改为第三值;第三值与第一值不同;第三值与第二值不同;
若成功将第一文件的指示字段的值修改为第三值,则在第二时刻,获取指示字段的值;
根据第一文件的指示字段在第二时刻的值,判断在第一时刻至第二时刻的时段内,第一文件是否被修改。
在一种可能的设计中,尝试将第一文件的指示字段的值修改为第三值,包括:
若满足第一条件,则将指示字段的值修改为第三值;在第一条件下,电子设备的文件系统能够检测到在第一时刻至第二时刻的时段内,针对第一文件的修改操作。
在一种可能的设计中,处理模块,还用于在第一时刻之后,检测到第一文件被修改,将第一文件的指示字段的值修改为第二值。
根据第一文件的指示字段在第二时刻的值,判断在第一时刻至第二时刻的时段内,第一文件是否被修改,包括:
若第一文件的指示字段在第二时刻的值为第二值,则确定在第一时刻至第二时刻的时段内,第一文件被修改。
在一种可能的设计中,根据第一文件的指示字段在第二时刻的值,判断在第一时刻至第二时刻的时段内,第一文件是否被修改,包括:
若第一文件的指示字段在第二时刻的值为第三值,则确定在第一时刻至第二时刻的时段内,第一文件未被修改。
在一种可能的设计中,尝试将第一文件的指示字段的值修改为第三值,包括:若不满足第一条件,则不将指示字段修改为第三值;
处理模块,还用于在不能成功将第一文件的指示字段的值修改为第三值时,确定在第一时刻至第二时刻的时段内,第一文件被修改。
在一种可能的设计中,第一条件包括如下一项或多项条件:在第一时刻之前,第一文件未被映射到内存;在第一时刻之前,第一文件被映射到内存,但电子设备未对内存执行过写入操作。
在一种可能的设计中,处理模块,还用于:
扫描得到电子设备中的重复文件,重复文件包括第一文件和第二文件;第一文件存储在第一存储空间,第二文件存储在第二存储空间;
确定第一时刻至第二时刻的时段内,第一文件、第二文件未被修改;
该装置还包括显示模块,显示模块,用于显示第一界面;第一界面包括第一文件的信息以及第二文件的信息。
在一种可能的设计中,该装置还包括输入模块,输入模块,用于检测到用户在第一界面中输入的第一操作;
处理模块,用于根据输入模块检测到的第一操作,将第一文件以及第二文件压缩至同一存储空间。
在一种可能的设计中,该装置还包括存储模块。存储模块,用于在扫描电子设备中的重复文件之后,存储第一文件的标识和第二文件的标识。
在一种可能的设计中,第一文件的标识包括第一文件的第一索引节点编号;第二文件的标识包括第二文件的第二索引节点编号。
在一种可能的设计中,根据第一文件的指示字段在第二时刻的值,判断在第一时刻至第二时刻的时段内,第一文件是否被修改,包括:
若第一文件的指示字段在第二时刻的值为第三值,且第一文件的索引节点编号为第一索引节点编号,则确定在第一时刻至第二时刻的时段内,第一文件未被修改。
第四方面,提供一种文件处理装置,应用于电子设备或芯片系统,该装置包括:
显示模块,用于显示第二界面,第二界面包括扫描得到的电子设备中的多个重复文件;多个重复文件分别存储在电子设备的多个存储空间;
处理模块,用于响应于用户在第二界面上输入的操作,在第三时刻,获取多个重复文件中每个重复文件的指示字段,重复文件的指示字段的值用于指示重复文件是否被修改;
处理模块,还用于根据多个重复文件的指示字段在第三时刻的值,将多个重复文件中的部分重复文件压缩至同一存储空间。
在一种可能的设计中,每个重复文件的指示字段的初始值为第一值。
在一种可能的设计中,处理模块,还用于显示第二界面之前,扫描得到多个候选重复文件;多个候选重复文件包括多个重复文件;
处理模块,还用于在第一时刻,尝试将多个候选重复文件中每个候选重复文件的指示字段的值修改为第三值。
在一种可能的设计中,扫描得到多个候选重复文件,包括:
控制显示模块显示第三界面,第三界面包括第一控件;
检测到用户对第一控件的操作,扫描得到多个候选重复文件。
在一种可能的设计中,扫描得到多个候选重复文件,包括:
当电子设备空闲时,扫描得到多个候选重复文件。
在一种可能的设计中,处理模块,还用于在第一时刻之后,在第二时刻,获取至少一个重复文件的指示字段的值;
显示模块,还用于根据至少一个重复文件的指示字段在第二时刻的值,显示第二界面;第二界面中的多个重复文件为在第一时刻至第二时刻的时段内,修改状态是未被修改的文件。
在一种可能的设计中,尝试将多个候选重复文件中每个候选重复文件的指示字段的值修改为第三值,包括:
若多个候选重复文件中的至少一个候选重复文件满足第一条件,则将至少一个候选重复文件的指示字段的值修改为第三值;在第一条件下,电子设备的文件系统能够检测到在第一时刻至第二时刻的时段内,针对至少一个候选重复文件的修改操作。
在一种可能的设计中,在第二时刻,获取至少一个重复文件的指示字段的值,包括:在第二时刻,获取到至少一个重复文件中目标重复文件的指示字段的值为第三值;
处理模块,还用于在目标重复文件的指示字段在第二时刻的值为第三值的情况下,确定在第一时刻至第二时刻的时段内,目标重复文件未被修改。
在一种可能的设计中,多个候选重复文件包括第三文件;
处理模块,还用于:
在第一时刻之后,检测到第三文件被修改,将第三文件的指示字段的值修改为第二值;
在第二时刻,获取到第三文件的指示字段的值不是第三值;
确定在第一时刻至第二时刻的时段内,第三文件被修改。
在一种可能的设计中,多个候选重复文件包括第四文件;
在第一时刻,尝试将多个候选重复文件中每个候选重复文件的指示字段的值修改为第三值,包括:若第四文件不满足第一条件,则不将第四文件的指示字段修改为第三值;
处理模块,还用于在不能成功将第四文件的指示字段的值修改为第三值时,确定在第一时刻至第二时刻的时段内,第四文件被修改。
在一种可能的设计中,根据多个重复文件的指示字段在第三时刻的值,将多个重复文件中的部分重复文件压缩至同一存储空间,包括:
若多个重复文件中第一文件的指示字段在第三时刻的值为第三值,则对第一文件执行压缩;
或者,若多个重复文件中第一文件的指示字段在第三时刻的值不是第三值,则不对第一文件执行压缩。
在一种可能的设计中,存储模块,用于存储多个重复文件的标识,重复文件的标识包括重复文件的索引节点编号。
在一种可能的设计中,在目标重复文件的指示字段在第二时刻的值为第三值的情况下,确定在第一时刻至第二时刻的时段内,目标重复文件未被修改,包括:
在目标重复文件的指示字段的值为第三值的情况下,若目标重复文件的索引节点编号未发生改变,则确定在第一时刻至第二时刻的时段内,目标重复文件未被修改。
在上述任一方面的任一种可能的设计中,指示字段存储在电子设备的元数据区中。
在上述任一方面的任一种可能的设计中,第一文件的标识包括第一文件的第一索引节点编号;第二文件的标识包括第二文件的第二索引节点编号。
在上述任一方面的任一种可能的设计中,第一条件包括如下一项或多项条件:在第一时刻之前,重复文件未被映射到内存;在第一时刻之前,重复文件被映射到内存,但电子设备未对内存执行过写入操作。
附图说明
图1A为本申请实施例提供的重复文件扫描流程的一种示例图;
图1B为本申请实施例提供的i-mtime字段的一种示例图;
图2为本申请实施例提供的写接口方式的写操作的示意图;
图3为本申请实施例提供的写内存方式的写操作的示意图;
图4、图5为本申请实施例提供的写操作的另外的示意图;
图6为本申请实施例提供的电子设备的硬件结构示意图;
图7为本申请实施例提供的电子设备的软件结构示意图;
图8为本申请实施例提供的数据区、元数据区的示意图;
图9为本申请实施例提供的文件处理方法的示意图;
图10A为本申请实施例提供的界面示意图;
图10B、图10C为本申请实施例提供的场景示意图;
图11为本申请实施例提供的数据库的示意图;
图12为本申请实施例提供的文件被修改的场景示意图;
图13为本申请实施例提供的文件未被修改的场景示意图;
图14为本申请实施例提供的界面示意图;
图15为本申请实施例提供的V1设置失败的场景示意图;
图16为本申请实施例提供的文件被修改的场景示意图;
图17为本申请实施例提供的文件未被修改的场景示意图;
图18为本申请实施例提供的V1设置失败的场景示意图;
图19为本申请实施例提供的场景示意图;
图20为本申请实施例提供的界面示意图;
图21、图22为本申请实施例提供的装置的结构示意图。
具体实施方式
本申请的描述中所提到的术语“包括”和“具有”以及它们的任何变形,意图在于覆盖不排他的包含。例如包含了一系列步骤或单元的过程、方法、系统、产品或设备没有限定于已列出的步骤或单元,而是可选地还包括其他没有列出的步骤或单元,或可选地还包括对于这些过程、方法、产 品或设备固有的其它步骤或单元。
需要说明的是,本申请实施例中,“示例性的”或者“例如”等词用于表示作例子、例证或说明。本申请实施例中被描述为“示例性的”或者“例如”的任何实施例或设计方案不应被解释为比其它实施例或设计方案更优选或更具优势。确切而言,使用“示例性的”或者“例如”等词旨在以具体方式呈现相关概念。
在本申请的描述中,除非另有说明,“多个”的含义是指两个或两个以上。本文中的“和/或”仅仅是一种描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况。
为便于理解,下面先对本申请实施例可能涉及到的相关术语和概念进行介绍。
1、文件去重
一些场景中,文件系统中存在多个重复文件,该多个重复文件原本占用多份存储空间,经过去重后,多个重复文件只占用一份存储空间。重复文件,即内容完全相同文件。示例性的,如图1A,文件1和文件2构成重复文件,去重之前,文件1和文件2分别占用存储空间1、存储空间2。电子设备对文件1和文件2执行去重之后,文件1和文件指向同一块存储空间1,极大释放了电子设备的存储空间。一些方案中,电子设备可以扫描存储的重复文件。重复文件的扫描可包括初筛和二进制比对。其中,在初筛时,电子设备截选文件中的部分内容,通过读取该部分内容,得到一个值。如果两个文件的截选内容的值相同,电子设备初步认为这两个文件有可能是重复文件。之后,电子设备对这两个文件进行二进制比对,逐个字节比对这两个文件的全部内容,当二进制比对的结果一致时,说明两个文件是重复文件。
在另一些场景中,二进制比对还可以替换为其他用于确定重复文件的步骤,比如哈希值比对等,本申请实施例对重复文件的扫描流程的具体实现,不做限制。
2、i-mtime字段
根据文件在一段时间内是否被修改,可以将文件的修改状态分为两种,一种是在一段时间被被修改,一种是在一段时间内未被修改。
在一些方案中,电子设备可以设置i-mtime字段,i-mtime字段可用于表示文件最后一次被修改的时间。可选的,i-mtime字段通常可以存储在文件系统的元数据区中。具体的,i-mtime字段可以存储的元数据区的索引节点(inode)区。示例性的,文件1历史上被修改过三次,修改时间分别为2022-8-22(8:00)、2022-8-23(10:00)、2022-8-23(18:00),则如表1所示,文件1的i-mtime字段的字段值可以为2022-8-23(18:00)。类似的,文件2历史上被修改过两次,修改时间分别为2022-8-22(18:00)、2022-8-23(10:00),则如表1所示,文件2的i-mtime字段的字段值可以为2022-8-23(10:00)。
表1
在一些方案中,电子设备中的应用程序可以通过查询文件的i-mtime字段,获知该文件在一段时间内是否被修改过。作为一种可能的实现方式,应用程序分别在时间点1、时间点2查询文件的i-mtime字段,若两次查询到i-mtime字段的字段值一致,说明时间点1至时间点2期间内文件未被修改。反之,若两次查询到i-mtime字段的字段值不一致,说明时间点1至时间点2期间内文件被修改过。
示例性的,如图1B的(a),应用程序在10:00查询文件1的i-mtime字段,获知文件1最后一次被修改的时间为8:00,应用程序在12:00再次查询文件1的i-mtime字段,获知文件1最后一次被修改的时间为8:00。此种情况下,两次查询得到的字段值(用于表示文件最后一次被修改的时间)相同,应用程序可确定文件1在10:00-12:00期间内未被修改过。
再示例性的,如图1B的(b),应用程序在10:00查询文件1的i-mtime字段,获知文件1最后一次被修改的时间为8:00,应用程序在12:00再次查询文件1的i-mtime字段,获知文件1最后一次被修改的时间为11:00。此种情况下,两次查询得到的字段值不同,应用程序可确定文件1在10:00-12:00期间内被修改过。
3、写(write)接口
作为一种写文件的方式,电子设备可以通过写(write)接口执行写文件操作。此种写文件的方式,每次写操作,均会执行文件系统中的一段代码,文件系统可以修改文件的i-mtime字段,以便记录文件最后一次被修改的时间。示例性的,如图2,在t1时刻(10:00)调用写接口对文件1进行修改时,电子设备会执行文件系统中的代码,文件系统可以修改文件1的i-mtime字段,以标识文件1最后一次被修改的时间为10:00。类似的,在t2时刻(12:00)调用写接口对文件1进行修改时,电子设备会执行文件系统中的代码,文件系统可以修改文件1的i-mtime字段,以标识文件1最后一次被修改的时间为12:00。
4、mmap
作为写文件的另一方式,电子设备可以通过mmap接口,将文件映射到一定内存。后续,写文件时,可以通过写内存的方式对文件进行写操作。写内存,可以理解为向文件映射的内存中写入内容,相当于间接地向相应文件进行写入。此种写文件的方式,在对某个文件映射到相应内存之后,电子设备首次在该内存中写入时,会执行文件系统中的相关代码。在一些示例中,后续,在同一内存中写入时,有可能不再执行文件系统中的代码,以免陷入文件系统产生额外开销。
示例性的,如图3的(a),电子设备将文件2映射到内存2。如图3的(b),在t1时刻(10:00),电子设备通过mmap接口首次对内存2进行写操作,此时,电子设备执行文件系统中的相关代码对内存2进行写操作。因此,文件系统能够感知内存2关联的文件2被修改,并据此修改文件2的i-mtime字段,以标识文件2最后一次被修改的时间为10:00。
之后,仍如图3的(b),在t2时刻,电子设备通过mmap接口对内存2进行写操作。由于历史上曾对内存2进行写操作,为了避免频繁陷入文件系统导致的系统开销,在t2时刻电子设备不再陷入文件系统执行对内存2的写操作。
再示例性的,如图4,在t1时刻,电子设备将文件映射到某块内存。之后,在t2时刻(10:05),电子设备向内存中写入内容,相当于向内存映射的文件中写入相应内容。由于此次写入是向该内存中的首次写入,因此,会执行文件系统中的相关代码,文件系统可以感知文件被修改,并修改该文件的i-mtime字段,以标识该文件最后一次被修改的时间为10:05。之后,在t3时刻(10:06),电子设备中的某个应用程序查询文件的i-mtime字段。在t4时刻(10:07),电子设备第二次向同一块内存中写入内容,且为了频繁陷入文件系统,电子设备本次写内存时并未陷入文件系统中的代码。因此,文件系统不能感知该内存关联的文件被修改,相应的没有修改文件的i-mtime字段。t5时刻,应用程序再次查询文件的i-mtime字段。由于t5、t3时刻查询到i-mtime字段的字段值均为10:05,则电子设备误认为t3-t5时段内(即10:05-10:07期间)文件未被修改。
可见,某些场景中,通过mmap方式执行写操作时电子设备不会陷入文件系统,导致文件系统无法感知文件被修改,无法跟踪文件的修改,无法及时更新i-mtime字段的字段值,导致电子设备对文件是否修改这一事件进行误判。
5.修改系统时间导致文件修改状态的误判
在一些场景中,无论是通过写接口还是mmap接口执行写操作,在系统时间被修改的情况下,均可能对文件的修改状态进行误判。示例性的,如图5,在t1时刻(10:00),文件被修改。之后,在t2时刻,电子设备中的某个应用程序查询文件的i-mtime字段,获知文件最后一次被修改的时间为10:00。在t3时刻,电子设备的系统时间被修改,比如由10:30修改为9:30。之后,t4时刻(修改系统时间后为10:00),文件再次被修改。t5时刻,应用程序再次查询文件的i-mtime字段。由于t5、t3时刻查询到i-mtime字段的字段值均为10:00,则电子设备误认为t3-t5时段内(即10:05-12:00期间)文件未被修改。
这里,系统时间可以是用户修改的,也可以是系统自动修改的。
可见,由于系统时间被修改,可能致使两次修改文件时的系统时间相同,进而使得电子设备对文件是否被修改这一事件进行误判,无法满足电子设备精准判断文件是否被修改的业务需求,即,不能可靠的判断文件的修改状态,电子设备的性能较低。
6、inotify
在一些方案中,还可以通过inotify机制监听文件是否被修改。应用程序可以通过inotify接口通知文件系统需要监听文件的修改状态。后续,文件系统监听到文件被修改的事件,会通知该应用程序文件被修改。此种方式,要求应用程序在需要监听的时段内常驻运行,占用较多系统资源(比如内存资源),电子设备的开销较大。
可见,上述用于判断文件是否被修改的方案,均不能使电子设备获得较好的性能。为解决上述技术问题,本申请实施例提供一种文件处理方法。该方法可适用于电子设备。例如,本申请实施例中的电子设备可通过图6中的电子设备来实现。图6所示为本申请实施例提供的电子设备的硬件结构示意图。该电子设备200包括至少一个处理器201,存储器202以及至少一个收发器203。
处理器201可以是一个通用中央处理器(central processing unit,CPU),微处理器,特定应用集成电路(application-specific integrated circuit,ASIC),或一个或多个用于控制本申请方案程序执行的集成电路。
上述各组件之间可包括通信线路,用于在上述组件之间传送信息。
收发器203,用于与其他设备通信。在本申请实施例中,收发器可以是模块、电路、总线、接口或者其它能实现通信功能的装置,用于与其他设备通信。可选的,该收发器可以为独立设置的发送器,该发送器可用于向其他设备发送信息,该收发器也可以为独立设置的接收器,用于从其他设备接收信息。该收发器也可以是将发送、接收信息功能集成在一起的部件,本申请实施例对收发器的具体实现不做限制。
存储器202可以是只读存储器(read-only memory,ROM)或可存储静态信息和指令的其他类型的静态存储设备,随机存取存储器(random access memory,RAM)或者可存储信息和指令的其他类型的动态存储设备,也可以是电可擦可编程只读存储器(electrically erasable programmable read-only memory,EEPROM)、只读光盘(compact disc read-only memory,CD-ROM)或其他光盘存储、光碟存储(包括压缩光碟、激光碟、光碟、数字通用光碟、蓝光光碟等)、磁盘存储介质或者其他磁存储设备、或者能够用于携带或存储具有指令或数据结构形式的期望的程序代码并能够由计算机存取的任何其他介质,但不限于此。存储器可以是独立存在,通过通信线路与处理器相连接。存储器也可以和处理器集成在一起。
其中,存储器202用于存储用于实现本申请方案的计算机执行指令,并由处理器201来控制执行。处理器201用于执行存储器202中存储的计算机执行指令,从而实现本申请下述实施例提供的各个方法。
可选的,本申请实施例中的计算机执行指令也可以称之为应用程序代码、指令、计算机程序或者其它名称,本申请实施例对此不作具体限定。
在具体实现中,作为一种实施例,处理器201可以包括一个或多个CPU。
在具体实现中,作为一种实施例,电子设备200可以包括多个处理器。这些处理器中的每一个可以是一个单核(single-CPU)处理器,也可以是一个多核(multi-CPU)处理器。这里的处理器可以指一个或多个设备、电路、和/或用于处理数据(例如计算机程序指令)的处理核。
如图6所示为电子设备的示例性结构图。应该理解的是,图示电子设备仅是一个范例,并且在实际应用中电子设备可以具有比图6中所示出的更多的或者更少的部件,可以组合两个或更多的部件,或者可以具有不同的部件配置。
电子设备的软件系统可以采用分层架构,事件驱动架构,微核架构,微服务架构,或云架构。例如,该电子设备的软件系统可以是系统等。本发明实施例以分层架构的Android系统为例,示例性说明电子设备的软件结构。
图7是本发明实施例的电子设备的软件结构框图。
分层架构将软件分成若干个层,每一层都有清晰的角色和分工。层与层之间通过软件接口通信。在一些实施例中,将Android系统分为五层,从上至下分别为应用程序层(简称应用层),应用程序框架层(简称框架层),安卓运行时(Android runtime)和系统库,硬件抽象层(Hardware Abstraction Layer,HAL)以及内核层。
(1)应用层
应用层可以包括一系列应用程序包。如图7所示,应用程序包可以包括相机,图库,日历,通话,地图,导航,无线局域网(wireless local area network,WLAN),蓝牙,音乐,视频,短信息等应用程序。
本申请实施例中,应用程序还可以包括设置、手机管家等应用。以手机管家应用为例,手机管家应用可以调用文件系统提供的接口修改相应文件的U字段的字段值。后续,手机管家应用可以根据U字段的字段值判断相应文件在一段时间内是否被修改过。
可选的,应用程序可以通过如下至少一种方式判断U字段的值。
第一种方式:可以由应用程序调用文件系统提供的第一接口,第一接口返回文件的U字段值。
第二种方式:应用程序调用文件系统提供的第二接口,文件系统在执行过程中判断文件的U字段值,并根据U字段值判断是否要继续执行第二接口的剩余步骤。
可选的,上述应用程序可以是运行在用户态的应用程序。
运行在“用户态”的应用程序可被称为“用户态程序”。比如,畅连通信、智慧生活等应用程序均为用户态程序。在一些情况下,用户态程序需要使用操作系统提供的一些功能(诸如读取文件内容),此时,用户态程序会调用操作系统提供的应用编程接口(application programming interface,API),从用户态陷入内核态执行操作系统内核提供的函数。
(2)框架层
框架层为应用层的应用程序提供API和编程框架。框架层包括一些预先定义的函数。
如图7所示,框架层可以包括活动管理器,窗口管理器,内容提供器,视图系统,电话管理器,资源管理器,通知管理器等。
其中,活动管理器,用于负责所有APP进程的启动,APP四大组件(如活动activity、服务service、广播接收者broadcast receiver、内容提供者content provider)的启动,APP之间及APP内部界面之间切换和各种组件的生命周期。窗口管理器用于管理窗口程序。窗口管理器可以获取显示屏大小,判断是否有状态栏,锁定屏幕,截取屏幕等。内容提供器用来存放和获取数据,并使这些数据可以被应用程序访问。所述数据可以包括视频,图像,音频,拨打和接听的电话,浏览历史和书签,电话簿等。视图系统包括可视控件,例如显示文字的控件,显示图片的控件等。视图系统可用于构建应用程序。显示界面可以由一个或多个视图组成的。例如,包括短信通知图标的显示界面,可以包括显示文字的视图以及显示图片的视图。电话管理器用于提供电子设备的通信功能。例如通话状态的管理(包括接通,挂断等)。资源管理器为应用程序提供各种资源,比如本地化字符串,图标,图片,布局文件,视频文件等等。通知管理器使应用程序可以在状态栏中显示通知信息,可以用于传达告知类型的消息,可以短暂停留后自动消失,无需用户交互。比如通知管理器被用于告知下载完成,消息提醒等。通知管理器还可以是以图表或者滚动条文本形式出现在系统顶部状态栏的通知,例如后台运行的应用程序的通知,还可以是以对话窗口形式出现在屏幕上的通知。例如在状态栏提示文本信息,发出提示音,电子设备振动,指示灯闪烁等。
3、Android Runtime和系统库
如图7所示,Android Runtime负责安卓系统的调度和管理。
系统库可以包括多个功能模块。例如:表面管理器(surface manager),媒体库(Media Libraries),三维图形处理库(例如:OpenGL ES),2D图形引擎(例如:SGL)等。
其中,表面管理器用于对显示子系统进行管理,并且为多个应用程序提供了2D和3D图层的融合。媒体库支持多种常用的音频,视频格式回放和录制,以及静态图像文件等。媒体库可以支持多种音视频编码格式,例如:MPEG4,H.264,MP3,AAC,AMR,JPG,PNG等。三维图形处理库用于实现三维图形绘图,图像渲染,合成,和图层处理等。2D图形引擎是2D绘图的绘图引擎。
(4)内核层
内核层是硬件和软件之间的层。
在本申请实施例中,内核层可以包括文件系统。文件系统是操作系统内核的核心模块,也即主要组成部分之一。文件系统负责管理和存储文件信息,主要是为用户建立文件,存入、读出、修改、转储文件,控制文件的存取,当用户不再使用时撤销文件等。
在一些实施例中,文件系统可运行在内核态。
运行在“用户态”的应用程序可被称为“用户态程序”。比如,畅连通信、智慧生活等应用程序均为用户态程序。在一些情况下,用户态程序需要使用操作系统提供的一些功能(诸如读取文件内容),此时,用户态程序会调用操作系统提供的应用编程接口(application programming interface,API),从用户态陷入内核态执行操作系统内核提供的函数。
文件系统中的数据可包括元数据以及数据。其中,元数据用来描述文件的特征、属性。可选的,元数据包括但不限于如下信息:文件系统的控制信息、数据结构、文件的描述信息,例如文件长度、文件类型等。文件类型例如为普通文件(regular inode)、目录文件(directory inode)、软链接(symbol link inode)、特殊文件(special inode)等。
可选的,文件的元数据和数据可以存储在存储设备(比如硬盘)中。如图8,存储设备的存储 区域可包括元数据区以及数据区。
文件的数据可以存储在存储设备的数据区。可选的,数据区中存储的数据可以是基于无损压缩技术进行文件级别的压缩处理后得到的数据。数据区中的数据在存储介质(例如为磁盘、闪存等)的物理存储空间上按照磁盘块的集合来进行存储。其中,同一文件的数据可以在连续的磁盘块中存储,或者,也可以在不连续的磁盘块中交叉存储。
应理解,本申请中引入磁盘块的概念并不意味着存储介质仅限定为磁盘,磁盘块可以用来表示存储介质的物理存储空间经划分后得到的小的物理存储空间。
如图8,数据存储位置可以用数据所在块(block)的索引表示。比如图8中,文件存储在块909、912、914中。元数据区可以存储该文件的块索引909、912、914。后续,对文件执行诸如读写操作时,电子设备可以从元数据区读取文件所在块的索引,并根据索引,在相应块的位置对文件进行访问(比如读取)。
在一些实施例中,文件系统可以为用户态程序提供用于读写文件的接口。作为第一种可能的实现方式,文件系统提供读写接口(例如:read,write),用户态程序调用读、写接口对文件进行读、写处理。
作为第二种可能的实现方式,文件系统提供内存映射接口(例如:mmap),用户态程序调用内存映射接口,将文件映射到内存,并获取映射后的内存地址。之后,用户态程序可以通过内存访问的方式对文件进行访问,比如,通过写内存的方式对文件进行写操作。
在一些实施例中,对于上述第一种文件访问方法,由于每次文件访问的操作都会调用文件系统提供的接口,因此,文件系统可以感知到每次的访问文件操作。
对于上述第二种文件访问方法,对于建立映射后的第一次文件访问(比如第一次写内存),会产生内存缺页,此时会调用文件系统的函数,故文件系统知道用户态程序对文件进行了访问。而后续的访问(比如后续的写内存)不一定会产生内存缺页,故文件系统可能无法感知用户态程序对文件进行了修改。
本申请实施例中,如图8所示,文件系统可以在元数据区中新增unmodified字段(可简称U字段),U字段可指示相应文件是否被修改。每个文件具有对应的U字段。
可选的,文件系统可以设置U字段的初始值。比如,初始值设置为V0。
文件系统可以向应用程序提供接口,应用程序可调用该接口修改U字段的字段值(比如修改为V1)。后续,应用程序可以根据U字段的字段值判断相应文件是否被修改。
如下,以电子设备为手机为例,对本申请实施例的技术方案进行详细介绍。如下,首先以文件去重场景为例进行说明。
实施例一
如图9,本申请实施例的技术方案可包括如下步骤:
S 101、文件系统将第一文件的U字段的值设置为V0。
可选的,U字段可保存在文件系统的元数据区中。
S 102、第一时刻,应用程序调用文件系统的接口,尝试将第一文件的U字段的值修改为V1。
示例性的,如图10A的(a)所示,手机显示手机管家应用的界面901,界面901可包括“清理加速”按钮902。检测到用户点击“清理加速”按钮902之后,手机可以扫描手机中存储的待清理的数据。待清理的数据可包括多个重复文件,即内容完全相同的多个文件。
在一些实施例中,手机管家应用扫描多个重复文件的过程中,手机管家应用调用文件系统的接口,以尝试将多个重复文件各自对应的U字段的字段值由初始值V0修改为V1。可选的,扫描重复文件的过程可包括初筛和二进制比对。手机管家应用可以在初筛得到初步被识别为重复文件的文件(可简称为候选重复文件)之后,二进制比对之前调用文件系统的接口,尝试将各候选重复文件的U字段的值修改为V1。
示例性的,如图12,在t6时刻,用户点击“清理加速”按钮之后,手机可以执行重复文件的初筛,初筛完成后,初步识别英语语法1-4为一组候选重复文件,计算机技术1、2为一组候选重复文件。以尝试将候选重复文件中英语语法2的U字段值修改为V1为例,用户点击“清理加速”按钮,手机执行重复文件的初筛之后,在t 1时刻(第一时刻),手机管家应用调用文件系统的接口,尝试将英语语法2对应的U字段的字段值由V0修改为V1。在图12的示例中,由于t 1时刻之前,手机未执行过针对英语语法2的mmap,满足第一条件,手机管家应用可以成功将英语语法2的U字 段的值由V0修改为V1。
同理,手机管家应用可以尝试将其他候选重复文件(即初步被识别为重复文件的文件)的U字段的值修改为V1。
作为一种可能的实现方式,应用程序想要将第一文件的U字段置为V1时,可以调用文件系统的接口向文件系统发送请求消息,该请求消息用于请求将第一文件的U字段的初始值修改为V1。
可选的,V1可以由应用程序指定,也可以由文件系统指定。
在一些实施例中,文件系统从应用程序接收请求消息之后,判断是否满足修改该文件的U字段的值的第一条件,在满足第一条件时,文件系统可以将第一文件的U字段的值修改为V1。反之,在不满足第一条件时,文件系统不将第一文件的U字段的值修改为V1。
可选的,第一条件包括:该文件是否已被映射到内存(例如,应用程序已使用mmap()对文件进行映射)。
示例性的,如图15,t1时刻之前,手机已将计算机技术1这一文件映射到内存,不满足第一条件,则在t1时刻,手机管家应用不会成功将计算机技术1的U字段的字段值由V0修改为V1。
图10B示出了初筛得到的部分候选重复文件。经初筛,手机管家应用初步识别出英语语法1-5为一组候选重复文件,计算机技术1-4为一组候选重复文件。在t1时刻,手机管家应用可以调用文件系统的接口,以尝试将各候选重复文件的U字段的值修改为V1。示例性的,表2示出了t1时刻之后,各候选重复文件的U字段的字段值。
表2
如表2,计算机技术1的U字段的字段值仍为初始值V0,一个可能的原因是在t1时刻之前,手机已将计算机技术1这一文件映射到内存。其他文件,诸如英语语法1-4、计算机技术2,的U字段的字段值均被手机管家应用修改为V1,说明t1时刻之前,手机未将这几个文件映射到内存。
可选的,在满足第一条件的情况下,文件系统向应用程序返回设置成功的返回消息,应用程序可据此确定该文件的U字段的值已被修改为V1。
可选的,在不满足第一条件的情况下,文件系统向应用程序返回设置失败的返回消息,应用程序可据此确定该文件的U字段的值未被设置为V1(仍为V0)。
S103、检测到第一文件被修改,文件系统将第一文件的U字段的值修改为V2。
在一些场景中,用户可以对文件进行修改。比如,如图12,假设t1时刻之前,手机未执行过针对英语语法2的写内存操作。t3时刻,响应于用户对英语语法2的修改意图,手机针对英语语法2进行首次写内存。具体的,手机对英语语法2进行首次写内存操作,必定会执行文件系统中的相关代码。如此,在t3时刻,文件系统能够感知英语语法2被修改,并将英语语法2的U字段由V1修改为V2。
可选的,文件系统还可以在元数据区中存储文件的修改时间。如图12,文件系统可以将t3存储到元数据区中。后续,应用程序可以根据元数据区存储的修改时间,确定文件的修改时间。
S104、应用程序判断第一文件的U字段的值是否被成功设置为V1。若第一文件的U字段的值被设置为V1,则执行如下步骤S106-S110。若第一文件的U字段的值未被设置为V1,则执行步骤S111。
可选的,应用程序可以从文件系统接收返回消息,该返回消息用于指示第一文件的U字段的值是否被成功设置为V1。
应理解,应用程序将某个重复文件的U字段的值成功设置为V1,意味着,手机在t1时刻之前未将该文件映射到内存。此种情况下,后续手机可以将该文件映射到内存,并且,若采用写内存方 式对该文件进行修改,则手机必定会在首次对该文件进行写内存时,执行文件系统中的相关代码。如此,文件系统能够感知该文件被修改,并修改该文件的U字段的值(比如由V1修改为V2)。手机可以根据该文件的U字段的值(V2)确定该文件被修改过。反之,若手机后续未对该文件进行修改,则该文件的U字段的值仍为V1。手机可以根据该文件的U字段的值(V1)确定该文件未被修改。
其中,V2与V1的值不同。在一些实现方式中,V2可以等于V0。
或者,后续若采用write接口方式对该文件进行修改,则手机每次写操作时同样会执行文件系统的相关代码,文件系统仍能感知到该文件被修改,并修改该文件的U字段的值(V2)。反之,若手机后续未对该文件进行修改,则该文件的U字段的值仍为V1。手机可以根据该文件的U字段的值(V1)确定该文件未被修改。
简言之,在应用程序能够在第一时刻成功将文件的U字段的值设置为V1的情况下,无论后续采用写内存方式或write接口方式对文件进行修改,手机均可以根据文件的U字段值后续(比如第二时刻)是否发生变化,精准地判断文件实际上是否被修改。
反之,应用程序未能成功将某个文件的U字段的值设置为V1(仍为V0),意味着,手机此前已将该文件映射到内存。此种情况下,若后续采用写内存(未必是首次写内存)方式对该文件进行修改,为降低开销,手机未必会执行文件系统中的相关代码,文件系统无法跟踪该文件的修改事件,也就无法在文件被修改时更新文件的U字段的值。比如,在文件被修改的情况下,文件系统可能未感知到文件被修改,因此,并未更新文件的U字段的值。再比如,文件未被修改的情况下,文件系统也不会更新文件的U字段的值。这样,无论文件是否被修改,文件的U字段的值均是V0(不会被文件系统更新为V2),手机无法根据U字段的值,判断文件是否被修改。
考虑到应用程序在第一时刻未能成功将某个文件的U字段的值设置为V1的情况下,文件系统未必能感知到文件被修改,进而文件系统未必及时更新文件的U字段的值,导致手机后续在第二时刻无法根据U字段的值判断该文件是否被修改。此种情况下,为了避免数据被误去重,手机可以执行后续步骤S109,确定第一文件不是重复文件,以免对第一文件进行误去重。
在一些实施例中,应用程序缺少相应权限时,也可能导致无法成功将文件的U字段的值由V0修改为V1。本申请实施例中,经过用户授权的系统应用具有修改U字段的权限,以降低误判风险。
或者,在一些实施例中,在缺少存储空间时,应用程序可能无法成功将文件的U字段的值修改为V1。
S105、第二时刻,应用程序查询第一文件的U字段的值。
在一些实施例中,若第一时刻成功将某些候选重复文件(初步被识别为重复文件的文件)的U字段的值修改为V1,则手机可以对这些候选重复文件进行二进制比对,以便确定最终的重复文件。
示例性的,如图10B,t6时刻,用户点击“清理加速”按钮,触发手机执行候选重复文件的初筛,初筛得到候选重复文件包括英语语法1-5这组候选重复文件的,以及计算机技术1-4这组候选重复文件。t1时刻,手机管家应用尝试将各候选重复文件的U字段的值设置为V1。假设,在t1时刻,英语语法1-4,计算机技术2-4的U字段的值均被成功设置为V1,则手机管家应用可以对应用语法1-4这组候选重复文件,以及计算机技术2-4这组候选重复文件进行二进制比对,以确定最终的重复文件。经二进制比对,英语语法1-4构成一组重复文件。计算机技术2-4构成一组重复文件。
在一些实施例中,手机可以将重复文件的信息存储到重复文件信息库中。可选的,重复文件信息库中可以存储重复文件的标识。如图11,重复文件信息库可以包括英语语法1-4这组重复文件中每个重复文件的标识,以及计算机技术2-4这组重复文件中每个重复文件的标识。可选的,重复文件的标识包括但不限于:重复文件的名称、重复文件的索引节点编号(inode number)、重复文件的U字段的值在第一时刻是否被成功设置为V1。其中,文件的索引节点编号用于唯一标识一个文件。内容不同的文件,其索引节点编号不同。
在一些实施例中,扫描得到各重复文件之后,向用户呈现重复文件的扫描结果之前,在第二时刻,应用程序可以查询各重复文件的U字段的值,并根据各重复文件的U字段在第二时刻的值,判断各重复文件在第一时刻至第二时刻期间是否被修改过。
作为一种可能的实现方式,应用程序自己查询文件的U字段的值。或者,应用程序向文件系统发送查询请求,由文件系统查询文件的U字段的值,并向应用程序返回文件的U字段的值。
以判断重复文件中英语语法2的修改状态为例,如图12,初筛完成之后,在t1时刻,初步被识别为重复文件(候选重复文件)的英语语法2的U字段的值被成功设置为V1。之后,手机管家对 各候选重复文件执行二进制比对,最终确定英语语法1-4构成一组重复文件,计算机计算2-4构成一组重复文件。在扫描得到各重复文件之后,向用户展示重复文件的扫描结果之前,在t5时刻,手机管家应用可以查询英语语法2的U字段的值,并根据t5时刻的U字段值判断在t1-t5这段时间内,英语语法2是否被修改。
S106、应用程序判断第一文件的U字段的值是否为V1。若U字段的值是V1,则执行如下步骤S107。若U字段的值不是V1,则执行如下步骤S108。
S107、应用程序确定第一文件未被修改。
示例性的,如图13,手机管家应用扫描完重复文件(二进制比对)之后,向用户显示扫描结果之前,在t5时刻,手机管家应用查询英语语法3这一重复文件的U字段的字段值,获知字段值为V1。由于英语语法3的U字段在t5时刻的字段值与在t1时刻的字段值相同,均为V1,则手机管家应用可以确定在t1时刻(t1时刻,手机管家应用调用文件系统的接口,尝试将英语语法3的U字段的字段值由V0修改为V1)至t5时刻期间内,英语语法3这一文件未被修改过。
同理,手机管家应用可以查询英语语法1、3、4的U字段的字段值,如果英语语法1、3、4的U字段值均为V1,则说明文件系统未检测到英语语法1、3、4被修改。那么,手机管家应用可以确定在t1时刻至t5时刻期间内,英语语法1、3、4这三个文件同样未被修改过。因此,英语语法1、3、4仍构成重复文件,后续,手机管家应用可以对这组重复文件进行去重,以降低对存储空间的占用。
在一些实施例中,应用程序判断第一文件的索引节点编号以及第一文件的U字段在第二时刻的值,若第一文件的索引节点编号不变,且第一文件的U字段在第二时刻的值为V1,则确定在第一时刻至第二时刻的时段内,第一文件未被修改。
S108、应用程序确定第一文件被修改。
示例性的,如图12,手机管家应用执行完二进制比对,得到重复文件的扫描结果之后,向用户显示扫描结果之前,在t5时刻,手机管家应用可以从元数据区中读取英语语法2的U字段的字段值,获知字段值为V2。由于英语语法2的U字段在t5时刻的字段值与在t1时刻的字段值不同,则手机管家应用可以确定在t1时刻(t1时刻,手机管家应用请求文件系统将英语语法3的U字段的字段值由V0修改为V1)至t5时刻期间内,英语语法2这一文件可能曾被修改过。手机不再将英语语法2视为重复文件。这样一来,后续,手机管家应用不对英语语法2执行去重。
可选的,元数据区中还可以存储有英语语法2的修改时间t3,手机管家应用可以从元数据区中读取修改时间,并据此获知英语语法2的修改时间为t3。
与图4所示方案中,文件系统漏检诸如第二次的写内存操作,无法及时更新i-mtime字段,导致电子设备误认为在t3-t5时段内文件未被修改相比,采用本申请实施例的技术方案,对于某个文件来说,如果第一时刻前未将该文件映射到内存,则后续手机一旦在第一时刻至第二时刻期间内对该文件进行一次或多次写内存操作,其中的首次写内存操作必定会使得手机执行文件系统的相关代码。也就是说,第一时刻至第二时刻期间内的至少首次写内存操作会被文件系统检测到。如此,文件系统可以至少根据第一时刻至第二时刻期间内的至少首次写内存操作,确定该文件被修改。可见,本申请实施例中,文件系统无需检测每次写内存操作,即便文件系统存在漏检写内存操作的现象,文件系统也能根据检测到的一段时间内的至少首次写内存操作,确定文件被修改过。如此,能够提升电子设备的检测精度。
S109、应用程序确定第一文件不是重复文件。
上文已提及,在第一时刻,第一文件的U字段的值未被成功设置为V1,意味着,在第一时刻至第二时刻这段时间内,第一文件可能被修改(可能不再是重复文件),但文件系统未必能够检测到第一文件被修改。此种情况下,应用程序将第一文件视为已修改的文件,第一文件不再是重复文件。并且,应用程序不对第一文件执行去重处理,以免对实际上是非重复文件的第一文件进行误去重。
示例性的,如图15,假设t1时刻之前,手机针对候选重复文件中的计算机技术1执行过写内存操作,则重复文件的初筛完成后,在t1时刻,手机管家应用无法成功将计算机技术1的U字段的值修改为V1(U字段的值仍为V0)。此种情况下,手机管家应用可以不再对计算机技术1执行二进制比对。手机管家应用可以将计算机技术1视为已被修改过的文件(不再是重复文件),不再对计算机技术1执行去重,以免执行误去重。
在一些实施例中,手机管家应用确定各重复文件在t1-t5这段时间内的修改状态之后,可以向 用户呈现未被修改的一组或多组重复文件。如图10B,在t1-t5时段内,未被修改的文件包括:英语语法1、3、4、计算机技术2、3。即,英语语法1、3、4仍构成重复文件,计算机技术2、3仍构成重复文件。
如图10A的(b),在t2时刻,手机可以显示界面903。界面903可包括手机中重复文件对应的卡片905。如图10A的(b),根据卡片905,手机中存储有8组重复文件(包括英语语法1、3、4这组重复文件以及计算机计算2、3这组重复文件),重复文件总共占用229MB的存储空间。
在一些示例中,检测到用户点击“无损压缩”按钮904之后,手机可以显示如图10A的(c)所示界面906。界面906可呈现上述8组重复文件的详细信息。比如,如图10A的(c),界面906中呈现了第一组重复文件“英语语法1、英语语法3、英语语法4”的信息。界面906还呈现了第二组重复文件“计算机技术2、计算机技术3”的信息。响应于用户的诸如上滑操作等,界面906还可以呈现其他重复文件的信息。每组重复文件中的多个文件分别占用多个存储空间。比如,英语语法1-4各占用24MB的存储空间。
用户可以勾选某一组或多组重复文件,并点击压缩按钮907。手机可以根据用户的压缩/去重意图,将用户选择的一组或多组重复文件进行去重。比如,如图10A的(c),用户勾选英语语法这组重复文件,则手机可以根据用户的压缩意图,将英语语法1、3、4这一组文件进行去重。如图10C,去重之后,英语语法1、3、4仅占用一份存储空间(24MB),极大释放了手机的存储空间。
在一些实施例中,执行去重之后,电子设备在用户界面中仍可显示英语语法1、3、4这组文件,用户仍可正常打开、使用这组文件中的任意文件。相比于去重之前,去重之后,英语语法1、3、4占用的存储空间有所降低。
利用手机管家应用执行完去重处理之后,用户可以关闭手机管家应用。
可选的,上述提及的文件去重是文件压缩的一种可能的实现方式。文件压缩还可以有其他方式,本申请实施例不做限制。
本申请实施例的技术方案,针对不同类型的文件,有不同的方法来判断文件是否在一段时间内被修改过,以满足判断不同类型文件是否被修改的业务需求。
具体的,对于第一时刻之前未被映射到内存的文件1,电子设备可以在第一时刻将该文件1的U字段的值由初始值V0修改为V1。之后,在第二时刻,电子设备可以查询该文件1的U字段的值,并根据U字段的值判断该文件1是否被修改过。在一些情况下,第二时刻,若文件1的U字段的值是V1之外的其他值(比如V2),则电子设备可以确定在第一时刻至第二时刻这一时段内,该文件1被修改过。在另一些情况下,第二时刻,若文件1的U字段的值是V1,则电子设备可以确定在第一时刻至第二时刻这一时段内,该文件1未被修改过。
对于第一时刻之前已被映射到内存的文件2,电子设备在第一时刻不修改该文件2的U字段的值(U字段的值仍为初始值V0)。意味着,在第一时刻至第二时刻这段时间内,文件2可能被修改(可能不再是重复文件),但文件系统未必能够检测到文件2被修改。此种情况下,电子设备将文件2视为已修改的文件,文件2不再是重复文件。并且,应用程序不对文件2执行去重处理,以免对实际上是非重复文件的文件2进行误去重。
需要说明的是,上述V2也可以替换成其他非V1的值(例如V0)。本申请实施例对文件系统感知到文件被修改时,将U字段具体修改为何值,不做限制。
上述主要以应用程序为手机管家应用为例,对判断文件的修改状态的方法进行说明,应理解,应用程序还可以为其他任何可能的应用程序。比如,应用程序还可以为文件管理器等。文件管理器可以采用本申请实施例的技术方案判断在一段时间内,其目录下的文件是否被修改。
上述主要以用户主动触发手机扫描重复文件为例,在另一些实施例中,手机可以自行扫描手机中的重复文件,并对部分重复文件进行去重,以减少对存储空间的占用。以手机主动扫描重复文件、执行去重为例,示例性的,在时间点1,应用程序将文件A、B的U字段的值均修改为V1。在时间点2,应用程序读取文件A和B的内容,认为文件A和B是重复文件。在时间点3,文件A被修改,文件A的U字段的值被文件系统修改为V2。在时间点4,应用程序查询文件A、B的U字段的值,获知文件A的U字段的值为V1,文件B的U字段的值为V2,意味着,文件A已被修改,文件B未被修改,文件A、B不再是重复文件。因此,应用程序不对文件A、B执行去重。
再示例性的,在时间点1,应用程序将文件A、B的U字段的值均修改为V1。在时间点2,应用程序读取文件A和B的内容,认为文件A和B是重复文件。在时间点3,应用程序查询文件A、B的 U字段的值,获知文件A、B的U字段的值为V1,意味着,自时间点1开始,文件A、B均未被修改,文件A、B仍构成重复文件。因此,应用程序可以对文件A、B执行去重。
实施例二
本申请实施例还提供一种文件处理方法,该方法中,文件已被映射到内存,还可以包括如下两种情况:文件已被映射到内存,但电子设备未对文件映射的内存进行写入;文件已被映射到内存,且电子设备已对文件映射的内存进行写入。在上述两种情况下,电子设备可以采用不同方式判断文件是否被修改。如下,结合举例进行说明。
示例性的,如图16,初筛得到候选重复文件后,在t1时刻,应用程序想要将英语语法2这一文件的U字段的值修改为V1,则应用程序可以调用文件系统的接口向文件系统发送请求消息。经判断,该文件此前已被mmap(即已被映射到内存),但没有向该文件映射的内存中写入内容,那么,文件系统确定满足修改该文件的U字段的条件,进而可以将该文件的U字段的值由初始值V0修改为V1。之后,应用程序可以对英语语法3与其他候选重复文件进行二进制比对,以确定最终的重复文件。
之后,在t3时刻,电子设备首次对该文件映射的内存进行写操作,电子设备会调用文件系统的函数,故文件系统能够感知到此次对该文件的写操作。如图16,文件系统感知到对该文件的写操作之后,可以将该文件的U字段的值由V1修改为V2。
之后,如图16,在扫描得到多个重复文件之后(比如二进制比对之后),向用户展示重复文件的扫描结果之前,在t5时刻,应用程序查询该文件的U字段的值(V2),由于t5时刻查询得到的U字段的值与t1时刻U字段的值不同,因此,应用程序可确定在t1-t5时段内该文件被修改过。反之,如图17,在t5时刻,应用程序查询该文件的U字段的值(V1),由于t5时刻查询得到的U字段的值与t1时刻U字段的值相同,因此,应用程序可确定在t1-t5时段内该文件未被修改过。手机可以将t1-t5时段内未被修改过的重复文件展示给用户。比如,在t1-t5时段内,若重复文件中的英语语法1、3、4未被修改过,则手机可以在图10A的(c)所示界面中展示英语语法1、3、4的信息。
再示例性的,如图18,重复文件的初筛完成之后,t1时刻,应用程序想要将计算机技术1这一文件的U字段的值修改为V1,则应用程序可以调用文件系统的接口向文件系统发送请求消息。经判断,该文件此前已被mmap(即已被映射到内存),且已向该文件映射的内存中写入内容,那么,文件系统确定不满足修改该文件的U字段的条件,因此,文件系统不对该文件的U字段的值进行修改,该文件的U字段的值仍为V0。
当文件的U字段的值在t1时刻未被成功设置为V1时,意味着,在t1时刻至展示重构文件扫描结果的这段时间内,文件可能被修改(不再是重复文件),但文件系统未必能够检测到文件被修改。此种情况下,应用程序将文件视为已修改的文件,文件不再是重复文件。并且,应用程序不对该文件执行去重处理,以免对实际上是非重复文件的文件进行误去重。
在一些实施例中,可选的,在用户点击如图10A的(c)所示压缩按钮907之后,手机执行去重之前,手机管家应用向文件系统发送去重请求,文件系统可以再次检查各重复文件的U字段的值,以便进一步确定各重复文件自第一时刻开始是否被修改过。示例性的,如图19,用户点击“压缩”按钮之后,手机执行去重之前,在t9时刻,文件系统再次查询各重复文件(英语语法1、3、4、计算机技术1、2)的U字段的值。经判断,英语语法3的U字段的值在t1时刻被成功设置为V1,但在t9时刻U字段的值为V0,则手机可以确定t1时刻至t9时刻这段时间内,英语语法3被修改过。同理,手机判断其他重复文件在t1-t9时刻是否被修改过。
如图19,由于英语语法3在t1-t9时段内被修改过,因此,其不再与英语语法1、4构成重复文件,手机管家应用不对英语语法3执行去重。反之,t1-t9时段内,英语语法1、4未被修改,则英语语法1、4仍构成重复文件,手机管家应用可以在t10时刻对英语语法1、4进行去重。
可选的,在用户点击压缩按钮907之后,由文件系统检查文件的U字段的值,可确保检查U字段值和去重操作的原子性,即,检查U字段值,确定满足去重条件,到执行去重的这一过程中,文件不会被修改。
本申请实施例的技术方案,应用程序无需常驻运行。如此,能够在确保精准判断文件的修改状态的同时,降低系统开销。以上述去重场景为例,在需要清理手机中的重复文件时,用户打开手机管家应用,并点击“清理加速”按钮,触发手机执行重复文件扫描流程。之后,用户可以关闭手机 管家应用。后续,当手机剩余的存储空间不足,出现诸如卡顿现象时,用户可以再次打开手机管家应用,并点击“清理加速”按钮,手机可以根据历史上的重复文件扫描结果,以及部分重复文件的修改状态,重新确定手机中的重复文件,以降低重新扫描重复文件带来的资源消耗。
比如,如图10A的(c),用户打开手机管家应用后,手机管家应用扫描得到:英语语法1-4为一组重复文件,计算机技术1、计算机技术2为一组重复文件。手机可以将英语语法2-4这组重复文件的文件标识,以及计算机技术1、计算机技术2这组重复文件的文件标识存储在如图11所示的重复文件信息库中。
后续,手机的存储空间不足时,用户再次打开手机管家应用,并点击“清理加速”按钮902之后,手机管家应用可以查询如图11所示的重复文件信息库中,获知英语语法1-4这组历史上的重复文件,以及计算机技术2-4这组历史上的重复文件,并查询英语语法1-4、计算机技术2-4这几个重复文件的U字段值,以便根据各重复文件的U字段值判断各重复文件在一段时段内是否被修改过。
经判断,假设英语语法1、2被修改,计算机4被修改,英语语法3、英语语法4、计算机技术3、计算机技术2均未被修改。那么,手机管家应用可确定英语语法3、英语语法4仍构成重复文件,计算机技术3、计算机技术2仍构成重复文件。如图14,在t6时刻,手机管家应用可在界面906中显示上述几组重复文件。
可以看出,再次打开手机管家应用,确定手机中的重复文件的过程中,手机可以减少对部分文件的扫描(比如无需从相应内存中读取历史上重复文件的内容),极大降低了手机的运行消耗。
在一些实施例中,手机管家应用重新确定手机中的重复文件之后,可以更新诸如图11所示的重复文件信息库。
上述第一条件仅是示例,应理解,能够保证t1-t5时刻的写入操作被文件系统感知的条件,均可作为第一条件,反之,只要无法保证后续的写入被文件系统感知,第一条件就不满足。示例性的,作为另一种可行的实施例,可以判断该文件在第一时刻之前是否被mmap,且mmap是否具有写权限。若文件在第一时刻之前被mmap,但mmap不具有写权限,则确定满足第一条件。若文件在第一时刻之前被mmap,但mmap具有写权限,则确定不满足第一条件。
上述主要以去重场景为例进行说明,应理解,本申请实施例的技术方案还可以应用于其他场景中。
上述以用户点击“清理加速”按钮之后,手机执行重复文件的扫描为例进行说明,在另一些实施例中,手机还可以执行预扫描流程,在空闲时段执行重复文件的扫描,并存储扫描结果。换言之,上述实施例中的重复文件扫描流程,还可以是在手机空闲时(比如夜间)执行的扫描流程。比如,图12所示的初筛和二进制比对过程,可以在夜间预先执行。
示例性的,手机可以在夜间执行重复文件的扫描。假设扫描得到英语语法1-4为一组重复文件,并可以在扫描过程中,在t1时刻,尝试将英语语法1-4的U字段的值修改为V1。之后,如图10A的(a),用户在白天点击“清理加速”按钮902,手机可以查询英语语法1-4的U字段的值。假设英语语法1-4的U字段的值在t1时刻均被成功设置为V1,英语语法1、3、4的U字段的值当前仍为V1,则手机确定英语语法1、3、4自t1时刻开始未被修改过,这三个文件仍构成重复文件。手机可以在诸如图10A的(c)所示界面中展示这三个重复文件的信息。
通过在手机空闲时执行预扫描,可节约后续执行文件去重所需的时间,提高文件去重的效率,提升用户与电子设备之间的人机交互效率。
本申请实施例不限制电子设备执行重复文件预扫描的时机。电子设备可以在适当的场景执行重复文件的预扫描流程。比如,在夜间,在锁屏时长超过阈值时执行预扫描。
或者,在一些实施例中,电子设备也可以提供设置入口,使得用户可以设置执行预扫描的时机。示例性的,如图20,手机的设置界面20中显示开关201。当开关201被开启时,手机可以在空闲时执行预扫描。在另一些实施例中,手机还可以提供设置入口,使得用户可以设置预扫描的时机,比如,用户可以设置夜间或锁屏超过一定阈值时执行预扫描。
上述一个或多个界面均是示例性的,还可以有其他的界面设计方式,本申请对界面的具体设计方式不做限制。
需要说明的是,可以对上述多个实施例进行组合,并实施组合后的方案。可选的,各方法实施例的流程中的一些操作任选地被组合,并且/或者一些操作的顺序任选地被改变。并且,各流程的步骤之间的执行顺序仅是示例性的,并不构成对步骤之间执行顺序的限制,各步骤之间还可以是其 他执行顺序。并非旨在表明所述执行次序是可以执行这些操作的唯一次序。本领域的普通技术人员会想到多种方式来对本文所述的操作进行重新排序。另外,应当指出的是,本文某个实施例涉及的过程细节同样以类似的方式适用于其他实施例,或者,不同实施例之间可以组合使用。
此外,方法实施例中的某些步骤可等效替换成其他可能的步骤。或者,方法实施例中的某些步骤可以是可选的,在某些使用场景中可以删除。或者,可以在方法实施例中增加其他可能的步骤。
并且,上述各方法实施例之间可以单独实施,或结合起来实施。
可选的,电子设备还可以在其他时机、场景中判断V1是否设置成功。比如,每次查询文件的字段值之前,判断V1是否设置成功。
本申请另一些实施例提供了一种装置,该装置可以是上述电子设备(比如手机等)或服务器。该装置可以包括:显示屏、存储器和一个或多个处理器。该显示屏、存储器和处理器耦合。该存储器用于存储计算机程序代码,该计算机程序代码包括计算机指令。当处理器执行计算机指令时,装置可执行上述方法实施例中手机执行的各个功能或者步骤。该装置的结构可以参图6所示的电子设备(比如终端)。
其中,该装置的核心结构可以表示为图21所示的结构,装置包括:处理模块1301、输入模块1302、存储模块1303和显示模块1304。
处理模块1301,可包括中央处理器(CPU)、应用处理器(Application Processor,AP)或通信处理器(Communication Processor,CP)中的至少一个。处理模块1301可执行与用户电子设备的其他元件中的至少一个的控制和/或通信相关的操作或数据处理。具体地,处理模块1301可用于根据一定的触发条件,控制主屏上显示的内容。处理模块1301还用于将输入的指令或数据进行处理,并根据处理后的数据确定显示样式。
可选的,处理模块1301可以实现为诸如图6所示的处理器201。
输入模块1302,用于获取用户输入的指令或数据,并将获取到的指令或数据传输到电子设备的其他模块。具体地说,输入模块1302的输入方式可以包括触摸、手势、接近屏幕等,也可以是语音输入。例如,输入模块可以是电子设备的屏幕,获取用户的输入操作并根据获取到的输入操作生成输入信号,将输入信号传输至处理模块1301。
存储模块1303,可包括易失性存储器和/或非易失性存储器。存储模块用于存储用户终端设备的其他模块中的至少一个相关的指令或数据。
可选的,存储模块1303可以实现为诸如图6所示的存储器202。
显示模块1304,可包括例如液晶显示器(LCD)、发光二极管(LED)显示器、有机发光二极管(OLED)显示器、微机电系统(MEMS)显示器或电子纸显示器。用于显示用户可观看的内容(例如,文本、图像、视频、图标、符号等)。
可选的,还包括通信模块1305,用于支持个人终端(通过通信网络)与其他个人终端通信。例如,通信模块可经由无线通信或有线通信连接到网络,以与其他个人终端或网络服务器进行通信。无线通信可采用蜂窝通信协议中的至少一个,诸如,长期演进(LTE)、高级长期演进(LTE-A)、码分多址(CDMA)、宽带码分多址(WCDMA)、通用移动通信系统(UMTS)、无线宽带(WiBro)或全球移动通信系统(GSM)。无线通信可包括例如短距通信。短距通信可包括无线保真(Wi-Fi)、蓝牙、近场通信(NFC)、磁条传输(MST)或GNSS中的至少一个。
可选的,通信模块1305可以实现为诸如图6所示的收发器203。
需要说明的是,装置的各功能模块可执行上述方法实施例中的一个或多个步骤。
本申请实施例还提供一种芯片系统,如图22所示,该芯片系统包括至少一个处理器1401和至少一个接口电路1402。处理器1401和接口电路1402可通过线路互联。例如,接口电路1402可用于从其它装置(例如电子设备的存储器)接收信号。又例如,接口电路1402可用于向其它装置(例如处理器1401)发送信号。示例性的,接口电路1402可读取存储器中存储的指令,并将该指令发送给处理器1401。当所述指令被处理器1401执行时,可使得电子设备执行上述实施例中的各个步骤。当然,该芯片系统还可以包含其他分立器件,本申请实施例对此不作具体限定。
本申请实施例还提供一种计算机存储介质,该计算机存储介质包括计算机指令,当所述计算机指令在上述电子设备上运行时,使得该电子设备执行上述方法实施例中手机执行的各个功能或者步骤。
本申请实施例还提供一种计算机程序产品,当所述计算机程序产品在计算机上运行时,使得所 述计算机执行上述方法实施例中手机执行的各个功能或者步骤。
通过以上实施方式的描述,所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,仅以上述各功能模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能模块完成,即将装置的内部结构划分成不同的功能模块,以完成以上描述的全部或者部分功能。
在本申请所提供的几个实施例中,应该理解到,所揭露的装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅是示意性的,例如,所述模块或单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个装置,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是一个物理单元或多个物理单元,即可以位于一个地方,或者也可以分布到多个不同地方。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。
所述集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个可读取存储介质中。基于这样的理解,本申请实施例的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该软件产品存储在一个存储介质中,包括若干指令用以使得一个设备(可以是单片机,芯片等)或处理器(processor)执行本申请各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(read only memory,ROM)、随机存取存储器(random access memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。
以上内容,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何在本申请揭露的技术范围内的变化或替换,都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以所述权利要求的保护范围为准。

Claims (28)

  1. 一种文件处理方法,其特征在于,应用于电子设备,所述电子设备存储有第一文件的指示字段,所述指示字段的初始值为第一值,所述指示字段在所述第一文件被修改时被所述电子设备修改为第二值;所述方法包括:
    在第一时刻,尝试将所述第一文件的指示字段的值修改为第三值;所述第三值与所述第一值不同;所述第三值与所述第二值不同;
    若成功将所述第一文件的指示字段的值修改为所述第三值,则在第二时刻,获取所述指示字段的值;
    根据所述第一文件的指示字段在所述第二时刻的值,判断在所述第一时刻至所述第二时刻的时段内,所述第一文件是否被修改。
  2. 根据权利要求1所述的方法,其特征在于,所述指示字段存储在所述电子设备的元数据区中。
  3. 根据权利要求1或2所述的方法,其特征在于,所述尝试将所述第一文件的指示字段的值修改为第三值,包括:
    若满足第一条件,则将所述指示字段的值修改为所述第三值;在所述第一条件下,所述电子设备的文件系统能够检测到在所述第一时刻至所述第二时刻的时段内,针对所述第一文件的修改操作。
  4. 根据权利要求1-3任一项所述的方法,其特征在于,在所述第一时刻之后,所述方法还包括:
    检测到所述第一文件被修改,将所述第一文件的指示字段的值修改为所述第二值;
    根据所述第一文件的指示字段在所述第二时刻的值,判断在所述第一时刻至所述第二时刻的时段内,所述第一文件是否被修改,包括:
    若所述第一文件的指示字段在所述第二时刻的值为所述第二值,则确定在所述第一时刻至所述第二时刻的时段内,所述第一文件被修改,或者,若所述第一文件的指示字段在所述第二时刻的值不是所述第三值,则确定在所述第一时刻至所述第二时刻的时段内,所述第一文件被修改。
  5. 根据权利要求1-3任一项所述的方法,其特征在于,根据所述第一文件的指示字段在所述第二时刻的值,判断在所述第一时刻至所述第二时刻的时段内,所述第一文件是否被修改,包括:
    若所述第一文件的指示字段在所述第二时刻的值为所述第三值,则确定在所述第一时刻至所述第二时刻的时段内,所述第一文件未被修改,或者,若所述第一文件的指示字段在所述第二时刻的值不是所述第二值,则确定在所述第一时刻至所述第二时刻的时段内,所述第一文件未被修改。
  6. 根据权利要求1或2所述的方法,其特征在于,所述尝试将所述第一文件的指示字段的值修改为第三值,包括:若不满足第一条件,则不将所述指示字段修改为第三值;
    所述方法还包括:在不能成功将所述第一文件的指示字段的值修改为所述第三值时,确定在所述第一时刻至所述第二时刻的时段内,所述第一文件被修改。
  7. 根据权利要求3或6所述的方法,其特征在于,所述第一条件包括如下一项或多项条件:在所述第一时刻之前,所述第一文件未被映射到内存;在所述第一时刻之前,所述第一文件被映射到内存,但所述电子设备未对所述内存执行过写入操作。
  8. 根据权利要求1-7任一项所述的方法,其特征在于,所述方法还包括:
    扫描得到所述电子设备中的重复文件,所述重复文件包括所述第一文件和第二文件;所述第一文件存储在第一存储空间,所述第二文件存储在第二存储空间;
    确定所述第一时刻至所述第二时刻的时段内,所述第一文件、所述第二文件未被修改;
    显示第一界面;所述第一界面包括所述第一文件的信息以及所述第二文件的信息。
  9. 根据权利要求8所述的方法,其特征在于,检测到用户在所述第一界面中输入的第一操作;
    将所述第一文件以及所述第二文件压缩至同一存储空间。
  10. 根据权利要求8或9所述的方法,其特征在于,在扫描所述电子设备中的重复文件之后,所述方法还包括:
    存储所述第一文件的标识和所述第二文件的标识。
  11. 根据权利要求10所述的方法,其特征在于,所述第一文件的标识包括所述第一文件的第一索引节点编号;所述第二文件的标识包括所述第二文件的第二索引节点编号。
  12. 根据权利要求11所述的方法,其特征在于,根据所述第一文件的指示字段在所述第二时刻的值,判断在所述第一时刻至所述第二时刻的时段内,所述第一文件是否被修改,包括:
    若所述第一文件的指示字段在所述第二时刻的值为所述第三值,且所述第一文件的索引节点编 号为所述第一索引节点编号,则确定在所述第一时刻至所述第二时刻的时段内,所述第一文件未被修改。
  13. 一种文件处理方法,其特征在于,应用于电子设备,所述方法包括:
    显示第二界面,所述第二界面包括扫描得到的所述电子设备中的多个重复文件;所述多个重复文件分别存储在所述电子设备的多个存储空间;
    响应于用户在所述第二界面上输入的操作,在第三时刻,获取所述多个重复文件中每个重复文件的指示字段,所述重复文件的指示字段的值用于指示所述重复文件是否被修改;
    根据所述多个重复文件的指示字段在所述第三时刻的值,将所述多个重复文件中的部分重复文件压缩至同一存储空间。
  14. 根据权利要求13所述的方法,其特征在于,根据所述多个重复文件的指示字段在所述第三时刻的值,将所述多个重复文件中的部分重复文件压缩至同一存储空间,包括:
    若所述多个重复文件中第一文件的指示字段在所述第三时刻的值为第三值,则对所述第一文件执行压缩;
    或者,若所述多个重复文件中第一文件的指示字段在所述第三时刻的值不是第三值,则不对所述第一文件执行压缩。
  15. 根据权利要求13或14所述的方法,其特征在于,每个重复文件的指示字段的初始值为第一值。
  16. 根据权利要求13-15任一项所述的方法,其特征在于,显示第二界面之前,所述方法还包括:
    扫描得到多个候选重复文件;所述多个候选重复文件包括所述多个重复文件;
    在第一时刻,尝试将所述多个候选重复文件中每个候选重复文件的指示字段的值修改为第三值;
    对所述多个候选重复文件进行比对,以从所述多个候选重复文件中确定所述多个重复文件。
  17. 根据权利要求16所述的方法,其特征在于,确定所述多个重复文件之后,所述方法还包括:
    将所述多个重复文件的信息存储在数据库中,所述重复文件的信息包括如下任一项或多项信息:所述重复文件的索引节点编号、所述重复文件的路径、所述重复文件的名称。
  18. 根据权利要求16或17所述的方法,其特征在于,扫描得到所述多个候选重复文件,包括:
    显示第三界面,所述第三界面包括第一控件;
    检测到用户对所述第一控件的操作,扫描得到所述多个候选重复文件。
  19. 根据权利要求16或17所述的方法,其特征在于,扫描得到所述多个候选重复文件,包括:
    当所述电子设备空闲时,扫描得到所述多个候选重复文件。
  20. 根据权利要求16-19任一项所述的方法,其特征在于,尝试将所述多个候选重复文件中每个候选重复文件的指示字段的值修改为第三值,包括:
    若所述多个候选重复文件中的至少一个候选重复文件满足第一条件,则将所述至少一个候选重复文件的指示字段的值修改为所述第三值;在所述第一条件下,所述电子设备的文件系统能够检测到在所述第一时刻至所述第二时刻的时段内,针对所述至少一个候选重复文件的修改操作。
  21. 根据权利要求20所述的方法,其特征在于,在第二时刻,获取所述至少一个重复文件的指示字段的值,包括:在所述第二时刻,获取到所述至少一个重复文件中目标重复文件的指示字段的值为第三值;
    所述方法还包括:在所述目标重复文件的指示字段在所述第二时刻的值为第三值的情况下,确定在所述第一时刻至所述第二时刻的时段内,所述目标重复文件未被修改。
  22. 根据权利要求20所述的方法,其特征在于,所述多个候选重复文件包括第三文件;
    在所述第一时刻之后,所述方法还包括:检测到所述第三文件被修改,将所述第三文件的指示字段的值修改为第二值;
    在第二时刻,获取到所述第三文件的指示字段的值不是所述第三值;
    确定在所述第一时刻至所述第二时刻的时段内,所述第三文件被修改。
  23. 根据权利要求16-19任一项所述的方法,其特征在于,所述多个候选重复文件包括第四文件;
    所述在第一时刻,尝试将所述多个候选重复文件中每个候选重复文件的指示字段的值修改为第三值,包括:若所述第四文件不满足第一条件,则不将所述第四文件的指示字段修改为第三值;
    所述方法还包括:在不能成功将所述第四文件的指示字段的值修改为所述第三值时,确定在所述第一时刻至第二时刻的时段内,所述第四文件被修改。
  24. 根据权利要求20-23任一项所述的方法,其特征在于,所述第一条件包括如下一项或多项条件:在所述第一时刻之前,所述重复文件未被映射到内存;在所述第一时刻之前,所述重复文件被映射到内存,但所述电子设备未对所述内存执行过写入操作。
  25. 根据权利要求16-24任一项所述的方法,其特征在于,在第一时刻之后,所述方法还包括:
    在第二时刻,获取所述至少一个重复文件的指示字段的值以及所述至少一个重复文件的索引节点编号;
    当满足第三条件时,显示所述第二界面;所述第三条件包括:所述至少一个重复文件的指示字段在所述第二时刻的值为第三值,且,所述至少一个重复文件的索引节点编号与数据库中存储的索引节点编号一致。
  26. 根据权利要求13-25任一项所述的方法,其特征在于,所述指示字段存储在所述电子设备的元数据区中。
  27. 一种电子设备,其特征在于,包括:处理器以及存储器;
    所述存储器用于存储计算机执行指令,所述处理器与所述存储器耦接,当所述电子设备运行时,所述处理器执行所述存储器存储的所述计算机执行指令,以使所述电子设备执行如权利要求1-12中任一项所述的方法,或者,执行如权利要求13-26中任一项所述的方法。
  28. 一种计算机可读存储介质,所述计算机可读存储介质中存储有指令,其特征在于,当所述指令在电子设备上运行时,使得所述电子设备执行如权利要求1-12中任一项所述的方法,或者执行如权利要求13-26中任一项所述的方法。
PCT/CN2023/116818 2022-09-05 2023-09-04 文件处理方法及电子设备 Ceased WO2024051654A1 (zh)

Priority Applications (3)

Application Number Priority Date Filing Date Title
CN202380064000.5A CN119836627A (zh) 2022-09-05 2023-09-04 文件处理方法及电子设备
EP23862348.2A EP4528529A4 (en) 2022-09-05 2023-09-04 FILE PROCESSING METHOD AND ELECTRONIC DEVICE
US19/069,237 US20250321934A1 (en) 2022-09-05 2025-03-04 File processing method and electronic device

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202211095247.7A CN117648288B (zh) 2022-09-05 2022-09-05 文件处理方法及电子设备
CN202211095247.7 2022-09-05

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US19/069,237 Continuation US20250321934A1 (en) 2022-09-05 2025-03-04 File processing method and electronic device

Publications (1)

Publication Number Publication Date
WO2024051654A1 true WO2024051654A1 (zh) 2024-03-14

Family

ID=90045623

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2023/116818 Ceased WO2024051654A1 (zh) 2022-09-05 2023-09-04 文件处理方法及电子设备

Country Status (4)

Country Link
US (1) US20250321934A1 (zh)
EP (1) EP4528529A4 (zh)
CN (3) CN117648288B (zh)
WO (1) WO2024051654A1 (zh)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN120909998A (zh) * 2024-05-06 2025-11-07 云智能资产控股(新加坡)私人股份有限公司 文件系统中的对象处理方法、系统、设备、产品及介质

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP0774715A1 (en) * 1995-10-23 1997-05-21 Stac Electronics System for backing up files from disk volumes on multiple nodes of a computer network
CN108647317A (zh) * 2018-05-10 2018-10-12 东软集团股份有限公司 增量文件的生成方法、装置和存储介质以及电子设备
CN112783848A (zh) * 2021-01-20 2021-05-11 杭州数梦工场科技有限公司 一种数据同步方法、装置及电子设备
CN114116611A (zh) * 2020-08-29 2022-03-01 华为技术有限公司 一种文件扫描方法及相关装置
CN114880299A (zh) * 2021-02-05 2022-08-09 北京字跳网络技术有限公司 多媒体草稿文件同步方法、装置、设备和介质

Family Cites Families (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20140019497A1 (en) * 2010-02-22 2014-01-16 Asaf CIDON Modification of files within a cloud computing environment
US8504515B2 (en) * 2010-03-30 2013-08-06 Commvault Systems, Inc. Stubbing systems and methods in a data replication environment
US8516022B1 (en) * 2012-01-11 2013-08-20 Emc Corporation Automatically committing files to be write-once-read-many in a file system
CN105468686A (zh) * 2015-11-17 2016-04-06 北京奇虎科技有限公司 减少冗余数据的方法及装置
US10394794B2 (en) * 2015-11-30 2019-08-27 Open Text Sa Ulc Systems and methods for multi-file check-in
US10547576B1 (en) * 2016-04-04 2020-01-28 Google Llc Modifying presentation of message based on content identified by uniform resource locator (URL) in message
US11086545B1 (en) * 2018-03-23 2021-08-10 Tintri By Ddn, Inc. Optimizing a storage system snapshot restore by efficiently finding duplicate data
CN108874585B (zh) * 2018-05-25 2021-01-22 南京云信达科技有限公司 文件备份方法、装置及系统
CN108763582B (zh) * 2018-06-11 2023-04-21 腾讯科技(深圳)有限公司 文件搜索方法、装置、终端及存储介质
CN110059115B (zh) * 2019-03-19 2023-08-11 创新先进技术有限公司 一种数据读取方法和装置
CN114567674B (zh) * 2022-02-25 2024-03-15 腾讯科技(深圳)有限公司 一种数据处理方法、装置、计算机设备以及可读存储介质

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP0774715A1 (en) * 1995-10-23 1997-05-21 Stac Electronics System for backing up files from disk volumes on multiple nodes of a computer network
CN108647317A (zh) * 2018-05-10 2018-10-12 东软集团股份有限公司 增量文件的生成方法、装置和存储介质以及电子设备
CN114116611A (zh) * 2020-08-29 2022-03-01 华为技术有限公司 一种文件扫描方法及相关装置
CN112783848A (zh) * 2021-01-20 2021-05-11 杭州数梦工场科技有限公司 一种数据同步方法、装置及电子设备
CN114880299A (zh) * 2021-02-05 2022-08-09 北京字跳网络技术有限公司 多媒体草稿文件同步方法、装置、设备和介质

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
See also references of EP4528529A4

Also Published As

Publication number Publication date
EP4528529A1 (en) 2025-03-26
CN119513041A (zh) 2025-02-25
CN119836627A (zh) 2025-04-15
EP4528529A4 (en) 2025-10-08
CN117648288B (zh) 2024-09-17
CN117648288A (zh) 2024-03-05
US20250321934A1 (en) 2025-10-16

Similar Documents

Publication Publication Date Title
CN110162525B (zh) 基于b+树的读写冲突解决方法、装置及存储介质
KR102124231B1 (ko) 플레이스홀더 및 콘텐츠 스트리밍 기법
US12591706B2 (en) Open access token for determining that file is accessible to everyone
WO2022156484A1 (zh) 媒体数据处理方法、装置及终端设备
US20130227085A1 (en) Terminal and method for using cloud services
WO2020119491A1 (zh) 来电提醒方法及终端
CN108021590A (zh) 一种目标对象属性确定方法、属性更新方法及装置
US20140297586A1 (en) Device and method for cloud file management
WO2024078348A1 (zh) 应用移植环境下注册表操作的处理方法、装置和介质
US20250321934A1 (en) File processing method and electronic device
CN118120212A (zh) 一种文件去重方法、装置和设备
EP2686791B1 (en) Variants of files in a file system
CN114328007B (zh) 一种容器备份还原方法、装置及其介质
US20170091206A1 (en) Information Processing Method and Electronic Apparatus
WO2018107361A1 (zh) 镜像处理方法以及计算设备
CN108845772A (zh) 一种硬盘故障处理方法、系统、设备及计算机存储介质
CN105430314A (zh) 视频数据存储访问控制方法及装置
EP3073360A1 (en) Multi-media data backup method, user terminal and synchronizer
CN117708070B (zh) 一种文件压缩方法及电子设备
CN112286869A (zh) 一种快照创建方法及装置
CN119248737A (zh) 文件同步方法、电子设备及存储介质
CN118869879A (zh) 文件扫描方法、文件扫描装置和电子设备
US8990265B1 (en) Context-aware durability of file variants
CN108345431B (zh) 一种数据读取的方法及装置
US20110106861A1 (en) Interface Techniques Providing Contiguous Storage For Files

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 23862348

Country of ref document: EP

Kind code of ref document: A1

WWE Wipo information: entry into national phase

Ref document number: 2023862348

Country of ref document: EP

ENP Entry into the national phase

Ref document number: 2023862348

Country of ref document: EP

Effective date: 20241217

WWE Wipo information: entry into national phase

Ref document number: 202380064000.5

Country of ref document: CN

NENP Non-entry into the national phase

Ref country code: DE

WWP Wipo information: published in national office

Ref document number: 202380064000.5

Country of ref document: CN