CN112699084A - File cleaning method and device, storage medium and electronic device - Google Patents

File cleaning method and device, storage medium and electronic device Download PDF

Info

Publication number
CN112699084A
CN112699084A CN202110013985.1A CN202110013985A CN112699084A CN 112699084 A CN112699084 A CN 112699084A CN 202110013985 A CN202110013985 A CN 202110013985A CN 112699084 A CN112699084 A CN 112699084A
Authority
CN
China
Prior art keywords
file
cleaning
target
information
target file
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.)
Granted
Application number
CN202110013985.1A
Other languages
Chinese (zh)
Other versions
CN112699084B (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.)
Qingdao Haier Technology Co Ltd
Haier Smart Home Co Ltd
Original Assignee
Qingdao Haier Technology Co Ltd
Haier Smart Home 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 Qingdao Haier Technology Co Ltd, Haier Smart Home Co Ltd filed Critical Qingdao Haier Technology Co Ltd
Priority to CN202110013985.1A priority Critical patent/CN112699084B/en
Publication of CN112699084A publication Critical patent/CN112699084A/en
Application granted granted Critical
Publication of CN112699084B publication Critical patent/CN112699084B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a file cleaning method and device, a storage medium and an electronic device. Wherein, the method comprises the following steps: acquiring a target file list of all file information in a target file system recorded with target file information, wherein the file information comprises file cleaning information configured for a file in advance, and the file cleaning information is used for indicating that the file is allowed to be cleaned; determining first file cleaning information matched with preset target cleaning conditions in file cleaning information of target file information; and cleaning the target file corresponding to the first file cleaning information in the target file system. The invention solves the technical problem of low file cleaning efficiency.

Description

File cleaning method and device, storage medium and electronic device
Technical Field
The invention relates to the field of computers, in particular to a file cleaning method and device, a storage medium and an electronic device.
Background
With the use of mobile phone software (App for short), various files in different sandboxes corresponding to different apps are more and more, and the occupied storage space of a hard disk is larger and larger, and then the cleaning of the files often becomes a chicken rib in development and maintenance, but for cleaning of sandbox files in the related art, a scheme 1) that a file creator is responsible for deleting the files when the files are not needed or a scheme 2) that a function of "cleaning" is provided in the App is adopted, and the waste files are cleaned at the time, however, the scheme 1) or the scheme 2) excessively depends on the operation of a user, and the efficiency is low.
In view of the above problems, no effective solution has been proposed.
Disclosure of Invention
The embodiment of the invention provides a file cleaning method and device, a storage medium and an electronic device, and at least solves the technical problem of low file cleaning efficiency.
According to an aspect of an embodiment of the present invention, there is provided a file cleaning method, including: acquiring a target file list of all file information in a target file system recorded with target file information, wherein the target file information is file information in the target file system, the file information comprises file cleaning information configured for a file in advance, and the file cleaning information is used for indicating that the file is allowed to be cleaned; determining first file cleaning information matched with preset target cleaning conditions in the file cleaning information of the target file information; and clearing the target file corresponding to the first file clearing information in the target file system.
According to another aspect of the embodiments of the present invention, there is also provided a file cleaning apparatus, including: a first obtaining unit, configured to obtain a target file list of all file information in a target file system in which target file information is recorded, where the file information includes file cleaning information preconfigured for a file, and the file cleaning information is used to indicate that the file is allowed to be cleaned; a first determining unit configured to determine first file cleaning information that matches a preset target cleaning condition, from among the file cleaning information of the target file information; and the cleaning unit is used for cleaning the target file corresponding to the first file cleaning information in the target file system.
According to another aspect of the embodiments of the present invention, there is also provided a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to execute the file cleaning method when running.
According to another aspect of the embodiments of the present invention, there is also provided an electronic apparatus, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the file cleaning method through the computer program.
In the embodiment of the invention, an object file list of all file information in an object file system recorded with object file information is obtained, wherein the file information comprises file cleaning information configured for a file in advance, and the file cleaning information is used for indicating that the file is allowed to be cleaned; determining first file cleaning information matched with preset target cleaning conditions in the file cleaning information of the target file information; the target file corresponding to the first file cleaning information in the target file system is cleaned, the target file to be cleaned is automatically obtained through preset file cleaning information and target cleaning conditions and automatically matched with the target cleaning conditions and the file cleaning information in the file cleaning process, and therefore the purpose of improving the automation of file cleaning is achieved, the effect of improving the file cleaning efficiency is achieved, and the technical problem that the file cleaning efficiency is low is solved.
Drawings
The accompanying drawings, which are included to provide a further understanding of the invention and are incorporated in and constitute a part of this application, illustrate embodiment(s) of the invention and together with the description serve to explain the invention without limiting the invention. In the drawings:
FIG. 1 is a schematic diagram of an application environment of an alternative file cleaning method according to an embodiment of the invention;
FIG. 2 is a schematic diagram of a flow chart of an alternative file cleaning method according to an embodiment of the invention;
FIG. 3 is a schematic diagram of an alternative file cleaning method according to an embodiment of the invention;
FIG. 4 is a schematic diagram of an alternative file cleaning method according to an embodiment of the invention;
FIG. 5 is a schematic diagram of an alternative file cleaning method according to an embodiment of the invention;
FIG. 6 is a schematic diagram of an alternative file cleaning method according to an embodiment of the invention;
FIG. 7 is a schematic diagram of an alternative document cleaning apparatus according to an embodiment of the present invention;
fig. 8 is a schematic structural diagram of an alternative electronic device according to an embodiment of the invention.
Detailed Description
In order to make the technical solutions of the present invention better understood, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
It should be noted that the terms "first," "second," and the like in the description and claims of the present invention and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the invention described herein are capable of operation in sequences other than those illustrated or described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
Optionally, as an optional implementation manner, as shown in fig. 1, the file cleaning method includes:
s102, acquiring a target file list of all file information in a target file system recorded with target file information, wherein the file information comprises file cleaning information configured for a file in advance, and the file cleaning information is used for indicating that the file is allowed to be cleaned;
s104, determining first file cleaning information matched with preset target cleaning conditions in the file cleaning information of the target file information;
and S106, cleaning the target file corresponding to the first file cleaning information in the target file system.
Optionally, the file cleaning method may be applied, but not limited to, in a scenario of automatically cleaning App sandbox waste files, specifically, by taking over addition and deletion of App sandbox waste files, and attaching a "cleaning attribute" to each file created through the method to identify a deletion policy for the file, based on which the file cleaner can perform an automatic cleaning operation at an appropriate time.
Optionally, in this embodiment, the preset target cleaning condition may include, but is not limited to, at least one of the following: a time condition, a storage condition, a call condition, etc., wherein the time condition may be, but is not limited to, determining a clean time of the file in terms of a system time, such as when the file clean information indicates that at system time "2021.02.03.13: 00' cleaning, if the system time reaches or exceeds, executing automatic cleaning operation to the file; the storage condition may be, but is not limited to, determining a cleaning condition of the file according to the system storage space, for example, in a case that a margin of the system storage space is less than or equal to a preset lower limit, the file is cleaned preferentially; the calling condition may be, but not limited to, according to the calling frequency of the file, or the recent calling number, for example, in a period of one month, and when the period is reached, the file with the calling frequency less than or equal to the preset frequency is automatically cleaned. This is by way of example only and not by way of limitation.
It should be noted that, an object file list of all file information in an object file system recorded with object file information is obtained, where the object file information is file information in the object file system, the file information includes file cleaning information preconfigured for a file, and the file cleaning information is used to indicate that the file is allowed to be cleaned; determining first file cleaning information matched with preset target cleaning conditions in file cleaning information of target file information; and cleaning the target file corresponding to the first file cleaning information in the target file system.
Optionally, in this embodiment, the target file in the target file system does not need to be cleaned manually, but the corresponding file cleaning information is allocated to the target file when the target file is established, so that the system automatically cleans the target file when the file cleaning information matches the target cleaning condition. The file cleaning method enables a developer to only concern about the creation and the use of the file, and generally does not need to concern about the deletion of the file; on the other hand, the file cleaning method can delete the abandoned files in the target file system in time and release the storage space of the terminal in which the target file system is located.
For further example, as shown in fig. 2, the target file list 202 records a file a, a file B, and a file C of the target file system, wherein, while the file a, the file B, and the file C are established, the user may select that the file a, the file B, and the file C are each configured with corresponding file cleaning information, in other words, the file a, the file B, and the file C are each configured with corresponding file cleaning information, and the file cleaning information is used to instruct that the corresponding file is automatically cleaned at a time that the user wants to delete the file most.
Optionally, in this embodiment, for example, as shown in fig. 2, it is assumed that the file cleaning information of the file C matches the current preset target cleaning condition, and further it is determined that the file C is the target file 204, in other words, the file C is taken as the file that needs to be cleaned currently.
Optionally, in this embodiment, the file cleaning information pre-configured for the file may be, but is not limited to, executed by a file manager (FileManager), the file information may be, but is not limited to, stored in a Database (Database), the file of the target document system may be, but is not limited to, stored in a document system (Filesystem), the file cleaning method may be, but is not limited to, executed by a file cleaner (FileCleaner), the file is added and deleted by taking over the addition and deletion of the file, and a "cleaning attribute" is attached to each file created by the file cleaner, so as to identify a deletion policy for the file; based on the above, the file cleaner performs automatic cleaning work in due time.
Optionally, in this embodiment, only one FileCleaner instance needs to exist in the lifecycle of the target file system, which may be implemented as a single instance, and after the FileCleaner creation is completed, the FileCleaner starts the automatic cleaning work, which may, but is not limited to, occur only in the background thread. fileCleaner works by executing a run loop.
The start of the run loop occurs each time the target file system starts or a timed task triggers. The timed task means that the fileCleaner sets a Timer (Timer) at the end of each execution of a run cycle, and executes the next run cycle after the duration n, which is the case when the target file system is in a long life cycle.
In practice, on the one hand, the cleaning of obsolete files is not a high priority or time-sensitive task; on the other hand, both file and database operations are relatively resource consuming, so here the choice is made to be performed each time the target file system is started or a timed task is triggered.
After the running cycle begins, FileCleaner queries the private database to obtain a list of files that need to be cleaned. The query condition is combined with the information of the clearing attribute, the creation time, the last automatic clearing time and the like of each file.
When the file to be cleaned is inquired, cleaning operation is executed, otherwise, the next step is carried out, and the specific operation cycle is as follows:
1. and deleting the corresponding file in the file system according to the searched list of the files to be cleaned.
2. The FileCleaner receives the feedback that the file deletion is finished.
3. FileCleaner deletes the associated record for the cleared file in the private database.
4. FileCleaner records the current time in a dedicated database as the time when the automatic clean was last performed.
And setting a timer after the time length n, and triggering the operation cycle of the next round.
For further example, as shown in fig. 3, the following steps may be optionally performed:
step S302, creating a file cleaner 302;
step S304, under the condition that the file cleaner 302 is finished, the file cleaner 302 starts automatic cleaning;
step S306, inquiring file cleaning information stored in the database 304;
step S308, the file cleaner 302 deletes the file stored in the document system and corresponding to the file cleaning information;
step S310, the file cleaner 302 deletes the corresponding record stored in the database 304;
in step S312, the file cleaner 302 records the current time for cleaning the file in the database 304.
The optional steps S306 to S312 are running cycles started after the step S304 is executed, and after each running cycle is executed, the current time is used as the start time to start timing until the timing reaches the period of the running cycle, and then the next running cycle is started.
Optionally, in this embodiment, before obtaining the target file list of all file information in the target file system recorded with the target file information, or in the process of obtaining the target file list of all file information in the target file system recorded with the target file information, or after obtaining the target file list of all file information in the target file system recorded with the target file information, the target file list of the target file system may be updated in real time by adding a new file, for example, as shown in fig. 4, the specific steps are as follows:
in step S402, the user 402 sends a request for creating a file to the file manager 404, and 2 necessary parameters are introduced: url of file and "clear attribute" of file;
step S404, after receiving the request, the file manager 404 creates a file in the document system 406, wherein the url of the file is the url transmitted by the user 402;
step S406, the document manager 404 receives feedback of successful document creation;
step S408, the file manager 404 stores the url, the removal attribute, the creation date and other information of the file into a special database 408;
in step S410, the document manager 404 receives feedback of the completion of the storage in the database 408;
in step S412, the document manager 404 returns the document creation success to the user 402.
Optionally, in this embodiment, while executing the file cleaning method, the file may also be, but is not limited to, deleted by a user actively, optionally, a request for the user to delete the file actively is taken over, and the file manager processes the request uniformly, so as to delete information such as the file additional attribute in the dedicated database, for example, as shown in fig. 5, the specific steps are as follows:
step S502, the user 502 sends a request for deleting the file to the file manager 504, and the url of the file is transmitted;
step S504, after the file manager 504 receives the request, the corresponding file is deleted in the file system 506;
in step S506, the document manager 504 receives a feedback of successful document deletion;
step S508, the file manager 504 deletes the additional attribute information of the file in the private database 508;
step S510, the document manager 504 receives feedback of successful operation of the database 508;
in step S512, the document manager 504 returns the document deletion success to the user.
According to the embodiment provided by the application, an object file list of all file information in an object file system recorded with object file information is obtained, wherein the object file information is file information in the object file system, the file information comprises file cleaning information configured for files in advance, and the file cleaning information is used for indicating that the files are allowed to be cleaned; determining first file cleaning information matched with preset target cleaning conditions in file cleaning information of target file information; the target file corresponding to the first file cleaning information in the target file system is cleaned, the target file to be cleaned is automatically obtained through the preset file cleaning information and the preset target cleaning condition and the file cleaning information are automatically matched in the file cleaning process, and therefore the purpose of improving the automation of file cleaning is achieved, and the effect of improving the file cleaning efficiency is achieved.
As an optional scheme, before determining the first file cleaning information matching the target cleaning condition, the method includes:
s1, acquiring a current timestamp, wherein the current timestamp is used for representing the timestamp of the acquisition target file list;
s2, acquiring the cleaning time data configured for each file from the file information recorded in the target file list;
s3, comparing the cleaning time data of each file with the current time stamp;
s4, in the case where the clearing time data matches the current time stamp, it is determined that the target clearing condition is satisfied.
Optionally, in this embodiment, when the target cleaning condition is a time condition, the cleaning time data configured for each file is compared with the current timestamp, and when the comparison result indicates that the cleaning time data is consistent with the current timestamp, the corresponding file is determined to be the target file to be cleaned.
It should be noted that, a current timestamp is obtained, where the current timestamp is used to indicate a timestamp of obtaining the target file list; acquiring cleaning time data configured for each file from file information recorded in a target file list; comparing the cleaning time data of each file with the current timestamp; and under the condition that the cleaning time data is matched with the current timestamp, determining that the target cleaning condition is met.
According to the embodiment provided by the application, the current timestamp is obtained, wherein the current timestamp is used for indicating the timestamp for obtaining the target file list; acquiring cleaning time data configured for each file from file information recorded in a target file list; comparing the cleaning time data of each file with the current timestamp; under the condition that the cleaning time data is matched with the current timestamp, the target cleaning condition is determined to be met, the purpose of automatically cleaning the file based on the timestamp is achieved, and the effect of the accuracy of cleaning the file is achieved.
As an alternative, the acquiring the cleaning time data configured for each file from the file information recorded in the target file list includes:
s1, acquiring a corresponding establishing time stamp of each file;
and S2, acquiring clearing time data according to the establishing timestamp.
Optionally, in this embodiment, the clearing time data may include, but is not limited to, a set-up time stamp, and may also include, but is not limited to, interval duration data between the current time stamp and the set-up time stamp.
It should be noted that, the establishment timestamp corresponding to each file is obtained; and acquiring clearing time data according to the establishing timestamp.
For further example, optionally, for example, as shown in fig. 6, taking the file 602 as an example, it is assumed that the setup time 6022 corresponds to the setup time of the file 602, the current execution time of the file cleaning method corresponding to the current time stamp 6024, the interval duration from the setup time of the file 602 corresponding to the interval duration data 6026 to the current execution time of the file cleaning method, and the cleaning time stamp 6028 corresponds to the cleaning time of the file 602 recorded in the file cleaning information.
Optionally, in this embodiment, continuing to explain by taking fig. 6 as an example, when the target cleaning condition is a time condition, and when the interval duration data 6026 meets the target cleaning condition, the file 602 is cleaned; or, if the build time stamp 6022 meets the target cleaning condition, the file 602 is cleaned; or, in case the cleaning timestamp satisfies the target cleaning condition, then the file 602 is cleaned.
According to the embodiment provided by the application, the corresponding establishment timestamp of each file is obtained; the clearing time data is obtained according to the establishing timestamp, the purpose of accurately clearing the file is achieved, and the effect of improving the accuracy of file clearing is achieved.
As an alternative, acquiring clearing time data according to the establishing timestamp includes:
s1, acquiring the establishing time stamp of the target file and the preset lag time in the target file cleaning information;
s2, acquiring a target time period, wherein the time starting point of the target time period is the establishment time stamp, the time length of the target time period is the lag time, and the cleaning time data comprises the target time period.
It should be noted that the establishing timestamp of the target file and the lag time preset in the target file cleaning information are obtained; and acquiring a target time period, wherein the time starting point of the target time period is the establishment timestamp, the time length of the target time period is the lag time, and the cleaning time data comprises the target time period.
To further illustrate, optionally, such as shown in fig. 6, the lag period may be, but is not limited to, the interval period data 6026, and in the event that the interval period data 6026 meets the target cleaning condition, the file 602 is cleaned.
According to the embodiment provided by the application, the establishment timestamp of the target file and the preset lag time in the target file cleaning information are obtained; and acquiring a target time period, wherein the time starting point of the target time period is the establishment timestamp, the time length of the target time period is the lag time, and the cleaning time data comprises the target time period, so that the aim of accurately cleaning the file is fulfilled, and the effect of improving the accuracy of file cleaning is realized.
As an alternative, in the case that the clearing time data matches the current timestamp, determining that the target clearing condition is satisfied includes at least one of:
s1, determining that the cleaning time data is matched with the current time stamp and determining that the target cleaning condition is met under the condition that the cleaning time stamp indicated by the cleaning time data is consistent with the current time stamp;
and S2, determining that the cleaning time data is matched with the current time stamp and determining that the target cleaning condition is met under the condition that the current time stamp is in the target time period.
Optionally, since the file cleaning method cannot detect the file cleaning information of each file anytime and anywhere, when the cleaning timestamp is inconsistent with the current timestamp but the current timestamp is within the target time period, it is still determined that the cleaning time data is matched with the current timestamp, and it is determined that the target cleaning condition is met.
It should be noted that, in the case that the cleaning timestamp indicated by the cleaning time data is consistent with the current timestamp, it is determined that the cleaning time data matches the current timestamp, and it is determined that the target cleaning condition is satisfied; and under the condition that the current time stamp is located in the target time period, determining that the cleaning time data is matched with the current time stamp, and determining that the target cleaning condition is met.
According to the embodiment provided by the application, under the condition that the cleaning timestamp indicated by the cleaning time data is consistent with the current timestamp, the cleaning time data is determined to be matched with the current timestamp, and a target cleaning condition is determined to be met; under the condition that the current timestamp is located in the target time period, the cleaning time data is determined to be matched with the current timestamp, and the target cleaning condition is determined to be met, so that the aim of meeting the target cleaning condition under various conditions is fulfilled, and the effect of improving the compatibility of file cleaning is achieved.
As an optional scheme, after cleaning a target file in the target file system corresponding to the target file cleaning information, the method includes:
s1, determining that the current round of cleaning of the target file system is completed and determining the cleaning completion timestamp of the current round under the condition that the target file is the last file cleaned by the current round of the target file system;
s2, triggering the next round of cleaning of the target file system after the current round, obtaining the cleaning triggering time stamp of the next round, and obtaining a target file list;
s3, determining the time difference between the cleaning completion time stamp of the current round and the cleaning trigger time stamp of the next round;
s4, when the time difference is equal to or greater than the target threshold, second file cleaning information matching the target cleaning condition is determined.
It should be noted that, in the case that the target file is the last file to be cleaned in the current round of the target file system, it is determined that the cleaning of the current round of the target file system is completed, and a cleaning completion timestamp of the current round is determined; triggering the cleaning of the target file system in the next round after the current round, acquiring a cleaning triggering timestamp of the next round, and acquiring a target file list; determining the time difference between the cleaning completion timestamp of the current round and the cleaning trigger timestamp of the next round; and under the condition that the time difference is larger than or equal to the target threshold, determining second file cleaning information matched with the target cleaning condition.
To further illustrate, optionally, for example, as shown in fig. 3, in step S308, all target files stored in the document system 306 are deleted, where the file cleaning information of the target files matches the target cleaning condition, and in step S312, the cleaning/deleting time corresponding to the cleaned/deleted documents may be, but is not limited to, recorded, and the completion time of the running cycle of the current round may also be, but is not limited to, recorded.
According to the embodiment provided by the application, under the condition that the target file is the last file cleaned by the current round of the target file system, the cleaning completion of the current round of the target file system is determined, and the cleaning completion timestamp of the current round is determined; triggering the cleaning of the target file system in the next round after the current round, acquiring a cleaning triggering timestamp of the next round, and acquiring a target file list; determining the time difference between the cleaning completion timestamp of the current round and the cleaning trigger timestamp of the next round; and under the condition that the time difference is greater than or equal to the target threshold value, determining second file cleaning information matched with the target cleaning condition, achieving the aim of circularly operating file cleaning, and achieving the effect of improving the automation of file processing.
As an alternative, the obtaining of the target file list of all file information in the target file system recorded with the target file information includes at least one of the following:
s1, under the condition that the target client corresponding to the target file system is detected to be in the starting state, the current round of cleaning of the target file system is triggered;
and S2, under the condition that the timed task is detected to be completed, triggering the current round of cleaning of the target file system.
It should be noted that, when detecting that a target client corresponding to a target file system is in a starting state, triggering the current round of cleaning of the target file system; and under the condition that the completion of the timing task is detected, triggering the current round of cleaning of the target file system.
Optionally, in this embodiment, the current round of cleaning of the target file system is triggered, which may be but is not limited to detecting whether the timing task is completed, or may also be but is not limited to detecting whether the target client corresponding to the target file system is in a start state.
According to the embodiment provided by the application, under the condition that the target client corresponding to the target file system is detected to be in the starting state, the current round of cleaning of the target file system is triggered; under the condition that the completion of the timing task is detected, the current round of cleaning of the target file system is triggered, the purpose of timely cleaning files is achieved, and the effect of improving the timeliness of file cleaning is achieved.
It should be noted that, for simplicity of description, the above-mentioned method embodiments are described as a series of acts or combination of acts, but those skilled in the art will recognize that the present invention is not limited by the order of acts, as some steps may occur in other orders or concurrently in accordance with the invention. Further, those skilled in the art should also appreciate that the embodiments described in the specification are preferred embodiments and that the acts and modules referred to are not necessarily required by the invention.
According to another aspect of the embodiment of the invention, a file cleaning device for implementing the file cleaning method is also provided. As shown in fig. 7, the apparatus includes:
a first obtaining unit 702, configured to obtain a target file list of all file information in a target file system recorded with target file information, where the file information includes file cleaning information preconfigured for a file, and the file cleaning information is used to indicate that the file is allowed to be cleaned;
a first determining unit 704 configured to determine, among the file cleaning information of the target file information, first file cleaning information that matches a preset target cleaning condition;
a cleaning unit 706, configured to clean a target file in the target file system, where the target file corresponds to the first file cleaning information.
Optionally, the file cleaning apparatus may be applied, but not limited to, in a scenario of automatically cleaning App sandbox obsolete files, specifically, by taking over addition and deletion of App sandbox obsolete files, and attaching a "cleaning attribute" to each file created through the file cleaning apparatus to identify a deletion policy for the file, and based on this, the file cleaner may perform an automatic cleaning operation at an appropriate time.
Optionally, in this embodiment, the preset target cleaning condition may include, but is not limited to, at least one of the following: a time condition, a storage condition, a call condition, etc., wherein the time condition may be, but is not limited to, determining a clean time of the file in terms of a system time, such as when the file clean information indicates that at system time "2021.02.03.13: 00' cleaning, if the system time reaches or exceeds, executing automatic cleaning operation to the file; the storage condition may be, but is not limited to, determining a cleaning condition of the file according to the system storage space, for example, in a case that a margin of the system storage space is less than or equal to a preset lower limit, the file is cleaned preferentially; the calling condition may be, but not limited to, according to the calling frequency of the file, or the recent calling number, for example, in a period of one month, and when the period is reached, the file with the calling frequency less than or equal to the preset frequency is automatically cleaned. This is by way of example only and not by way of limitation.
The method includes the steps that a target file list of all file information in a target file system recorded with target file information is obtained, wherein the file information comprises file cleaning information configured for files in advance, and the file cleaning information is used for indicating that the files are allowed to be cleaned; determining first file cleaning information matched with preset target cleaning conditions in file cleaning information of target file information; and cleaning the target file corresponding to the first file cleaning information in the target file system.
Optionally, in this embodiment, the target file in the target file system does not need to be cleaned manually, but the corresponding file cleaning information is allocated to the target file when the target file is established, so that the system automatically cleans the target file when the file cleaning information matches the target cleaning condition. The file cleaning device enables a developer to only concern about the creation and the use of the file, and generally does not need to concern about the deletion of the file; on the other hand, the file cleaning device can delete the abandoned files in the target file system in time and release the storage space of the terminal in which the target file system is located.
Optionally, in this embodiment, the file cleaning information pre-configured for the file may be, but is not limited to, executed by a file manager (FileManager), the file information may be, but is not limited to, stored in a Database (Database), the file of the target document system may be, but is not limited to, stored in a document system (Filesystem), the file cleaning apparatus may be, but is not limited to, executed by a file cleaner (FileCleaner), the addition and deletion of the file are taken over by taking over, and a "cleaning attribute" is attached to each file created by the file cleaning apparatus to identify a deletion policy for the file; based on the above, the file cleaner performs automatic cleaning work in due time.
Optionally, in this embodiment, only one FileCleaner instance needs to exist in the lifecycle of the target file system, which may be implemented as a single instance, and after the FileCleaner creation is completed, the FileCleaner starts the automatic cleaning work, which may, but is not limited to, occur only in the background thread. fileCleaner works by executing a run loop.
The start of the run loop occurs each time the target file system starts or a timed task triggers. The timed task means that the fileCleaner sets a Timer (Timer) at the end of each execution of a run cycle, and executes the next run cycle after the duration n, which is the case when the target file system is in a long life cycle.
In practice, on the one hand, the cleaning of obsolete files is not a high priority or time-sensitive task; on the other hand, both file and database operations are relatively resource consuming, so here the choice is made to be performed each time the target file system is started or a timed task is triggered.
After the running cycle begins, FileCleaner queries the private database to obtain a list of files that need to be cleaned. The query condition is combined with the information of the clearing attribute, the creation time, the last automatic clearing time and the like of each file.
When the file to be cleaned is inquired, cleaning operation is executed, otherwise, the next step is carried out, and the specific operation cycle is as follows:
1. and deleting the corresponding file in the file system according to the searched list of the files to be cleaned.
2. The FileCleaner receives the feedback that the file deletion is finished.
3. FileCleaner deletes the associated record for the cleared file in the private database.
4. FileCleaner records the current time in a dedicated database as the time when the automatic clean was last performed.
And setting a timer after the time length n, and triggering the operation cycle of the next round.
For a specific embodiment, reference may be made to the example shown in the file cleaning method, which is not described herein again in this example.
According to the embodiment provided by the application, the target file list of all file information in the target file system recorded with the target file information is obtained, wherein the file information comprises file cleaning information configured for the file in advance, and the file cleaning information is used for indicating that the file is allowed to be cleaned; determining first file cleaning information matched with preset target cleaning conditions in file cleaning information of target file information; the target file corresponding to the first file cleaning information in the target file system is cleaned, the target file to be cleaned is automatically obtained through the preset file cleaning information and the preset target cleaning condition and the file cleaning information are automatically matched in the file cleaning process, and therefore the purpose of improving the automation of file cleaning is achieved, and the effect of improving the file cleaning efficiency is achieved.
As an alternative, the method comprises the following steps:
a second obtaining unit, configured to obtain a current timestamp before determining first file cleaning information that matches the target cleaning condition, where the current timestamp is used to indicate a timestamp for obtaining the target file list;
a third acquisition unit configured to acquire, from the file information recorded in the target file list, cleaning time data configured for each file before determining the first file cleaning information matching the target cleaning condition;
the comparison unit is used for comparing the cleaning time data of each file with the current timestamp before determining the first file cleaning information matched with the target cleaning condition;
a second determination unit configured to determine that the target clearing condition is satisfied in a case where the clearing time data matches the current time stamp before determining the first file clearing information matching the target clearing condition.
For a specific embodiment, reference may be made to the example shown in the file cleaning method, which is not described herein again in this example.
As an optional solution, the third obtaining unit includes:
the first acquisition module is used for acquiring the corresponding establishment timestamp of each file;
and the second acquisition module is used for acquiring the cleaning time data according to the establishing timestamp.
For a specific embodiment, reference may be made to the example shown in the file cleaning method, which is not described herein again in this example.
As an optional solution, the second obtaining module includes:
the first acquisition submodule is used for acquiring an establishment timestamp of the target file and a preset lag time in the target file cleaning information;
and the second acquisition submodule is used for acquiring a target time period, wherein the time starting point of the target time period is the establishment timestamp, the time length of the target time period is the lag time, and the cleaning time data comprises the target time period.
For a specific embodiment, reference may be made to the example shown in the file cleaning method, which is not described herein again in this example.
As an alternative, the second determining unit includes at least one of:
the first determining module is used for determining that the cleaning time data is matched with the current timestamp and determining that a target cleaning condition is met under the condition that the cleaning timestamp indicated by the cleaning time data is consistent with the current timestamp;
and the second determining module is used for determining that the cleaning time data is matched with the current time stamp and determining that the target cleaning condition is met under the condition that the current time stamp is located in the target time period.
For a specific embodiment, reference may be made to the example shown in the file cleaning method, which is not described herein again in this example.
As an alternative, the method comprises the following steps:
the third determining module is used for determining that the cleaning of the current round of the target file system is finished and determining a cleaning finishing timestamp of the current round under the condition that the target file is the last file cleaned by the current round of the target file system after the target file corresponding to the cleaning information of the target file system is cleaned;
the third acquisition module is used for triggering the next round of cleaning of the target file system after the current round after cleaning the target file corresponding to the target file cleaning information in the target file system, acquiring a cleaning triggering timestamp of the next round and acquiring a target file list;
a fourth determining module, configured to determine a time difference between a cleaning completion timestamp of a current round and a cleaning trigger timestamp of a next round after a target file corresponding to target file cleaning information in a target file system is cleaned;
and the fifth determining module is used for determining second file cleaning information matched with the target cleaning condition under the condition that the time difference is greater than or equal to the target threshold value after the target file corresponding to the target file cleaning information in the target file system is cleaned.
For a specific embodiment, reference may be made to the example shown in the file cleaning method, which is not described herein again in this example.
As an optional solution, the first obtaining unit 702 includes at least one of:
the first trigger module is used for triggering the current round of cleaning of the target file system and acquiring a target file list under the condition that a target client corresponding to the target file system is detected to be in a starting state;
and the second triggering module is used for triggering the current round of cleaning of the target file system and acquiring the target file list under the condition of detecting that the timing task is completed.
For a specific embodiment, reference may be made to the example shown in the file cleaning method, which is not described herein again in this example.
According to another aspect of the embodiments of the present invention, there is also provided an electronic device for implementing the file cleaning method, as shown in fig. 8, the electronic device includes a memory 802 and a processor 804, the memory 802 stores a computer program, and the processor 804 is configured to execute the steps in any one of the method embodiments through the computer program.
Optionally, in this embodiment, the electronic apparatus may be located in at least one network device of a plurality of network devices of a computer network.
Optionally, in this embodiment, the processor may be configured to execute the following steps by a computer program:
s1, acquiring a target file list of all file information in a target file system recorded with target file information, wherein the file information comprises file cleaning information configured for files in advance, and the file cleaning information is used for indicating that the files are allowed to be cleaned;
s2, determining first file cleaning information matched with preset target cleaning conditions in the file cleaning information of the target file information;
and S3, cleaning the target file corresponding to the first file cleaning information in the target file system.
Alternatively, it can be understood by those skilled in the art that the structure shown in fig. 8 is only an illustration, and the electronic device may also be a terminal device such as a smart phone (e.g., an Android phone, an iOS phone, etc.), a tablet computer, a palm computer, a Mobile Internet Device (MID), a PAD, and the like. Fig. 8 is a diagram illustrating a structure of the electronic device. For example, the electronic device may also include more or fewer components (e.g., network interfaces, etc.) than shown in FIG. 8, or have a different configuration than shown in FIG. 8.
The memory 802 may be used to store software programs and modules, such as program instructions/modules corresponding to the file cleaning method and apparatus in the embodiments of the present invention, and the processor 804 executes various functional applications and data processing by running the software programs and modules stored in the memory 802, that is, implements the file cleaning method described above. The memory 802 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 802 can further include memory located remotely from the processor 804, which can be connected to the terminal over a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof. The memory 802 may be specifically, but not limited to, used for storing file cleaning information, target cleaning conditions, target files, and other information. As an example, as shown in fig. 8, the memory 802 may include, but is not limited to, a first obtaining unit 702, a first determining unit 704, and a cleaning unit 706 in the file cleaning apparatus. In addition, the file cleaning device may further include, but is not limited to, other module units in the file cleaning device, which is not described in this example again.
Optionally, the transmitting device 806 is configured to receive or transmit data via a network. Examples of the network may include a wired network and a wireless network. In one example, the transmission device 806 includes a Network adapter (NIC) that can be connected to a router via a Network cable and other Network devices to communicate with the internet or a local area Network. In one example, the transmission device 806 is a Radio Frequency (RF) module, which is used for communicating with the internet in a wireless manner.
In addition, the electronic device further includes: a display 808 for displaying the file cleaning information, the target cleaning condition, the target file, and other information; and a connection bus 810 for connecting the respective module parts in the above-described electronic apparatus.
According to a further aspect of an embodiment of the present invention, there is also provided a computer-readable storage medium having a computer program stored thereon, wherein the computer program is arranged to perform the steps of any of the above method embodiments when executed.
Alternatively, in the present embodiment, the above-mentioned computer-readable storage medium may be configured to store a computer program for executing the steps of:
s1, acquiring a target file list of all file information in a target file system recorded with target file information, wherein the file information comprises file cleaning information configured for files in advance, and the file cleaning information is used for indicating that the files are allowed to be cleaned;
s2, determining first file cleaning information matched with preset target cleaning conditions in the file cleaning information of the target file information;
and S3, cleaning the target file corresponding to the first file cleaning information in the target file system.
Alternatively, in this embodiment, a person skilled in the art may understand that all or part of the steps in the methods of the foregoing embodiments may be implemented by a program instructing hardware associated with the terminal device, where the program may be stored in a computer-readable storage medium, and the storage medium may include: flash disks, Read-Only memories (ROMs), Random Access Memories (RAMs), magnetic or optical disks, and the like.
The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.
The integrated unit in the above embodiments, if implemented in the form of a software functional unit and sold or used as a separate product, may be stored in the above computer-readable storage medium. Based on such understanding, the technical solution of the present invention may be substantially or partially implemented in the prior art, or all or part of the technical solution may be embodied in the form of a software product stored in a storage medium, and including instructions for causing one or more computer devices (which may be personal computers, servers, or network devices) to execute all or part of the steps of the method according to the embodiments of the present invention.
In the above embodiments of the present invention, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
In the several embodiments provided in the present application, it should be understood that the disclosed client may be implemented in other manners. The above-described embodiments of the apparatus are merely illustrative, and for example, a division of a unit is merely a division of a logic function, and an actual implementation may have another division, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, units or modules, and may be in an electrical or other form.
Units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The foregoing is only a preferred embodiment of the present invention, and it should be noted that, for those skilled in the art, various modifications and decorations can be made without departing from the principle of the present invention, and these modifications and decorations should also be regarded as the protection scope of the present invention.

