CN112241395B - Application program file cleaning method and device, terminal equipment and storage medium - Google Patents

Application program file cleaning method and device, terminal equipment and storage medium Download PDF

Info

Publication number
CN112241395B
CN112241395B CN201910646199.8A CN201910646199A CN112241395B CN 112241395 B CN112241395 B CN 112241395B CN 201910646199 A CN201910646199 A CN 201910646199A CN 112241395 B CN112241395 B CN 112241395B
Authority
CN
China
Prior art keywords
file path
file
cleaned
path
time
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.)
Active
Application number
CN201910646199.8A
Other languages
Chinese (zh)
Other versions
CN112241395A (en
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.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen 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 Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN201910646199.8A priority Critical patent/CN112241395B/en
Publication of CN112241395A publication Critical patent/CN112241395A/en
Application granted granted Critical
Publication of CN112241395B publication Critical patent/CN112241395B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR 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/162Delete operations
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/61Installation
    • G06F8/62Uninstallation
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

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

Abstract

The invention provides a cleaning method, a device, a terminal device and a storage medium of an application program file, wherein the method is integrated in the application program, the application program acquires a file path to be cleaned under an installation path by calling the method, then judges whether a file path matched with the file path to be cleaned is contained in a reservation rule, and if so, continues to judge whether the storage time of a file corresponding to the file to be cleaned exceeds the corresponding storable time. And if the corresponding storable time is exceeded, or the retention rule does not contain the matched file path, deleting the file corresponding to the file to be cleaned. By adopting the scheme, the files under the installation directory of the application program can be cleaned uniformly, a software developer is not required to add corresponding file cleaning logic codes for the developed service modules, and the development burden of the software developer is reduced.

Description

Application program file cleaning method and device, terminal equipment and storage medium
Technical Field
The invention belongs to the technical field of computers, and particularly relates to a method and a device for cleaning application program files, terminal equipment and a storage medium.
Background
With the popularization of smart terminals (e.g., smart phones, tablet computers, personal PCs, etc.), applications based on smart terminals are layered endlessly, but the storage space of smart terminals cannot be expanded endlessly. This requires the application to be cleaned of unwanted files.
The current application program file cleaning scheme generally requires an application program developer to add cleaning logic of a file by himself according to the file service condition of a developed service when developing a service module. The cleanup logic of the files is spread across the code of the application program and is inconvenient to manage centrally. Moreover, if the developer of the application program forgets to add the relevant file cleaning logic during the development process, the phenomenon that the useless file permanently occupies the storage space may occur. Therefore, a solution that can uniformly clean up garbage within an application is needed.
Disclosure of Invention
In view of the above, the present invention aims to provide a method, a device, a terminal device and a storage medium for cleaning application files, so as to achieve the purpose of automatically cleaning application files, and the disclosed technical scheme is as follows:
in one aspect, the present invention provides a method for cleaning an application file, integrated in an application, where the method includes:
acquiring a file path to be cleaned under the installation path of the application program;
Judging whether a reservation rule comprises a file path matched with the file path to be cleaned or not, wherein the reservation rule comprises a file path corresponding to a file allowed to be stored and a storable time;
If the reservation rule does not contain the file path matched with the file path to be cleaned, deleting the file corresponding to the file path to be cleaned;
If the reservation rule contains a file path matched with the file path to be cleaned, judging whether the storage time of the file corresponding to the file path to be cleaned exceeds the corresponding storable time;
and if the storage time of the file corresponding to the file path to be cleaned exceeds the storable time, deleting the file corresponding to the file path to be cleaned.
In one possible implementation manner, the obtaining a file path to be cleaned under the installation path of the application program includes:
Acquiring a file directory tree of the application program;
and acquiring a file path to be cleaned under the installation path of the application program according to the file directory tree.
In one possible implementation manner, the determining whether the reservation rule includes a file path that matches the file path to be cleaned includes:
Judging whether the reservation rule contains a file path which is completely the same as the file path to be cleaned;
If the reservation rule contains the file path which is completely the same as the file path to be cleaned, determining the file path matched with the file path to be cleaned as the file path matched with the file path to be cleaned;
if the reservation rule does not contain the file path which is completely the same as the file path to be cleaned, judging whether the reservation rule contains the file path which is completely the same as the upper file path of the file path to be cleaned;
If the reservation rule contains the file path which is completely the same as the upper file path, determining that the file path matched with the file path to be cleaned is the file path which is completely the same as the upper file path;
and if the reservation rule does not contain the file path which is completely the same as the upper file path, determining that the reservation rule does not contain the file path which is matched with the file path to be cleaned.
In one possible implementation manner, if the reservation rule includes a file path that matches the file path to be cleaned, determining whether a storage time of a file corresponding to the file path to be cleaned exceeds a storable time includes:
If the reservation rule contains a file path matched with the file path to be cleaned, acquiring storable time corresponding to the file path matched with the file path to be cleaned;
acquiring the latest updating time of the file corresponding to the file path to be cleaned;
Judging whether the time difference between the current time and the latest updating time is larger than or equal to the storable time or not;
if the time difference value is smaller than the storable time, determining that the storage time of the file corresponding to the file path to be cleaned does not exceed the storable time;
And if the time difference value is larger than or equal to the storable time, determining that the storage time of the file corresponding to the file path to be cleaned exceeds the storable time.
In one possible implementation, the method further includes:
Determining whether the application is in a low power state;
And if the application program is in a low-power consumption state, executing the step of acquiring the file path to be cleaned under the installation path of the application program.
In one possible implementation, determining whether the application is in a low power consumption state includes:
When the application program detects that the application program runs in a system background, determining that the application program is in a low-power consumption state;
Or alternatively
And after the application program detects that the application program is in the idle state, determining that the application program is in a low-power consumption state.
On the other hand, the invention also provides a cleaning device for application program files, which is integrated in the application program and comprises
The acquisition module is used for acquiring a file path to be cleaned under the installation path of the application program;
The first judging module is used for judging whether a reservation rule comprises a file path matched with the file path to be cleaned or not, wherein the reservation rule comprises a file path corresponding to a file allowed to be stored and a storable time;
The second judging module is used for judging whether the storage time of the file corresponding to the file path to be cleaned exceeds the corresponding storable time when the file path matched with the file path to be cleaned is contained in the reservation rule;
And the deleting module is used for deleting the file corresponding to the file path to be cleaned when the file path matched with the file path to be cleaned is not contained in the reservation rule or when the storage time of the file corresponding to the file path to be cleaned exceeds the storable time.
In one possible implementation manner, the first determining module includes:
the first judging submodule is used for judging whether the reservation rule contains a file path which is completely the same as the file path to be cleaned;
the first determining submodule is used for determining that the file path matched with the file path to be cleaned is the file path matched with the file path to be cleaned when the file path which is completely the same as the file path to be cleaned is contained in the reservation rule;
The second judging submodule is used for judging whether the reservation rule contains a file path which is completely the same as a superior file path of the file path to be cleaned or not when the reservation rule does not contain the file path which is completely the same as the file path to be cleaned;
The second determining submodule is used for determining that the file path matched with the file path to be cleaned is the file path which is completely the same as the upper file path when the reservation rule contains the file path which is completely the same as the upper file path;
And the third determining submodule is used for determining that the reservation rule does not contain the file path matched with the file path to be cleaned when the reservation rule does not contain the file path which is completely the same as the upper file path.
In one possible implementation manner, the acquiring module is specifically configured to:
Acquiring a file directory tree of the application program;
and acquiring a file path to be cleaned under the installation path of the application program according to the file directory tree.
In one possible implementation manner, the second judging module includes:
the first obtaining sub-module is used for obtaining storable time corresponding to the file path matched with the file path to be cleaned when the file path matched with the file path to be cleaned is contained in the reservation rule.
And the second acquisition sub-module is used for acquiring the latest updating time of the file corresponding to the file path to be cleaned.
And the third judging sub-module is used for judging whether the time difference between the current time and the latest updating time is larger than or equal to the storable time.
And the fourth determining submodule is used for determining that the storage time of the file corresponding to the file path to be cleaned does not exceed the storable time when the time difference is smaller than the storable time.
And the fifth determining submodule is used for determining that the storage time of the file corresponding to the file path to be cleaned exceeds the storable time when the time difference is larger than or equal to the storable time.
In one possible implementation, the apparatus further includes:
The third judging module is used for judging whether the application program is in a low-power consumption state or not; and if the application program is in a low-power consumption state, triggering the acquisition module to execute the acquisition of the file path to be cleaned under the installation path of the application program.
In one possible implementation, when the application detects that the application runs in a system background, determining that the application is in a low power consumption state;
Or alternatively
And after the application program detects that the application program is in the idle state, determining that the application program is in a low-power consumption state.
In yet another aspect, the present invention provides a terminal device, including a processor and a memory;
The processor is used for executing the program stored in the memory;
The memory is used for storing a program, and the program is used for at least:
Acquiring a file path to be cleaned under an installation path of an application program;
Judging whether a reservation rule comprises a file path matched with the file path to be cleaned or not, wherein the reservation rule comprises a file path corresponding to a file allowed to be stored and a storable time;
If the reservation rule does not contain the file path matched with the file path to be cleaned, deleting the file corresponding to the file path to be cleaned;
If the reservation rule contains a file path matched with the file path to be cleaned, judging whether the storage time of the file corresponding to the file path to be cleaned exceeds the corresponding storable time;
and if the storage time of the file corresponding to the file path to be cleaned exceeds the storable time, deleting the file corresponding to the file path to be cleaned.
In yet another aspect, the present invention further provides a storage medium, where computer executable instructions are stored, where the computer executable instructions, when loaded and executed by a processor, implement a method for cleaning files of an application program according to any one of the possible implementation manners described above.
The method for cleaning the application program file is integrated in the application program, the application program acquires the file path to be cleaned under the self installation path by calling the method, then judges whether the reservation rule contains a file path matched with the file path to be cleaned, and if so, continues to judge whether the storage time of the file corresponding to the file to be cleaned exceeds the corresponding storable time. And if the corresponding storable time is exceeded or the corresponding file path is not contained in the reservation rule, deleting the file corresponding to the file to be cleaned. The method can be integrated in the code of the application program, can scan the files under the installation path of the application program, and clean the designated files, so as to reduce the occupation of the limited storage space of the intelligent terminal by useless files in the application program. Moreover, by adopting the scheme, the files under the installation directory of the application program can be cleaned uniformly, a software developer is not required to add corresponding file cleaning logic codes for the developed service modules, and the development burden of the software developer is reduced.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings that are required in the embodiments or the description of the prior art will be briefly described, and it is obvious that the drawings in the following description are some embodiments of the present invention, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a schematic diagram of a cleaning process for application files provided by the present invention;
FIG. 2 is a flow chart of a method for cleaning application files provided by the present invention;
FIG. 3 is a flow chart of a process for determining whether a retention rule includes a file path matching a file path to be cleaned;
FIG. 4 is a flowchart of a process for determining whether the storage time of a file corresponding to a path of a file to be cleaned exceeds the storable time configured in a reservation rule according to the present invention;
FIG. 5 is a schematic diagram of a file directory tree provided by the present invention;
FIG. 6 is a flowchart of another method for cleaning application files provided by the present invention;
FIG. 7 is a schematic diagram of a device for cleaning application files according to the present invention;
FIG. 8 is a schematic diagram illustrating a structure of a cleaning device for an application file according to another embodiment of the present invention;
Fig. 9 is a schematic structural diagram of a terminal device according to an embodiment of the present invention.
Detailed Description
Application files refer to files generated by a user during use of the application, such as cached files, downloaded files, and the like. For example, a user may cache some picture files during use of the instant messaging APP, where the pictures are stored in the installation path of the instant messaging APP. Moreover, these pictures are not used later by the user, and if they are not cleaned regularly, they will always occupy the storage space of the terminal device. The traditional application program file cleaning scheme needs a developer to add file cleaning logic according to the file service condition of the developed service. Such spreading of the file-cleaning logic in the code of the application is inconvenient for centralized management, and if a developer forgets to add the relevant file-cleaning logic during development, a phenomenon that a useless file in the application permanently occupies a memory space may occur.
In order to solve the technical problem, the invention provides a cleaning method for application program files, which can automatically acquire a file path to be cleaned under an installation path and judge whether files corresponding to the file path to be cleaned need to be deleted or not based on cleaning configuration files. By adopting the method, the developer is not required to add the file cleaning logic by itself, the development workload of the developer is reduced, and the phenomenon that the developer forgets to add the corresponding file cleaning logic to cause the useless file to occupy the storage space permanently can be avoided.
Referring to fig. 1, a schematic diagram of a system framework for cleaning application files provided by the invention is shown, and the system is applied to an intelligent terminal.
As shown in fig. 1, in the application development stage, a software developer needs to configure a whitelist configuration file, where a file path corresponding to a file that is allowed to be stored and a time that the file is allowed to be stored are stored in the whitelist configuration file. And the whitelist configuration file is built into the installation file of the application program. Furthermore, a disk scanning tool is built in the installation file of the application program.
After the user installs the installation file of the application program, the disk scanning tool sets a corresponding reservation rule according to the white list configuration file. In the process that the disk scanning tool scans the file of the application program, the disk scanning tool decides whether to clean the file according to the set reservation rule.
When developing an application, a software developer specifies a file path of a file generated when the user uses the application. For example, a software developer may store a chat record of a user in the development specification under the A/B/chat.db file path, and then the chat record generated during the running of the application may be stored in the chat.db file. The developer may configure the contents of the whitelist configuration file according to the prescribed file path.
Referring to fig. 2, a flowchart of a method for cleaning an application file provided by the present invention is shown, and the method is applied to an intelligent terminal. The method can be integrated in any application program, and the application program can clean the designated files under the self installation path by calling the cleaning method, so that the storage space occupied by useless files in the application program is reduced.
As shown in fig. 2, the method comprises the steps of:
s110, acquiring a file path to be cleaned under an installation path of the application program.
In one embodiment of the invention, an application program firstly acquires a file directory tree of the application program, and then calls a disk scanning tool to acquire a file path to be cleaned under an installation path of the application program according to the file directory tree.
For example, the file directory tree for the application may be obtained from a system interface of the operating system.
The file directory tree refers to a storage relationship between a folder and a file in a tree structure, and the file directory refers to a corresponding relationship between the file or the folder and a physical address in a storage space. The file directory sets up an entry for each file or folder. The file directory entry includes at least the name of the file name or folder, the storage address, the data length, the type of access data, the access rights, the creation time, the access time, and the like.
The file path to be cleaned may be any one of file paths under the installation path of the application program.
It should be noted that the file path may be a path of one file or a path of one folder. Where a file path refers to a path that needs to be traversed to reach a certain file (or folder). Wherein the file path includes an absolute path and a relative path.
An absolute path refers to a path from the root directory at the top of a tree directory structure (i.e., a file directory tree) to a certain directory or file, consisting of a series of consecutive directories, separated by diagonal lines, until the directory or file to be pointed to, the last name in the path, i.e., the directory or file to be pointed to. An absolute path is typically a path from the drive, a path that completely describes the location of the file.
The relative path refers to the path relation with other files (or folders) caused by the path in which this file is located.
S120, judging whether the reservation rule contains a file path matched with the file path to be cleaned. If yes, then S140 is performed; if not, S130 is performed.
The reservation rule is configured with a file path corresponding to the file permitted to be stored and a storable time corresponding to the file permitted to be stored.
In one embodiment of the present invention, as shown in fig. 3, the procedure for determining whether the reservation rule includes a file path matching the file path to be cleaned is as follows:
s121, judging whether the reservation rule contains a file path which is completely the same as the file path to be cleaned, and if so, executing S122; if not, S123 is performed.
S122, determining the file path which is completely the same as the file path to be cleaned as the file path matched with the file path to be cleaned.
In one application scenario of the present invention, the reservation rule includes a file path that is identical to the file path to be cleaned, and in this application scenario, it is determined that the file path is a file path that is included in the reservation rule and matches the file path to be cleaned.
S123, judging whether the reservation rule contains a file path which is completely the same as the upper file path of the file path to be cleaned; if yes, then execute S124; if not, S125 is performed.
In another embodiment of the present invention, the storable time corresponding to the path of the file configured in the reservation rule has an inheritance relationship, for example, the storable time corresponding to the path of a folder configured in the reservation rule is not configured in the reservation rule. In this scenario, the file may directly use the storable time rule corresponding to the folder to which it belongs.
Therefore, when the reservation rule does not include the file path completely identical to the file path to be cleaned, in this application scenario, it is necessary to continuously determine whether the reservation rule includes the file path completely identical to the upper-level path of the file path to be cleaned.
S124, determining the file path matched with the file path to be cleaned as the file path which is completely the same as the upper file path.
If the reservation rule contains a file path which is completely the same as the upper file path of the file path to be cleaned, determining the upper file path as the file path matched with the cleaning file path. And cleaning the file according to the configuration information corresponding to the upper file path.
S125, determining that the file path matched with the file path to be cleaned is not contained in the reservation rule.
And if the reservation rule does not contain the file path which is completely the same as the upper file path of the file path to be cleaned, determining that the reservation rule does not contain the file path which is matched with the file path to be cleaned.
S130, deleting the file corresponding to the file path to be cleaned.
In an application scenario of the present invention, if the reservation rule does not include a file path matching with the file path to be cleaned, it indicates that the file of the file path to be cleaned needs to be cleaned, that is, the file path to be cleaned is deleted and corresponds to the file.
In another application scenario of the present invention, if the storage time of the file corresponding to the to-be-cleaned file path exceeds the storable time of the file path configured in the reservation rule and matched with the to-be-cleaned file path, deleting the file corresponding to the to-be-cleaned file path.
S140, judging whether the storage time of the file corresponding to the file path to be cleaned exceeds the storable time; if yes, then S130 is performed; if not, ending the current flow.
If the reservation rule contains a file path matched with the file path to be cleaned, continuing to judge whether the storage time of the file corresponding to the file path to be cleaned exceeds the storable time configured in the reservation rule.
In one embodiment of the present invention, as shown in fig. 4, the process of determining whether the storage time of the file corresponding to the path of the file to be cleaned exceeds the storable time configured in the reservation rule may include steps S141 to S145:
S141, obtaining storable time corresponding to the file path matched with the file path to be cleaned.
And reading the storable time of the file path matched with the file path to be cleaned from the reservation rule.
S142, obtaining the latest updating time of the file corresponding to the file path to be cleaned.
In one embodiment of the present invention, the description information of the file corresponding to the path of the file to be cleaned can be obtained by using a disk scanning tool, where the description information includes, but is not limited to: file type, file size, creation time, update time, etc.
S143, judging whether the time difference between the current time and the latest update time is greater than or equal to storable time; if less, then execute S144; if greater than or equal to, S145 is performed.
S144, determining that the storage time of the file corresponding to the file path to be cleaned does not exceed the storable time.
S145, determining that the storage time of the file corresponding to the file path to be cleaned exceeds the storable time.
Finally, different applicable situations of the storable time of the file are described through specific examples:
for example, as shown in fig. 5, a file directory tree of a certain application program has a folder B, a file x.pic and a file y.pic under a folder a; there is a file z.pic under folder B.
If the storable time in which only the folder a is configured in the reservation rule is 24 hours, there is no exactly the same file path as the file paths of the three files of x.pic, y.pic, and z.pic, respectively, in the reservation rule. Therefore, whether the reservation rule contains the file paths which are completely the same as the previous file paths of the three files respectively is continuously judged, and at the moment, the reservation rule contains storable time matched with the folder A to which the two files, namely the x.pic and the y.pic, belong, so that the x.pic and the y.pic can be determined to be reserved for 24 hours. The reservation rule does not contain a file path matched with the folder B to which the z.pic file belongs, and the file path is continuously searched to find that the storable time of the folder A to which the folder B belongs in the reservation rule is 24 hours, so that the z.pic file can be reserved for 24 hours.
Assuming that the storable time of configuration a in the retention rule is 24 hours and the storable time of folder B is three days, in this case, the two files x.pic and y.pic are retained for only 24 hours and the file z.pic is retained for three days.
Assuming that the storage time of the folder a is configured to be 24 hours in the reservation rule, the storable time of the file x.pic is three days, in this case, the two files, i.e., y.pic and z.pic, are reserved for only 24 hours, and the file x.pic is reserved for three days.
In addition, it should be noted that the present embodiment does not limit the running time of the method, and the cleaning method may be performed at preset time intervals, or the condition for performing the cleaning method may be preconfigured, and when it is detected that the current condition satisfies the preconfigured condition, the cleaning method may be performed.
The method for cleaning the application program files is integrated in the code of the application program, and the application program scans the files under the installation path of the application program by calling the method and cleans the designated files, so that the occupied limited storage space of the intelligent terminal by useless files in the application program is reduced. Moreover, by adopting the scheme, the files under the installation directory of the application program can be cleaned uniformly, a software developer is not required to add corresponding file cleaning logic codes for the developed service modules, and the development burden of the software developer is reduced.
Referring to fig. 6, another process of cleaning an application file according to an embodiment of the present invention is shown, and in this embodiment, when the application is in a low power consumption state, the above-mentioned cleaning method of the application file is executed. As shown in fig. 6, the method further comprises the following steps, based on the embodiment shown in fig. 2:
s210, determining whether an application program is in a low power consumption state; if yes, then S110 is performed; if not, the execution returns to S210 after the interval is preset.
In one embodiment of the invention, when an application detects that the application is running in the system background, the application determines that the application is in a low power consumption state. For example, in an Android system or an IOS system, when an application runs in the background of the system, the system may notify that the application is currently in the background state.
In another embodiment of the invention, the application is determined to be in a low power consumption state when the application detects itself in an idle state. For example, when an application does not detect any operation on the application within a preset time, it is determined that the application is in a low power consumption state.
When the application program is in the low power consumption state, the method for cleaning the application program files is executed, namely, a disk scanning tool is started to scan all file paths under the installation directory of the application program, and corresponding files are cleaned according to a preset reservation rule.
According to the application program file cleaning method provided by the embodiment, the file cleaning method is automatically executed when the application program is in a low-power consumption state, and the phenomenon that the use experience of a user is affected due to excessive occupied memory caused by running the file cleaning method when the user uses the application program is avoided.
In another aspect, the present invention further provides an embodiment of an application file cleaning device, where the device is integrated in an application, as shown in fig. 7, and the device may include: the device comprises an acquisition module 110, a first judgment module 120, a second judgment module 130 and a deletion module 140.
The obtaining module 110 is configured to obtain a file path to be cleaned under an installation path of the application program.
In one embodiment of the present invention, the obtaining module 110 is specifically configured to: acquiring a file directory tree of an application program; and acquiring a file path to be cleaned under the installation path of the application program according to the file directory tree.
The first determining module 120 is configured to determine whether the reservation rule includes a file path that matches the file path to be cleaned.
The reservation rule includes a file path and a storable time corresponding to the file allowed to be stored.
In one embodiment of the present invention, the first determining module 120 may include: the system comprises a first judging sub-module, a first determining sub-module, a second judging sub-module, a second determining sub-module and a third determining sub-module.
And the first judging submodule is used for judging whether the reservation rule contains a file path which is completely the same as the file path to be cleaned.
And the first determining submodule is used for determining the file path matched with the file path to be cleaned as the file path matched with the file path to be cleaned when the file path which is completely the same as the file path to be cleaned is contained in the reservation rule.
And the second judging sub-module is used for judging whether the reservation rule contains the file path which is completely the same as the upper file path of the file path to be cleaned or not when the reservation rule does not contain the file path which is completely the same as the file path to be cleaned.
And the second determining submodule is used for determining that the file path matched with the file path to be cleaned is the file path identical to the upper file path when the reservation rule contains the file path identical to the upper file path.
And the third determining submodule is used for determining that the reservation rule does not contain the file path matched with the file path to be cleaned when the reservation rule does not contain the file path which is completely the same as the upper file path.
The second determining module 130 is configured to determine, when the reservation rule includes a file path that matches the file path to be cleaned, whether a storage time of a file corresponding to the file path to be cleaned exceeds a corresponding storable time.
In one embodiment of the present invention, the second determining module 130 may include:
the first obtaining sub-module is used for obtaining storable time corresponding to the file path matched with the file path to be cleaned when the file path matched with the file path to be cleaned is contained in the reservation rule.
And the second acquisition sub-module is used for acquiring the latest updating time of the file corresponding to the file path to be cleaned.
And the third judging sub-module is used for judging whether the time difference between the current time and the latest updating time is larger than or equal to the storable time.
And the fourth determining submodule is used for determining that the storage time of the file corresponding to the file path to be cleaned does not exceed the storable time when the time difference is smaller than the storable time.
And the fifth determining submodule is used for determining that the storage time of the file corresponding to the file path to be cleaned exceeds the storable time when the time difference is larger than or equal to the storable time.
And the deleting module 140 is configured to delete the file corresponding to the file path to be cleaned when the file path matching the file path to be cleaned is not included in the reservation rule, or when the storage time of the file corresponding to the file path to be cleaned exceeds the storable time.
Referring to fig. 8, a schematic structural diagram of another cleaning device for application files according to the present invention is shown, where the device further includes, based on the embodiment shown in fig. 7:
A third judging module 210, configured to judge whether the application program is in a low power consumption state; and if so, triggering the acquisition module to execute the acquisition of the file path to be cleaned under the installation path of the application program. If not, after the interval is set for a long time, the third judging module is continuously triggered to judge whether the application program is in a low power consumption state.
In an application scenario of the present invention, when an application detects that the application itself is running in a system background, it is determined that the application is in a low power consumption state. For example, in an Android system or an IOS system, when an application runs in the background of the system, the system may notify that the application is currently in the background state.
In another application scenario of the present invention, when an application detects that the application itself is in an idle state, it is determined that the application is in a low power consumption state. For example, when an application does not detect any operation on the application within a preset time, it is determined that the application is in a low power consumption state.
According to the application program file cleaning device, the file cleaning method is automatically executed when the application program is in a low-power consumption state, and the phenomenon that the usage experience of a user is affected due to excessive occupied memory caused by running the file cleaning method when the user uses the application program is avoided.
In yet another aspect, the present invention also provides a terminal device, as shown in fig. 9, which may include a processor 310 and a memory 320.
Optionally, the terminal device may further comprise a communication interface 330, an input unit 340, a communication bus 350 and a display unit 360.
The processor 310, the memory 320, the communication interface 330, the input unit 340 and the display unit 360 all implement communication with each other through the communication bus 350.
In one possible implementation, the processor 310 may be a central processing unit (Central Processing Unit, CPU), an application specific integrated circuit, a digital signal processor, an off-the-shelf programmable gate array, or other programmable logic device, or the like.
The processor 310 may execute programs stored in the memory 320, the memory 320 storing one or more programs, and the programs may include program code including computer operating instructions. In the embodiment of the present application, at least a program for realizing the following functions is stored in the memory:
Acquiring a file path to be cleaned under an installation path of an application program;
Judging whether a reservation rule comprises a file path matched with the file path to be cleaned or not, wherein the reservation rule comprises a file path corresponding to a file allowed to be stored and a storable time;
If the reservation rule does not contain the file path matched with the file path to be cleaned, deleting the file corresponding to the file path to be cleaned;
If the reservation rule contains a file path matched with the file path to be cleaned, judging whether the storage time of the file corresponding to the file path to be cleaned exceeds the corresponding storable time;
and if the storage time of the file corresponding to the file path to be cleaned exceeds the storable time, deleting the file corresponding to the file path to be cleaned.
In one possible implementation, the memory 320 may include a storage program area and a storage data area, wherein the storage program area may store an operating system, and application programs required for at least one function (such as a sound playing function, an image playing function, etc.), and the like; the storage data area may store data created during use of the computer, such as user data, user access data, audio data, and the like.
In addition, memory 320 may include high-speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device or other volatile solid-state storage device.
The communication interface 330 may be an interface of a communication module, such as an interface of a GSM module.
It should be noted that the structure of the server shown in fig. 9 is not limited to the server in the embodiment of the present application, and the server may include more or less components than those shown in fig. 9, or may be combined with some components in practical applications.
In yet another aspect, the present invention further provides a storage medium having stored therein computer executable instructions that, when loaded and executed by a processor, implement the method for cleaning application files in any of the above embodiments.
For the foregoing method embodiments, for simplicity of explanation, the methodologies are shown as a series of acts, but one of ordinary skill in the art will appreciate that the present invention is not limited by the order of acts, as some steps may, in accordance with the present invention, occur in other orders or concurrently. Further, those skilled in the art will also appreciate that the embodiments described in the specification are all preferred embodiments, and that the acts and modules referred to are not necessarily required for the present invention.
It should be noted that, in the present specification, each embodiment is described in a progressive manner, and each embodiment is mainly described as different from other embodiments, and identical and similar parts between the embodiments are all enough to be referred to each other. For the apparatus class embodiments, the description is relatively simple as it is substantially similar to the method embodiments, and reference is made to the description of the method embodiments for relevant points.
The steps in the method of the embodiments of the present application may be sequentially adjusted, combined, and deleted according to actual needs.
The device and the modules and the submodules in the terminal in the embodiments of the application can be combined, divided and deleted according to actual needs.
In the embodiments provided in the present application, it should be understood that the disclosed terminal, apparatus and method may be implemented in other manners. For example, the above-described terminal embodiments are merely illustrative, and for example, the division of modules or sub-modules is merely a logical function division, and there may be other manners of division in actual implementation, for example, multiple sub-modules or modules may be combined or integrated into another module, or some features may be omitted, or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be an indirect coupling or communication connection via some interfaces, devices or modules, which may be in electrical, mechanical, or other forms.
The modules or sub-modules illustrated as separate components may or may not be physically separate, and components that are modules or sub-modules may or may not be physical modules or sub-modules, i.e., may be located in one place, or may be distributed over multiple network modules or sub-modules. Some or all of the modules or sub-modules may be selected according to actual needs to achieve the purpose of the embodiment.
In addition, each functional module or sub-module in the embodiments of the present application may be integrated in one processing module, or each module or sub-module may exist alone physically, or two or more modules or sub-modules may be integrated in one module. The integrated modules or sub-modules may be implemented in hardware or in software functional modules or sub-modules.
Finally, it is further noted that relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the invention. Thus, the present invention is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
The foregoing is merely a preferred embodiment of the present invention and it should be noted that modifications and adaptations to those skilled in the art may be made without departing from the principles of the present invention, which are intended to be comprehended within the scope of the present invention.

Claims (10)

1. The method for cleaning the application program files is characterized by being integrated in the application program, wherein the installation files of the application program comprise white list configuration files and disk scanning tools, and the disk scanning tools are used for setting corresponding reservation rules according to the white list configuration files after the application program is installed; the white list configuration file stores a file path and storable time corresponding to the file which is allowed to be stored; the method comprises the following steps:
acquiring a file path to be cleaned under the installation path of the application program;
Judging whether a reservation rule contains a file path matched with the file path to be cleaned or not, wherein if the reservation rule does not contain the file path which is completely the same as the file path to be cleaned, judging whether the reservation rule contains the file path which is completely the same as an upper file path of the file path to be cleaned or not; if the reservation rule comprises a file path which is completely the same as the upper file path, determining that the file path which is matched with the file path to be cleaned is the file path which is completely the same as the upper file path, wherein the reservation rule comprises a file path corresponding to the file which is allowed to be stored and a storable time, and the storable time corresponding to the file path configured in the reservation rule has an inheritance relationship;
If the reservation rule does not contain the file path matched with the file path to be cleaned, deleting the file corresponding to the file path to be cleaned;
If the reservation rule comprises a file path matched with the file path to be cleaned, acquiring storable time corresponding to the file path matched with the file path to be cleaned, wherein if the file path matched with the file path to be cleaned is the file path which is completely the same as the upper file path, determining that storable time corresponding to the file path matched with the file path to be cleaned is storable time corresponding to the file path which is completely the same as the upper file path according to the inheritance relation;
acquiring the latest updating time of the file corresponding to the file path to be cleaned;
judging whether the time difference between the current time and the latest updating time is larger than or equal to the corresponding storable time or not;
if the time difference value is smaller than the corresponding storable time, determining that the storage time of the file corresponding to the file path to be cleaned does not exceed the storable time;
if the time difference value is larger than or equal to the corresponding storable time, determining that the storage time of the file corresponding to the file path to be cleaned exceeds the storable time;
and if the storage time of the file corresponding to the file path to be cleaned exceeds the storable time, deleting the file corresponding to the file path to be cleaned.
2. The method of claim 1, wherein the obtaining a file path to be cleaned under an installation path of the application program comprises:
Acquiring a file directory tree of the application program;
and acquiring a file path to be cleaned under the installation path of the application program according to the file directory tree.
3. The method of claim 1, wherein determining whether the retention rule includes a file path that matches the file path to be cleaned comprises:
Judging whether the reservation rule contains a file path which is completely the same as the file path to be cleaned;
If the reservation rule contains the file path which is completely the same as the file path to be cleaned, determining the file path matched with the file path to be cleaned as the file path matched with the file path to be cleaned;
and if the reservation rule does not contain the file path which is completely the same as the upper file path, determining that the reservation rule does not contain the file path which is matched with the file path to be cleaned.
4. The method according to claim 1, wherein the method further comprises:
Determining whether the application is in a low power state;
And if the application program is in a low-power consumption state, executing the step of acquiring the file path to be cleaned under the installation path of the application program.
5. The method of claim 4, wherein determining whether the application is in a low power state comprises:
When the application program detects that the application program runs in a system background, determining that the application program is in a low-power consumption state;
Or alternatively
And after the application program detects that the application program is in the idle state, determining that the application program is in a low-power consumption state.
6. The device for cleaning the application program files is characterized by being integrated in the application program, wherein the installation files of the application program comprise white list configuration files and disk scanning tools, and the disk scanning tools are used for setting corresponding reservation rules according to the white list configuration files after the application program is installed; the white list configuration file stores a file path and storable time corresponding to the file which is allowed to be stored; the device comprises
The acquisition module is used for acquiring a file path to be cleaned under the installation path of the application program;
the first judging module is used for judging whether a reservation rule comprises a file path matched with the file path to be cleaned or not, the reservation rule comprises a file path corresponding to the file which is allowed to be stored and a storable time, and the storable time corresponding to the file path configured in the reservation rule has an inheritance relationship;
The first judging module comprises a second judging sub-module and a second determining sub-module;
The second judging submodule is used for judging whether the reservation rule contains a file path which is completely the same as a superior file path of the file path to be cleaned or not when the reservation rule does not contain the file path which is completely the same as the file path to be cleaned;
The second determining submodule is used for determining that the file path matched with the file path to be cleaned is the file path which is completely the same as the upper file path when the reservation rule contains the file path which is completely the same as the upper file path;
the first obtaining submodule is used for obtaining storable time corresponding to a file path matched with the file path to be cleaned when the file path matched with the file path to be cleaned is contained in the reservation rule, wherein if the file path matched with the file path to be cleaned is the file path which is completely the same as the upper-level file path, the storable time corresponding to the file path matched with the file path to be cleaned is determined to be storable time corresponding to the file path which is completely the same as the upper-level file path according to the inheritance relation;
The second acquisition submodule is used for acquiring the latest updating time of the file corresponding to the file path to be cleaned;
a third judging sub-module, configured to judge whether a time difference between the current time and the latest update time is greater than or equal to the corresponding storable time;
a fourth determining submodule, configured to determine, when the time difference value is smaller than the corresponding storable time, that the storage time of the file corresponding to the file path to be cleaned does not exceed the storable time;
a fifth determining submodule, configured to determine that, when the time difference is greater than or equal to the corresponding storable time, a storage time of a file corresponding to the file path to be cleaned exceeds the storable time;
And the deleting module is used for deleting the file corresponding to the file path to be cleaned when the file path matched with the file path to be cleaned is not contained in the reservation rule or when the storage time of the file corresponding to the file path to be cleaned exceeds the storable time.
7. The apparatus of claim 6, wherein the first determining module further comprises:
the first judging submodule is used for judging whether the reservation rule contains a file path which is completely the same as the file path to be cleaned;
the first determining submodule is used for determining that the file path matched with the file path to be cleaned is the file path matched with the file path to be cleaned when the file path which is completely the same as the file path to be cleaned is contained in the reservation rule;
And the third determining submodule is used for determining that the reservation rule does not contain the file path matched with the file path to be cleaned when the reservation rule does not contain the file path which is completely the same as the upper file path.
8. The apparatus of claim 6, wherein the apparatus further comprises:
A third judging module, configured to determine whether the application program is in a low power consumption state; and if the application program is in a low-power consumption state, triggering the acquisition module to execute the step of acquiring the file path to be cleaned under the installation path of the application program.
9. A terminal device, comprising: a processor and a memory;
The processor is used for executing the program stored in the memory;
The memory is used for storing a program, and the program is used for at least:
acquiring a file path to be cleaned under an installation path of an application program; the installation files of the application programs comprise white list configuration files and disk scanning tools, and the disk scanning tools are used for setting corresponding reservation rules according to the white list configuration files after the application programs are installed; the white list configuration file stores a file path and storable time corresponding to the file which is allowed to be stored;
Judging whether a reservation rule contains a file path matched with the file path to be cleaned or not, wherein if the reservation rule does not contain the file path which is completely the same as the file path to be cleaned, judging whether the reservation rule contains the file path which is completely the same as an upper file path of the file path to be cleaned or not; if the reservation rule comprises a file path which is completely the same as the upper file path, determining that the file path which is matched with the file path to be cleaned is the file path which is completely the same as the upper file path, wherein the reservation rule comprises a file path corresponding to the file which is allowed to be stored and a storable time, and the storable time corresponding to the file path configured in the reservation rule has an inheritance relationship;
If the reservation rule does not contain the file path matched with the file path to be cleaned, deleting the file corresponding to the file path to be cleaned;
If the reservation rule comprises a file path matched with the file path to be cleaned, acquiring storable time corresponding to the file path matched with the file path to be cleaned, wherein if the file path matched with the file path to be cleaned is the file path which is completely the same as the upper file path, determining that storable time corresponding to the file path matched with the file path to be cleaned is storable time corresponding to the file path which is completely the same as the upper file path according to the inheritance relation;
acquiring the latest updating time of the file corresponding to the file path to be cleaned;
judging whether the time difference between the current time and the latest updating time is larger than or equal to the corresponding storable time or not;
if the time difference value is smaller than the corresponding storable time, determining that the storage time of the file corresponding to the file path to be cleaned does not exceed the storable time;
if the time difference value is larger than or equal to the corresponding storable time, determining that the storage time of the file corresponding to the file path to be cleaned exceeds the storable time;
and if the storage time of the file corresponding to the file path to be cleaned exceeds the storable time, deleting the file corresponding to the file path to be cleaned.
10. A storage medium having stored therein computer executable instructions which when loaded and executed by a processor implement a method of cleaning files of an application program according to any of claims 1-5.
CN201910646199.8A 2019-07-17 2019-07-17 Application program file cleaning method and device, terminal equipment and storage medium Active CN112241395B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910646199.8A CN112241395B (en) 2019-07-17 2019-07-17 Application program file cleaning method and device, terminal equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910646199.8A CN112241395B (en) 2019-07-17 2019-07-17 Application program file cleaning method and device, terminal equipment and storage medium

Publications (2)

Publication Number Publication Date
CN112241395A CN112241395A (en) 2021-01-19
CN112241395B true CN112241395B (en) 2024-04-23

Family

ID=74167093

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910646199.8A Active CN112241395B (en) 2019-07-17 2019-07-17 Application program file cleaning method and device, terminal equipment and storage medium

Country Status (1)

Country Link
CN (1) CN112241395B (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104156414A (en) * 2014-07-30 2014-11-19 珠海市君天电子科技有限公司 Terminal, device and method for clearing junk files
CN104572819A (en) * 2014-12-02 2015-04-29 深圳市腾讯计算机***有限公司 Clearing method and system for junk data
CN105159913A (en) * 2015-07-06 2015-12-16 北京金山安全软件有限公司 Method and device for determining file to be cleaned

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103176828B (en) * 2013-03-29 2017-06-09 北京奇虎科技有限公司 Delete the method and device of application program Stub File
CN104317840A (en) * 2014-10-10 2015-01-28 北京金山安全软件有限公司 File cleaning method and device and terminal
CN104536792A (en) * 2014-12-30 2015-04-22 北京奇虎科技有限公司 Method and device for eliminating application program residual files
CN105653663B (en) * 2015-12-29 2019-05-10 珠海豹趣科技有限公司 A kind of file clean-up method and device

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104156414A (en) * 2014-07-30 2014-11-19 珠海市君天电子科技有限公司 Terminal, device and method for clearing junk files
CN104572819A (en) * 2014-12-02 2015-04-29 深圳市腾讯计算机***有限公司 Clearing method and system for junk data
CN105159913A (en) * 2015-07-06 2015-12-16 北京金山安全软件有限公司 Method and device for determining file to be cleaned

Also Published As

Publication number Publication date
CN112241395A (en) 2021-01-19

Similar Documents

Publication Publication Date Title
US9703542B2 (en) Preinstalled application management method for mobile terminal and mobile terminal
CN109669709B (en) Data migration method and data migration system for block chain upgrading
CN108021590B (en) Target object attribute determining method, attribute updating method and device
CN104536792A (en) Method and device for eliminating application program residual files
CN108563440B (en) Automatic adding method and device of list controller codes and readable storage medium
WO2011130971A1 (en) Method and mobile terminal for deleting files
CN104317623B (en) The management method of the preset application program of mobile terminal and mobile terminal
US10235152B2 (en) System and method for downgrading applications
CN105893471B (en) Data processing method and electronic equipment
CN104991949B (en) Mobile terminal and its file management system and method
CN111666516A (en) Page loading method and device, electronic equipment and storage medium
CN110908734A (en) Application combination method and device based on plug-in, terminal equipment and storage medium
CN105824827A (en) File path storage and local file visiting method and apparatus
CN110765394A (en) So file loading method and device, storage medium and terminal equipment
US11080909B2 (en) Image layer processing method and computing device
CN112559127B (en) Virtual machine creation method, device, host and storage medium
CN112241395B (en) Application program file cleaning method and device, terminal equipment and storage medium
CN112799588A (en) Data storage method for loading container cluster application data by using external storage
CN112231699A (en) Interception method and device for reading function, electronic equipment and computer readable medium
CN111417109B (en) eSIM card and operator file management method and management system thereof
CN113868194A (en) Management method, device, system and medium for local user group of storage equipment
CN110795389B (en) Storage snapshot based copying method, user equipment, storage medium and device
CN110944047A (en) Distributed application monitoring method and device
CN112035119B (en) Data deleting method and device
CN113825157B (en) Wireless network equipment upgrading method and system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant