CN114706825A - File scanning method and device, terminal equipment and storage medium - Google Patents

File scanning method and device, terminal equipment and storage medium Download PDF

Info

Publication number
CN114706825A
CN114706825A CN202210430599.7A CN202210430599A CN114706825A CN 114706825 A CN114706825 A CN 114706825A CN 202210430599 A CN202210430599 A CN 202210430599A CN 114706825 A CN114706825 A CN 114706825A
Authority
CN
China
Prior art keywords
file
scanning
scanned
files
queue
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.)
Pending
Application number
CN202210430599.7A
Other languages
Chinese (zh)
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.)
BDstar Intelligent and Connected Vehicle Technology Co Ltd
Original Assignee
BDstar Intelligent and Connected Vehicle Technology 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 BDstar Intelligent and Connected Vehicle Technology Co Ltd filed Critical BDstar Intelligent and Connected Vehicle Technology Co Ltd
Priority to CN202210430599.7A priority Critical patent/CN114706825A/en
Publication of CN114706825A publication Critical patent/CN114706825A/en
Pending legal-status Critical Current

Links

Images

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
    • 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/17Details of further file system functions
    • G06F16/1734Details of monitoring file system events, e.g. by the use of hooks, filter drivers, logs

Landscapes

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

Abstract

The embodiment of the invention provides a file scanning method, a file scanning device, terminal equipment and a storage medium, belonging to the field of data processing, wherein the method comprises the following steps: when a scanning process monitors the mount notification of any external storage device, file directories of the external storage devices are traversed, files meeting effective conditions are added into a file queue, the files which are not scanned in the file queue are used as files to be scanned based on a historical scanning file table, a first thread pool is started, all the files to be scanned are scanned in a multi-thread parallel mode, scanned scanning information is inserted into a database, after all the files to be scanned are scanned, scanning end notification is broadcasted to other processes to notify the other processes that the database is to be accessed, only the files to be scanned which are not scanned in the history are scanned, repeated scanning is avoided to a certain extent, and the multi-thread parallel scanning mode is adopted, so that the scanning time consumption can be greatly reduced.

Description

File scanning method and device, terminal equipment and storage medium
Technical Field
The invention relates to the field of data processing, in particular to a file scanning method, a file scanning device, terminal equipment and a storage medium.
Background
With the popularization of intelligent terminals and the coming of the era of mobile internet, the intellectualization of the car terminal has become a key direction for research and development of car enterprises. At present, the intelligent vehicle machine has more and more complete functions, and people can utilize the vehicle machine terminal to realize entertainment activities such as listening to music, watching videos, playing games, navigating, chatting and the like. Due to the limitation of the storage space of the in-vehicle terminal, the external storage devices such as a usb disk and a mobile hard disk are usually used to store resources such as pictures, music, and videos, and the in-vehicle terminal is connected to the external storage device to acquire and use the resources of the external storage device in a scanning manner.
The on-board terminal usually carries an Android (Android) system, and due to the design problem of a media scanner (Android native) frame, when scanning equipment with more media data, the scanning time is long. Meanwhile, after an external storage device is removed or inserted, the previously stored database is detected and cleaned, and therefore, after the external storage device is plugged, the file in the external storage device needs to be scanned and analyzed again. Therefore, when there are many media files in the external storage device, the time consumed for scanning by the in-vehicle terminal is too long.
Disclosure of Invention
In view of the above, an object of the present invention is to provide a file scanning method, an apparatus, an electronic device and a storage medium, which can solve the problem that the time consumption is too long when the current terminal scans an external storage device.
In order to achieve the above object, the embodiments of the present invention adopt the following technical solutions.
In a first aspect, an embodiment of the present invention provides a file scanning method, which adopts the following technical solution.
A file scanning method is applied to terminal equipment, the terminal equipment comprises a database, scanning processes are installed on the terminal equipment, and the method comprises the following steps:
traversing a file directory of the external storage equipment when the scanning process monitors the mount notification of any external storage equipment, and adding files meeting effective conditions into a file queue;
based on a history scanning file table, taking an unscanned file in the file queue as a file to be scanned, wherein file information of the scanned file is recorded in the history scanning file table;
starting a first thread pool, scanning all the files to be scanned in a multi-thread parallel mode, and inserting the scanned scanning information into the database;
and after scanning of all the files to be scanned is finished, broadcasting a scanning finish notice to other processes so as to inform the other processes that the database is to be accessed.
Further, the scanning information includes media file information, and the step of scanning all the files to be scanned includes:
judging whether the file to be scanned is a media file or not according to the file type of the file to be scanned, and if so, adding the file to be scanned into an analysis queue;
and opening a second thread pool, analyzing the files in the analysis queue in a multi-thread parallel mode, and updating the media file information of the successfully analyzed files into the media table of the database.
Further, the parsing the file in the parsing queue includes:
extracting metadata information of the file in the analysis queue, wherein if the extraction fails, the file analysis fails, otherwise, the file analysis succeeds;
the metadata information includes any of album, duration, title, and composer.
Further, after the step of determining whether the file to be scanned is a media file, the method further includes:
if not, ending the scanning process of the file to be scanned;
the step of scanning all the files to be scanned further includes:
and recording the file information of the file to be scanned into the history scanning file table.
Further, the step of traversing the file directory of the external storage device and adding the file meeting the effective condition to the file queue includes:
traversing the primary file directory of the external storage device, adding files meeting effective conditions into a file queue, and adding folders meeting effective conditions into a folder queue;
and adding the files meeting the effective conditions in all the folders in the folder queue into the file queue according to a directory recursive traversal mode, and adding the folders meeting the effective conditions into the folder queue until all the folders are traversed.
Further, before the step of traversing the file directory of the external storage device and adding the file meeting the valid condition to the file queue when the scanning process monitors the mount notification of any external storage device, the method further includes:
when the scanning process is started for the first time, the database is created, and the unique constraint is determined to comprise file information, wherein the file information comprises a file path, a file name, a file type, a file size and file modification time;
and starting the scanning process when the system of the terminal equipment is started.
Further, the step of using the file which is not scanned in the file queue as the file to be scanned based on the history scanning file table includes:
and judging whether the content consistent with the unique constraint field of the file exists in the history scanning file table or not aiming at each file in the file queue, and if not, determining that the file is an unscanned file so as to take the file as a file to be scanned.
In a second aspect, an embodiment of the present invention provides a document scanning apparatus, which adopts the following technical solutions.
A file scanning device is applied to terminal equipment, the terminal equipment comprises a database, the terminal equipment is provided with a scanning process, and the file scanning device comprises a traversal module, a scanning module and a broadcasting module;
the traversal module is used for traversing a file directory of the external storage equipment when the scanning process monitors the mount notification of any external storage equipment, and adding files meeting effective conditions to a file queue;
the scanning module is used for taking the file which is not scanned in the file queue as the file to be scanned based on a history scanning file list, wherein the history scanning file list records the file information of the scanned file; the system is also used for starting a first thread pool, scanning all the files to be scanned in a multi-thread parallel mode, and inserting the scanned scanning information into the database;
and the broadcasting module is used for broadcasting scanning end notification to other processes after scanning of all the files to be scanned is finished so as to notify the other processes that the database is to be accessed.
In a third aspect, an embodiment of the present invention provides a terminal device, which adopts the following technical solutions.
A terminal device comprising a processor and a memory, the memory storing a computer program executable by the processor, the processor being executable to implement the file scanning method of the first aspect.
In a fourth aspect, an embodiment of the present invention provides a storage medium, which adopts the following technical solutions.
A storage medium having stored thereon a computer program which, when executed by a processor, implements a file scanning method as described in the first aspect.
According to the file scanning method, the file scanning device, the terminal device and the storage medium provided by the embodiment of the invention, when the scanning process on the terminal device monitors the mounting notice of the external storage device, the effective files on the external storage device are added into the file queue, so that the files to be scanned which are not scanned historically in the file queue are determined, the first thread pool is started to scan the files to be scanned only, repeated scanning can be avoided, multithreading parallel scanning is realized, and the scanning time consumption can be greatly reduced.
In order to make the aforementioned and other objects, features and advantages of the present invention comprehensible, preferred embodiments accompanied with figures are described in detail below.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings needed to be used in the embodiments will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present invention and therefore should not be considered as limiting the scope, and for those skilled in the art, other related drawings can be obtained according to the drawings without inventive efforts.
Fig. 1 is a block diagram illustrating a document scanning system according to an embodiment of the present invention.
Fig. 2 is a flowchart illustrating a file scanning method according to an embodiment of the present invention.
Fig. 3 is a second flowchart of a file scanning method according to an embodiment of the present invention.
Fig. 4 shows a schematic flow diagram of a part of the sub-steps of step S102 in fig. 2 or 3.
Fig. 5 shows a schematic flow diagram of a part of the sub-steps of step S106 in fig. 2 or 3.
Fig. 6 is a block diagram of a document scanning apparatus according to an embodiment of the present invention.
FIG. 7 is a block diagram of a terminal device provided in an embodiment of a rush horse.
Icon: 110-a document scanning system; 120-a terminal device; 130 — an external storage device; 140-document scanning means; 150-traversal module; 160-a scanning module; 170-broadcast module.
Detailed Description
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. The components of embodiments of the present invention generally described and illustrated in the figures herein may be arranged and designed in a wide variety of different configurations.
Thus, the following detailed description of the embodiments of the present invention, presented in the figures, is not intended to limit the scope of the invention, as claimed, but is merely representative of selected embodiments of the invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments of the present invention without making any creative effort, shall fall within the protection scope of the present invention.
It is noted that relational terms such as "first" and "second," and the like, may be 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. Also, 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 an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
At present, the intelligent vehicle machine has more and more complete functions, and people can utilize the vehicle machine terminal to realize entertainment activities such as listening to music, watching videos, playing games, navigating, chatting and the like. Due to the limitation of the storage space of the in-vehicle terminal, the external storage device 130 such as a usb disk and a mobile hard disk is usually used to store resources such as pictures, music, and videos, and the in-vehicle terminal is connected to the external storage device 130 to obtain and use the resources of the external storage device 130 in a scanning manner.
The on-board terminal usually carries an Android (Android) system, and due to the design problem of a media scanner (Android native) frame, when scanning equipment with more media data, the scanning time is long. Meanwhile, after an external storage device (such as a U disk) is removed or inserted, the database saved before is detected and cleaned. Therefore, a phenomenon exists in a terminal device with an android system: after the user plugs in and unplugs the external storage device, the user needs to scan and analyze the file in the external storage device again.
When there are many files with large storage capacity, such as media files in the external storage device, the terminal device needs to spend a lot of time to complete the scanning and analysis of the external storage device, and the time consumption can even reach more than tens of minutes. In addition, in the process of scanning the external storage device by the terminal device, it is difficult for the user to access the required files in time. Meanwhile, the scanning and analyzing process occupies a high utilization rate of the CPU and the memory for a long time, so that the terminal device is prone to system jamming and other problems due to insufficient CPU and memory.
In view of this, embodiments of the present invention provide a file scanning scheme, which can solve the problem that the time consumption is too long when the terminal device 120 scans and analyzes the external storage device 130 at present. Hereinafter, description will be made from the viewpoint of a document scanning method and the like.
The file scanning method provided in the embodiment of the present invention may be applied to the environment shown in fig. 1, where the file scanning system 110 includes a terminal device 120 and at least one external storage device 130, the terminal device 120 includes a database, a scanning process is installed on the terminal device 120, and the terminal device 120 is equipped with an android system. When the scanning process monitors that the external storage device 130 is mounted on the terminal device 120, the terminal device 120 adds the valid file of the external storage device 130 to the file queue, determines the file to be scanned that is not scanned in the file queue, and starts the first thread pool to scan the file to be scanned.
The relevant tasks such as preprocessing, scanning, analysis, database operation and the like before scanning can be put into a Native layer of a scanning process. The external storage device 130 includes, but is not limited to, a U disk and a removable hard disk.
In an embodiment, referring to fig. 2, the present invention provides a file scanning method, and this embodiment is illustrated by applying the file scanning method to the terminal device 120 in fig. 1.
S102, when the scanning process monitors the mount notification of any external storage device, the file directory of the external storage device is traversed, and files meeting effective conditions are added into a file queue.
Thus, the file queue includes a plurality of active files. Wherein the valid condition comprises a file format standard. It should be understood that a file format standard refers to a format of each type of file conforming to the type of format standard to which it pertains. For example, "F: \2022-03\ XXXXX. docx" is a valid file and "\ 2022-03\ XXXXX. docx" is an invalid file.
And when the preprocessing, scanning, analyzing and database related operations before scanning are all put into the native layer of the scanning process, and the scanning process monitors the mount notification of the external storage device 130, sending a request to the native layer to trigger: the file directory of the external storage device 130 is traversed, and files satisfying the valid condition are added to the file queue.
And S104, based on the history scanning file table, taking the file which is not scanned in the file queue as the file to be scanned.
The history scanning file table records file information of scanned files.
S106, starting the first thread pool, scanning all the files to be scanned in a multi-thread parallel mode, and inserting the scanned scanning information into the database.
It should be noted that, steps S104 and S106 may also be performed in parallel, that is, after the file to be scanned is determined, S106 may be executed to scan the file to be scanned, and S104 may be executed to continue determining the file to be scanned.
And S108, after scanning of all the files to be scanned is finished, broadcasting a scanning end notification to other processes so as to notify the other processes that the database is to be accessed.
Other processes include, but are not limited to, read-write processes, storage processes, and the like.
It should be understood that the execution process of steps S104 to S108 belongs to the content of the scanning process.
To facilitate a better understanding of the above-described document scanning method provided by the present invention, the principles are described below.
In a native scanning process (MediaScanner) of the android system, after the user unplugs the external storage device 130, the file in the external storage device 130 is scanned and analyzed again, which results in a long scanning time.
In the file scanning method provided in this embodiment, when the scanning process on the terminal device 120 monitors the mount notification of the external storage device 130, the valid file on the external storage device 130 is added to the file queue, so as to determine the file to be scanned that has not been scanned historically in the file queue, and then the first thread pool is started to scan only the file to be scanned, so that multiple repeated scans on the same file or the same external storage device 130 can be avoided, and multiple threads of parallel scans can greatly reduce the scanning time consumption.
Therefore, after the user inserts the external storage device 130 (such as a usb disk) into the terminal device 120 (e.g., a car terminal), the terminal device 120 can access the desired file in a short time. Especially, when an external storage device 130 containing a large amount of data is unplugged again, the file scanning method provided by the embodiment can almost save the time consumption required for completely scanning the external storage device 130 once.
This can be done using the C + + language: and all related work such as preprocessing, scanning, analysis, database operation and the like before scanning is moved to a native layer of a scanning process. By the operation of the native layer in the scanning process, the scanning efficiency is improved, and meanwhile, a large amount of APP and Jni data communication of the native layer can be avoided to a certain extent, so that the communication time of data and the resource consumption of a system are reduced.
Further, referring to fig. 3, the file scanning method provided by the present embodiment may further include steps S100 and S101, and S100 and S101.
S100, when the scanning process is started for the first time, a database is created, and the unique constraint is determined to comprise file information.
The file information comprises a file path, a file name, a file type, a file size and a file modification time.
When the scanning process is first started on the terminal device 120, the terminal device 120 creates a database for subsequently recording the scanning information scanned by the scanning process and providing access to other processes. And determining a unique constraint (unique constraint) so as to determine the file to be scanned in S104.
S101, when a system of the terminal equipment is started, starting a scanning process.
It should be noted that the system of the terminal device 120 includes, but is not limited to, an android system, a linux system, and a windows system.
When the system of the terminal device 120 is powered on, the terminal device 120 performs the power-on broadcast, the scanning process is started when the terminal device 120 performs the power-on broadcast, and the started scanning can be monitored, so that the step S102 can be performed.
It should be noted that any one of the manners may be flexibly selected to implement the traversal of the file directory of the external storage device 130 in S102, and add the file meeting the valid condition to the file queue. For example, each folder in the first-level directory may also be traversed to the lowest-level directory once; or traversing all folders and file objects of the primary directory first, and then traversing all folders and file directories of the secondary directory until all files, namely the folder directories, are traversed.
In order to quickly determine all files satisfying the validity condition, in one embodiment, referring to fig. 4, the file directory of the external storage device 130 is traversed in S102, and the files satisfying the validity condition are added to the file queue.
S201, traversing the primary file directory of the external storage device, adding files meeting effective conditions into a file queue, and adding folders meeting effective conditions into a folder queue.
S202, adding the files meeting the effective conditions in all the folders in the folder queue into the file queue according to a directory recursive traversal mode, and adding the folders meeting the effective conditions into the folder queue until all the folders are traversed.
The essence of S202 is that for each folder in the folder team: traversing all the first-level folder directories in the folders, adding files meeting the effective conditions in the folders into a file queue, adding subfolders meeting the effective conditions in the folders into the folder queue, and deleting the folders from the folder queue after each folder is traversed until no folder exists in the folder queue.
Through the steps S201 and S202, invalid files can be removed from scanning, the amount of scanning required is reduced, the scanning analysis speed is further improved, and the time consumption is reduced. Meanwhile, through the steps S201 and S202, each file and folder can be traversed, and missing files or folders are prevented from being traversed.
The history scanning file list records file information of files which are scanned historically, wherein the file information comprises a file path, a file name, a file type, a file size and file modification time, and the file information in the history scanning file list is the same as the field number and the field type of the unique constraint.
To facilitate understanding of S104, an embodiment is provided next, and the step S104 may be implemented by: and judging whether the content consistent with the unique constraint field of the file exists in the history scanning file table or not aiming at each file in the file queue, and if not, determining that the file is an unscanned file so as to take the file as a file to be scanned.
And extracting a unique constraint field of each file in the file queue based on the unique constraint, wherein if the content completely consistent with the unique constraint field exists in the history scanned file table, the file is indicated to be scanned, otherwise, the file is not scanned and belongs to the file to be scanned.
For step S106, a suitable mode may be selected to scan all the files to be scanned according to the actual access requirement, that is, the mode of scanning all the files to be scanned may be flexibly selected.
In one embodiment, when the required scanning information includes media file information, referring to fig. 5, step S106 may scan all files to be scanned by the following steps.
S301, judging whether the file to be scanned is a media file according to the file type of the file to be scanned. If yes, go to step S302.
It should be noted that the file types of the media files include, but are not limited to, audio, video, pictures and motion pictures.
For example, when the file type of the file to be scanned is audio, video or picture, the file to be scanned is a media file.
S302, adding the file to be scanned into the analysis queue.
And adding the files to be scanned, which are media files, into an analysis queue, wherein all the files in the analysis queue are the media files.
And S303, opening a second thread pool, analyzing the files in the analysis queue in a multi-thread parallel mode, and updating the media file information of the successfully analyzed files into a media table of the database.
The number of threads in the second thread pool is determined by a technician according to experience values and test results.
In this embodiment, the media file information of the file that is successfully connected and disconnected can be updated/inserted into the media table through the SQLite open source code.
And analyzing a plurality of files in the analysis queue in parallel in a multithreading mode until all the files in the connection and disconnection queue are analyzed. And when any file is successfully analyzed, updating the media file information of the file into the media table. Other processes can access the media file according to the media file information in the media table.
It should be understood that both the historical scan file table and the media table may be stored within the database.
Further, with reference to fig. 5, step S106 further includes substeps S304 and S305, and if it is determined in S301 that the file to be scanned is not a media file, step S304 is executed, and step S305 may be executed after S304 and S303, or before S301.
S304, ending the scanning flow of the file to be scanned.
If the file to be scanned is not a media file, subsequent parsing is not required.
S305, recording the file information of the file to be scanned into a history scanning file table.
The file information of the file to be scanned at this time is recorded in the history scanning file list, so that the file can be prevented from being scanned repeatedly later, and the scanning time consumption can be reduced.
For the step S303, the manner of parsing the file in the parsing queue may be flexibly selected, for example, the file may be parsed according to a preset rule, or may be parsed by machine learning.
In one embodiment, parsing the files in the parse queue may be accomplished by: and extracting metadata information of the file in the analysis queue, wherein if the extraction fails, the file analysis fails, and otherwise, the file analysis succeeds.
The metadata information includes, but is not limited to, any one or more of album, duration, title, and composer.
In this embodiment, the metadata information of the media file may be extracted using the AVFormatContext object in the FFmpeg open source framework. It should be understood that this manner of extraction is merely an example, and not the only limitation of the manner of extraction.
In the native scanning process of the android system of the car terminal, when the mounting path is judged to be the USB flash disk, the scanning process of the files in the USB flash disk is not carried out any more. In the file scanning method provided in this embodiment, the scanning process may be configured as: the external storage path to be scanned (i.e., the path of the file to be scanned) is limited to the storage path of the terminal device 120 itself. In this way, scanning of the external storage device 130 can be masked.
Further, the file scanning method provided by the embodiment of the present invention may further include: when the scanning process monitors the pull-out broadcast or the call-back of the external storage device 130, the scanning operation of the external storage device 130 is stopped.
The file scanning method provided by the embodiment of the invention has the following advantages:
(1) after a file in an external storage device 130 is scanned and analyzed for the first time, file information is stored in a history scanning file table, the file information is not deleted after the device is removed or other external storage devices 130 are inserted, if data changes subsequently, the stored information is directly updated, and therefore repeated scanning on the same external storage device 130 or the same file is avoided to a certain extent.
(2) And a thread pool is introduced, a plurality of scanning and analyzing thread tasks are simultaneously performed in parallel, and the scanning and analyzing efficiency of the file is improved.
(3) An FFmpeg open source framework is introduced to analyze and extract metadata information of the media file so as to further reduce the time consumption for analyzing the metadata of the media file.
(4) The SQLite open source code is introduced to update and insert the database, and Native of the scanning process is configured, so that a large amount of App and Jni data communication of the Native layer can be avoided to a certain extent, and further the communication time of the data and the resource consumption of the system are reduced.
Based on the same inventive concept as the above-mentioned file scanning method, in one embodiment, a file scanning apparatus 140 is provided, which is applied to a terminal device 120, the terminal device 120 includes a database, and the terminal device 120 is installed with a scanning process, and referring to fig. 6, the file scanning apparatus 140 includes a traversal module 150, a scanning module 160, and a broadcasting module 170.
The traversal module 150 is configured to traverse the file directory of the external storage device 130 when the scan process monitors the mount notification of any external storage device 130, and add the file meeting the valid condition to the file queue.
And the scanning module 160 is configured to scan the file table based on the history, and use the file that is not scanned in the file queue as the file to be scanned.
The history scanning file table records file information of scanned files.
The scanning module 160 is further configured to start the first thread pool, scan all the files to be scanned in a multi-thread parallel manner, and insert the scanned scanning information into the database.
The broadcasting module 170 is configured to broadcast a scanning end notification to the other processes after scanning of all the files to be scanned is ended, so as to notify the other processes that the database is to be accessed.
The document scanning device 140 scans only the documents that have not been scanned historically in the external storage device 130, so that the same document can be prevented from being repeatedly scanned to a certain extent, thereby improving the scanning efficiency and reducing the scanning time consumption.
For the specific definition of the document scanning device 140, reference may be made to the above definition of the document scanning method, which is not described herein again. The various modules in the document scanning apparatus 140 described above may be implemented in whole or in part by software, hardware, and combinations thereof. The modules may be embedded in the hardware or independent of the processor in the terminal device 120, or may be stored in the memory in the terminal device 120 in the software, so that the processor calls and executes operations corresponding to the modules.
In one embodiment, a terminal device 120 is provided, and the terminal device 120 may be a terminal, and its internal structure diagram may be as shown in fig. 7. The terminal device 120 includes a processor, a memory, a communication interface, a display screen, and an input device connected through a system bus. Wherein the processor of the terminal device 120 is configured to provide computing and control capabilities. The memory of the terminal device 120 includes a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of an operating system and computer programs in the non-volatile storage medium. The communication interface of the terminal device 120 is used for performing wired or wireless communication with an external terminal, and the wireless communication may be implemented through WIFI, an operator network, Near Field Communication (NFC), or other technologies. The computer program is executed by a processor to implement a file scanning method. The display screen of the terminal device 120 may be a liquid crystal display screen or an electronic ink display screen, and the input device of the terminal device 120 may be a touch layer covered on the display screen, a key, a trackball or a touch pad arranged on a housing of the terminal device 120, or an external keyboard, a touch pad or a mouse, etc.
Those skilled in the art will appreciate that the structure shown in fig. 7 is a block diagram of only a portion of the structure associated with the inventive arrangements, and does not constitute a limitation on the terminal device 120 to which the inventive arrangements are applied, and that a particular terminal device 120 may include more or less components than those shown, or combine certain components, or have a different arrangement of components.
In one embodiment, the document scanning apparatus 140 provided by the present invention can be implemented in the form of a computer program, and the computer program can be run on the terminal device 120 shown in fig. 7. The memory of the terminal device 120 may store therein various program modules constituting the document scanning apparatus 140, such as an a module, a B module, and a C module shown in fig. 6. The computer program constituted by the respective program modules causes the processor to execute the steps in the file scanning method of the respective embodiments of the present invention described in this specification.
For example, the terminal device 120 shown in fig. 7 may execute step S102 through the traversal module 150 in the file scanning apparatus 140 shown in fig. 6. The terminal device 120 may perform steps S104 and S106 through the scanning module 160. The terminal device 120 may perform step S108 through the broadcasting module 170.
In one embodiment, a terminal device 120 is provided, comprising a memory storing a computer program and a processor implementing the following steps when the processor executes the computer program: when the scanning process monitors the mount notification of any external storage device 130, traversing the file directory of the external storage device 130, and adding files meeting effective conditions into a file queue; based on a history scanning file table, taking an unscanned file in a file queue as a file to be scanned, wherein file information of the scanned file is recorded in the history scanning file table; starting a first thread pool, scanning all files to be scanned in a multi-thread parallel mode, and inserting scanned scanning information into a database; and after scanning of all the files to be scanned is finished, broadcasting a scanning finish notice to other processes so as to inform the other processes that the database is to be accessed.
In one embodiment, the processor when executing the computer program further performs the steps of: judging whether the file to be scanned is a media file or not according to the file type of the file to be scanned, and if so, adding the file to be scanned into an analysis queue; and opening a second thread pool, analyzing the files in the analysis queue in a multi-thread parallel mode, and updating the media file information of the successfully analyzed files into the media table of the database.
In one embodiment, a computer-readable storage medium is provided, having a computer program stored thereon, which when executed by a processor, performs the steps of: when the scanning process monitors the mount notification of any external storage device 130, traversing the file directory of the external storage device 130, and adding files meeting effective conditions into a file queue; based on a history scanning file table, taking an unscanned file in a file queue as a file to be scanned, wherein file information of the scanned file is recorded in the history scanning file table; starting a first thread pool, scanning all files to be scanned in a multi-thread parallel mode, and inserting scanned scanning information into a database; and after scanning of all the files to be scanned is finished, broadcasting a scanning finish notice to other processes so as to inform the other processes that the database is to be accessed.
In one embodiment, the computer program when executed by the processor further performs the steps of: judging whether the file to be scanned is a media file or not according to the file type of the file to be scanned, and if so, adding the file to be scanned into an analysis queue; and opening a second thread pool, analyzing the files in the analysis queue in a multi-thread parallel mode, and updating the media file information of the successfully analyzed files into the media table of the database.
In the embodiments provided in the present invention, it should be understood that the disclosed apparatus and method can be implemented in other ways. The apparatus embodiments described above are merely illustrative, and for example, the flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
In addition, the functional modules in the embodiments of the present invention may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
The functions, if implemented in the form of software functional modules and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for enabling a terminal device 120 (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention, and various modifications and changes may be made by those skilled in the art. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (10)

1. A file scanning method is characterized in that the method is applied to terminal equipment, the terminal equipment comprises a database, and a scanning process is installed on the terminal equipment, and the method comprises the following steps:
traversing a file directory of the external storage equipment when the scanning process monitors the mount notification of any external storage equipment, and adding files meeting effective conditions into a file queue;
based on a history scanning file table, taking an unscanned file in the file queue as a file to be scanned, wherein file information of the scanned file is recorded in the history scanning file table;
starting a first thread pool, scanning all the files to be scanned in a multi-thread parallel mode, and inserting the scanned scanning information into the database;
and after scanning of all the files to be scanned is finished, broadcasting a scanning finish notification to other processes so as to notify the other processes that the database is to be accessed.
2. The method of claim 1, wherein the scanning information includes media file information, and the step of scanning all the files to be scanned includes:
judging whether the file to be scanned is a media file or not according to the file type of the file to be scanned, and if so, adding the file to be scanned into an analysis queue;
and opening a second thread pool, analyzing the files in the analysis queue in a multi-thread parallel mode, and updating the media file information of the successfully analyzed files to a media table of the database.
3. The method according to claim 2, wherein the step of parsing the files in the parsing queue comprises:
extracting metadata information of the file in the analysis queue, wherein if the extraction fails, the file analysis fails, otherwise, the file analysis succeeds;
the metadata information includes any of album, duration, title, and composer.
4. The method of claim 2, wherein after the step of determining whether the file to be scanned is a media file, the method further comprises:
if not, ending the scanning process of the file to be scanned;
the step of scanning all the files to be scanned further includes:
and recording the file information of the file to be scanned into the history scanning file table.
5. The method of claim 1, wherein the step of traversing the file directory of the external storage device and adding the file satisfying the valid condition to the file queue comprises:
traversing the primary file directory of the external storage device, adding files meeting effective conditions into a file queue, and adding folders meeting effective conditions into a folder queue;
and adding the files meeting the effective conditions in all the folders in the folder queue into the file queue according to a directory recursive traversal mode, and adding the folders meeting the effective conditions into the folder queue until all the folders are traversed.
6. The file scanning method according to claim 1, wherein before the step of traversing the file directory of the external storage device and adding the file meeting the valid condition to the file queue when the scanning process monitors the mount notification of any external storage device, the method further comprises:
when the scanning process is started for the first time, the database is created, and the unique constraint is determined to comprise file information, wherein the file information comprises a file path, a file name, a file type, a file size and file modification time;
and starting the scanning process when the system of the terminal equipment is started.
7. The method according to claim 1 or 6, wherein the step of using the file not scanned in the file queue as the file to be scanned based on the history scanned file table comprises:
and judging whether the history scanned file list has the content consistent with the unique constraint field of the file or not aiming at each file in the file queue, and if not, determining that the file is an unscanned file so as to take the file as a file to be scanned.
8. A file scanning device is characterized by being applied to terminal equipment, wherein the terminal equipment comprises a database, the terminal equipment is provided with a scanning process, and the file scanning device comprises a traversing module, a scanning module and a broadcasting module;
the traversal module is used for traversing a file directory of the external storage equipment when the scanning process monitors the mount notification of any external storage equipment, and adding files meeting effective conditions to a file queue;
the scanning module is used for taking the file which is not scanned in the file queue as the file to be scanned based on a history scanning file list, wherein the history scanning file list records the file information of the scanned file; the system is also used for starting a first thread pool, scanning all the files to be scanned in a multi-thread parallel mode, and inserting the scanned scanning information into the database;
and the broadcasting module is used for broadcasting scanning end notification to other processes after scanning of all the files to be scanned is finished so as to notify the other processes that the database is to be accessed.
9. A terminal device, characterized by comprising a processor and a memory, the memory storing a computer program executable by the processor, the processor being executable to implement the file scanning method according to any one of claims 1 to 7.
10. A storage medium having stored thereon a computer program, characterized in that the computer program, when being executed by a processor, implements the file scanning method according to any one of claims 1-7.
CN202210430599.7A 2022-04-22 2022-04-22 File scanning method and device, terminal equipment and storage medium Pending CN114706825A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210430599.7A CN114706825A (en) 2022-04-22 2022-04-22 File scanning method and device, terminal equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210430599.7A CN114706825A (en) 2022-04-22 2022-04-22 File scanning method and device, terminal equipment and storage medium

Publications (1)

Publication Number Publication Date
CN114706825A true CN114706825A (en) 2022-07-05

Family

ID=82175887

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210430599.7A Pending CN114706825A (en) 2022-04-22 2022-04-22 File scanning method and device, terminal equipment and storage medium

Country Status (1)

Country Link
CN (1) CN114706825A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116861425A (en) * 2023-07-07 2023-10-10 北京亿赛通科技发展有限责任公司 Data scanning method and device and endpoint equipment

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116861425A (en) * 2023-07-07 2023-10-10 北京亿赛通科技发展有限责任公司 Data scanning method and device and endpoint equipment

Similar Documents

Publication Publication Date Title
EP2985694A1 (en) Application program management method and apparatus, server, and terminal device
US10664443B2 (en) Method and apparatus for presenting to-be-cleaned data, and electronic device
EP3217295A1 (en) Method and system for scanning local media file
CN103369003A (en) A method and a system for scanning redundancy files in a mobile device by using cloud computing
CN112714359B (en) Video recommendation method and device, computer equipment and storage medium
JP3954642B1 (en) Screen storage system
CN107783766B (en) Method and device for cleaning files of application program
CN107704203B (en) Deletion method, device and equipment for aggregated large file and computer storage medium
CN110825456A (en) Loading time calculation method and device, computer equipment and storage medium
CN108920691B (en) Front-end static resource management method and device, computer equipment and storage medium
CN111954072B (en) Multimedia playing method, device, multimedia player and medium
CN109828859B (en) Mobile terminal memory analysis method and device, storage medium and electronic equipment
CN105808221A (en) Card type desktop realization method and apparatus
CN104965914A (en) Page display method and apparatus
CN114706825A (en) File scanning method and device, terminal equipment and storage medium
CN111125018B (en) File exception tracing method, device, equipment and storage medium
CN109889921B (en) Audio and video creating and playing method and device with interaction function
CN109766317B (en) File deletion method, device, equipment and storage medium
CN111614730B (en) File processing method and device of cloud storage system and electronic equipment
CN111726677B (en) Video playing method and device, computer storage medium and electronic equipment
CN111352917B (en) Information input method and device, electronic equipment and storage medium
KR100610904B1 (en) Meta data parsing method for providing multimedia service and handset using thereof
CN103617224A (en) Webpage collecting method, webpage collecting device and webpage collecting system
CN112423099A (en) Video loading method and device and electronic equipment
CN112181737A (en) Message processing method and device, electronic equipment and 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