Claims (10)

1. A file cleaning method, comprising:
acquiring a target file list of all file information in a target file system recorded with target file information, wherein the target file information is file information in the target file system, the file information comprises file cleaning information configured for a file in advance, and the file cleaning information is used for indicating that the file is allowed to be cleaned;
determining first file cleaning information matched with a preset target cleaning condition in the file cleaning information of the target file information;
and clearing the target file corresponding to the first file clearing information in the target file system.
2. The method of claim 1, prior to determining the first file cleaning information that matches the target cleaning condition, comprising:
acquiring a current timestamp, wherein the current timestamp is used for indicating the timestamp for acquiring the target file list;
acquiring cleaning time data configured for each file from the file information recorded in the target file list;
comparing the cleaning time data of each file with the current timestamp;
determining that the target cleaning condition is satisfied if the cleaning time data matches the current timestamp.
3. The method according to claim 2, wherein the obtaining of the clearing time data configured for each file from the file information recorded in the target file list comprises:
acquiring a corresponding establishment timestamp of each file;
and acquiring the cleaning time data according to the establishing timestamp.
4. The method of claim 3, wherein said obtaining the clearing time data according to the build timestamp comprises:
acquiring an establishment timestamp of the target file and a preset lag time in the target file cleaning information;
and acquiring a target time period, wherein the time starting point of the target time period is the establishment timestamp, the time length of the target time period is the lag time, and the cleaning time data comprises the target time period.
5. The method of claim 4, wherein determining that the target cleaning condition is met if the cleaning time data matches the current timestamp comprises at least one of:
determining that the cleaning time data is matched with the current timestamp and determining that the target cleaning condition is met under the condition that the cleaning timestamp indicated by the cleaning time data is consistent with the current timestamp;
and under the condition that the current time stamp is located in the target time period, determining that the cleaning time data is matched with the current time stamp, and determining that the target cleaning condition is met.
6. The method of claim 2, wherein after the cleaning of the target file in the target file system corresponding to the target file cleaning information, comprising:
determining that the current round of cleaning of the target file system is finished and determining a cleaning completion timestamp of the current round under the condition that the target file is the last file cleaned by the current round of the target file system;
triggering the cleaning of the target file system in the next round after the current round, acquiring a cleaning triggering timestamp of the next round and acquiring the target file list;
determining a time difference between the cleaning completion timestamp of the current round and the cleaning trigger timestamp of the next round;
and under the condition that the time difference is larger than or equal to a target threshold value, determining second file cleaning information matched with the target cleaning condition.
7. The method according to any one of claims 1 to 6, wherein the obtaining of the target file list recorded with all file information in the target file system comprises at least one of:
under the condition that a target client corresponding to the target file system is detected to be in a starting state, triggering the current round of cleaning of the target file system, and acquiring the target file list;
and under the condition that the completion of the timing task is detected, triggering the current round of cleaning of the target file system, and acquiring the target file list.
8. A document cleaning apparatus, comprising:
the file system comprises a first acquisition unit, a second acquisition unit and a third acquisition unit, wherein the first acquisition unit is used for acquiring a target file list of all file information in a target file system recorded with target file information, the file information comprises file cleaning information which is configured in advance for files, and the file cleaning information is used for indicating that the files are allowed to be cleaned;
a first determining unit, configured to determine, in the file cleaning information of the target file information, first file cleaning information that matches a preset target cleaning condition;
and the cleaning unit is used for cleaning the target file corresponding to the first file cleaning information in the target file system.
9. A computer-readable storage medium, comprising a stored program, wherein the program is operable to perform the method of any one of claims 1 to 7.
10. An electronic device comprising a memory and a processor, characterized in that the memory has stored therein a computer program, the processor being arranged to execute the method of any of claims 1 to 7 by means of the computer program.
CN202110013985.1A 2021-01-06 2021-01-06 File cleaning method and device, storage medium and electronic device Active CN112699084B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110013985.1A CN112699084B (en) 2021-01-06 2021-01-06 File cleaning method and device, storage medium and electronic device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110013985.1A CN112699084B (en) 2021-01-06 2021-01-06 File cleaning method and device, storage medium and electronic device

Publications (2)

Publication Number Publication Date
CN112699084A true CN112699084A (en) 2021-04-23
CN112699084B CN112699084B (en) 2022-10-28

Family

ID=75514927

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110013985.1A Active CN112699084B (en) 2021-01-06 2021-01-06 File cleaning method and device, storage medium and electronic device

Country Status (1)

Country Link
CN (1) CN112699084B (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103577417A (en) * 2012-07-23 2014-02-12 腾讯科技(深圳)有限公司 Desktop cleaning method and device
CN103605800A (en) * 2013-12-06 2014-02-26 贝壳网际(北京)安全技术有限公司 File processing method and file processing system
US9705730B1 (en) * 2013-05-07 2017-07-11 Axcient, Inc. Cloud storage using Merkle trees
CN107609066A (en) * 2017-08-30 2018-01-19 努比亚技术有限公司 Method, equipment and the computer for clearing up file can storage mediums

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103577417A (en) * 2012-07-23 2014-02-12 腾讯科技(深圳)有限公司 Desktop cleaning method and device
US9705730B1 (en) * 2013-05-07 2017-07-11 Axcient, Inc. Cloud storage using Merkle trees
CN103605800A (en) * 2013-12-06 2014-02-26 贝壳网际(北京)安全技术有限公司 File processing method and file processing system
CN107609066A (en) * 2017-08-30 2018-01-19 努比亚技术有限公司 Method, equipment and the computer for clearing up file can storage mediums

Also Published As

Publication number Publication date
CN112699084B (en) 2022-10-28

Similar Documents

Publication Publication Date Title
CN109542529B (en) Function name-based point burying method and device, computer equipment and storage medium
WO2018121442A1 (en) Method and device for processing software information, storage medium, and electronic device
CN103200247B (en) A kind of data download method and PC download client
CN105615832A (en) Medical image data acquisition method and device
CN110245020B (en) Mobile phone content forensics method and system based on multiple forensics devices
CN111405217A (en) Image information display method and device, storage medium and electronic device
CN110162347B (en) Application program starting method, device, equipment and storage medium
CN107526636B (en) Resource identification method and device
CN108306790B (en) Application flow monitoring method and device and Android equipment
CN100380868C (en) Network management systm, appts. need to be managed, managing device and program thereof
CN112699084B (en) File cleaning method and device, storage medium and electronic device
CN105335186A (en) Data downloading management method and system
CN108132836B (en) Task distribution method and device and electronic equipment
CN105635821B (en) A kind of video filtering method and device
CN111147226B (en) Data storage method, device and storage medium
CN108647139B (en) System test method, device, storage medium and electronic device
CN108446144B (en) Application program starting method and device, terminal and storage medium
JP5343453B2 (en) Content file management system
CN104202310B (en) A kind of method and apparatus that connection is established between mobile device and computing device
CN113660359A (en) Management method and device for domain name resolution record, storage medium and electronic equipment
CN107302605B (en) Configuration method and device of television proxy server, television and storage medium
CN108206933B (en) Video data acquisition method and device based on video cloud storage system
CN109495288B (en) Service deployment method and device
CN111399929A (en) Test application starting method and device
WO2016180350A1 (en) Intelligent management method for terminal desktop, terminal, and computer storage medium

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