Detailed Description
Features and exemplary embodiments of various aspects of the present application will be described in detail below, and in order to make the objects, technical solutions and advantages of the present application more apparent, the present application will be described in further detail below with reference to the accompanying drawings and the detailed embodiments. It should be understood that the particular embodiments described herein are meant to be illustrative of the application only and not limiting. It will be apparent to one skilled in the art that the present application may be practiced without some of these specific details. The following description of the embodiments is merely intended to provide a better understanding of the application by showing examples of the application.
It is noted that relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising" does not exclude the presence of additional identical elements in a process, method, article, or apparatus that comprises an element.
Fig. 1 is a schematic flow chart of a file scanning method according to an embodiment of the present application.
As shown in fig. 1, the document scanning method may include the steps of:
firstly, S110, monitoring the size of a storage space occupied by a folder in a configuration path to obtain a target folder with the size of the storage space changed;
S120, acquiring a target file in a target folder, a first characteristic value of a target source file corresponding to the target file and first attribute information of the target source file;
Then, S130, scanning the target file according to the target file, the first feature value and the first attribute information, to obtain a scanning result.
The method comprises the steps of obtaining a target folder with the size of storage space changed by monitoring the size of storage space occupied by the folder under a configuration path, obtaining a target file in the target folder, a first characteristic value of a target source file corresponding to the target file and first attribute information of the target source file, and then scanning the target file according to the target file, the first characteristic value and the first attribute information to obtain a scanning result. Therefore, the granularity of monitoring is the folder level, not the file level, the number of monitoring objects is reduced, the monitoring efficiency can be improved, and the target folders with the changed storage space can be found conveniently in time, so that the target files in the target folders can be scanned in time.
The following describes the above steps in detail, as follows:
First, referring to S110, a storage path of a received file may be included in a configuration path. Because many files, particularly data files, have high timeliness requirements, scanning needs to be completed as quickly as possible, and thus newly received files need to be discovered in time in order to be scanned in time. The application can obtain the target folder with the changed storage space size by monitoring the storage space size occupied by the folder under the configuration path, and the change of the storage space size can indicate that the newly received file is stored in the target folder, so that the file stored in the target folder can be determined to be the newly received file which needs to be scanned.
Furthermore, in an alternative embodiment, before S110, the method may further include:
Naming the received file according to a preset naming rule to obtain a file name;
Analyzing the file name and determining a receiving path;
the received file is stored to the receive path.
Here, after the file is received, the file may be named according to a preset naming rule, so as to obtain a standardized file name, from which a receiving path of the file may be parsed, and then the file may be stored under the receiving path. The monitored configuration path may include the receiving path, so that the receiving path may be monitored, so that in a case where the size of the storage space occupied by the folder under the receiving path is monitored to change, files stored in the folder with the changed size of the storage space under the receiving path may be scanned.
In addition, the file name can be named by the file sender according to a preset naming rule before sending, so that the file is convenient to receive without naming, the file name can be directly analyzed, a receiving path is determined, and the received file is stored in the receiving path.
In one example, the preset naming convention may be that the file name is a combination of the file sender system name, source file name, file type, date, and batch. Specifically, the received file A may be named according to the preset naming rule, so as to obtain the file name "S1-a-w-2021.09.02-1". Since the file type is w and the receiving path of the first batch of files with the date of 2021 and 9 is U, the file name is analyzed to determine that the receiving path of the file a is U, and then the file a can be stored in the receiving path U.
Therefore, the receiving path of the file can be determined, the received file can be stored in the receiving path conveniently, and the receiving path is arranged below the configuration path, so that the received file can be timely monitored, and the received file can be timely scanned. In addition, the number of the receiving paths is limited because the receiving paths are resolved from the standardized file names, so that the number of folders under the monitored configuration paths is also limited, the folders with the changed occupied storage space can be monitored in time, and the monitoring efficiency is improved.
Next, referring to S120, since the size of the storage space occupied by the target folder is changed, the target file in the target folder may be a newly received file that needs to be scanned. Before scanning, the target file, a first characteristic value of a target source file corresponding to the target file and first attribute information of the target source file need to be acquired. The destination source file may be the destination file before being sent. The first characteristic value may be calculated by the sender before transmission and then transmitted to the receiver together with the target file and the first attribute information.
In addition, the first characteristic value and the first attribute information of the target source file can be stored in a database, and when the target source file needs to be used, the target source file accesses the database and is acquired from the database. However, this method needs to access the database every time the first feature value and the first attribute information are used, so that the database needs to be accessed multiple times in the process of scanning the file, and the efficiency of scanning the file is reduced. And the sender directly sends the first characteristic value and the first attribute information to the receiver, so that the receiver can directly use the first characteristic value and the first attribute information in scanning without accessing the database for multiple times, and the scanning efficiency is improved.
Then, referring to S130, according to the obtained target file, the first feature value of the target source file corresponding to the target file, and the first attribute information of the target source file, the target file may be scanned, so as to obtain a scanning result.
Based on this, in an alternative embodiment, S130 may specifically include:
calculating a second characteristic value of the target file based on the target file;
comparing the first characteristic value with the second characteristic value;
comparing the first attribute information with the second attribute information of the target file under the condition that the first characteristic value is consistent with the second characteristic value;
And under the condition that the first attribute information and the second attribute information are consistent, recording the first file information of the target file into the database and moving the target file to a first preset path.
Here, the characteristic value of the received file, that is, the second characteristic value of the target file may be calculated, and then the characteristic value of the received file is compared with the characteristic value calculated before the transmission of the file, that is, the first characteristic value of the target source file, and if the characteristic values are consistent, the attribute information of the received file, that is, the second attribute information of the target file, is continuously compared with the attribute information of the file before the transmission, that is, the first attribute information of the target source file, and if the attribute information of the received file and the first attribute information of the target source file are consistent, the first file information of the target file is recorded in the database and the target file is moved to the first preset path. The first preset path can be different from the receiving path and is used for storing the scanned file and confirming the error-free file, so that the scanned file is prevented from being repeatedly scanned. The first preset path may be determined by parsing a file name of the received file. When the first file information of the target file is recorded in the database, the first preset path can be used as a main key. The first file information may include a first feature value, a second feature value, first attribute information, second attribute information, a scanning time of the target file, and a scanning number. The scanning time may be the time at which scanning is started or the time at which scanning is ended, but is not limited to this, and the scanning time may be the same as the scanning time at which scanning is started or the scanning time may be the scanning time at which scanning is ended.
In one example, the MD5 value of the object file B, that is, the second feature value, may be calculated based on a message-digest algorithm (md5), and the MD5 value of the object file B is compared with the MD5 value of the object source file B corresponding to the object file B, that is, the first feature value, and if the MD5 value of the object file B is consistent with the MD5 value of the object source file B, the attribute information of the object file B is continuously compared, that is, the second attribute information is consistent with the attribute information of the object source file B, that is, the first attribute information is consistent with the attribute information of the object source file B, and if the attribute information of the object file B is consistent with the attribute information of the object source file B, the received object file B is accurate, then the MD5 value of the object file B, the attribute information of the object source file B, the scan time and the scan number of times of the object file B are recorded in the database, and the object file B is moved to the path N, that is, the first preset path.
Therefore, through the process, the target file can be scanned, and the target file is moved to the first preset path under the condition that the characteristic value and the attribute information of the target file are confirmed to be consistent with the target source file, so that the scanned target file is prevented from being repeatedly scanned, and the scanning efficiency is improved.
Additionally, in an alternative embodiment, the method may further comprise:
comparing the first attribute information with the second attribute information of the target file under the condition that the first characteristic value is consistent with the second characteristic value;
and sending the first feedback information to the sender of the target file under the condition that the first attribute information and the second attribute information are inconsistent.
If the first characteristic value is consistent with the second characteristic value, the first attribute information and the second attribute information are continuously compared, if the attribute information is consistent, the fact that the target file received by the receiver is inconsistent with the target source file before transmission can be indicated, first feedback information can be sent to the sender of the target file, and the first feedback information can be used for feeding back information that the attribute of the target file is inconsistent with the attribute of the target source file to the sender of the target file.
In one example, if the MD5 value of the target file C is consistent with the MD5 value of the target source file C, the attribute information of the target file C, that is, the second attribute information and the attribute information of the target source file C, that is, the first attribute information, are continuously compared, and if the attribute information of the target file C is inconsistent with the attribute information of the target source file C, it is indicated that the target file C received by the receiving side is different from the target source file C before transmission, and information that the attribute of the target file C is inconsistent with the attribute of the target source file C can be fed back to the transmitting side.
Therefore, through the process, the characteristic value can be compared first, the attribute information can be further compared under the condition that the characteristic value is consistent, so that the number of times of comparing the attribute information is reduced, and because the information to be compared is relatively responsible during comparing the attribute information, the number of times of comparing the attribute information is reduced, the scanning efficiency can be improved.
Furthermore, in an alternative embodiment, after comparing the first characteristic value and the second characteristic value, the method may further include:
and storing the target file and the second file information of the target file to a second preset path under the condition that the first characteristic value and the second characteristic value are inconsistent.
Here, if the second characteristic value of the received target file is inconsistent with the first characteristic value of the target source file before transmission, it is possible that the target file is inconsistent with the target source file, but it is also possible that the target file is not completely received due to transmission delay, and in order to avoid inaccurate scanning results caused by the transmission delay, the target file and the second file information of the target file may be stored in a second preset path so as to scan the target file again. The second preset path may be a path storing a file that needs to be scanned again. The second file information may include a first feature value, a second feature value, first attribute information, a scanning time of the target file, and a scanning number. In addition, the second file information may be recorded in the database, and the receiving path corresponding to the target file may be used as a primary key during recording.
In one example, if the MD5 value of the target file D received by the receiving side is inconsistent with the MD5 value of the target source file sent by the sending side, the target file D, the MD5 value of the target source file, the attribute information of the target source file, the scanning time and the scanning number of the target file D are all stored in the path M, that is, the second preset path.
Therefore, the received target file with the second characteristic value inconsistent with the first characteristic value of the target source file before transmission can be stored in the second preset path, so that the target file can be scanned again, and inaccurate scanning results caused by transmission delay are avoided.
In addition, since the second characteristic value of the target file and the first characteristic value of the target source file may not be identical, the target file is not completely received due to transmission delay, so that the second file information of the target file and the target file needs to be stored in a second preset path for storing the file to be scanned again, and then the file under the second preset path needs to be scanned again. The rescanning method is as follows:
On the basis of the above S110-S130, in a possible embodiment, as shown in fig. 2, after storing the target file and the second file information of the target file in the second preset path in the case that the first feature value and the second feature value are not identical, the method may further include S210-S250, where:
S210, acquiring the first file and third file information of the first file from the second preset path.
Here, the first file may be a file that needs to be scanned again, and the third file information may include a feature value of the first file calculated in each scanning process, a scanning time of each scanning the first file, a number of times the first file is scanned, a third feature value of the first source file corresponding to the first file, and third attribute information of the first source file. The first file and the third file information may be stored in the second preset path after the previous scanning of the first file.
In one example, the first file E, the MD5 value of the first file E calculated in the first scanning process, the scanning time 00:20:30 of the first file E scanned for the first time, the number of times of scanning 1 the first file E is scanned, the MD5 value of the first source file E corresponding to the first file E, and the attribute information of the first source file E may be obtained from the path M.
S220, calculating a fourth characteristic value of the first file based on the first file.
Here, a fourth characteristic value of the first file may be calculated based on the first file, which may be one of the bases for determining whether the first file and the first source file are identical. Since the first file may not be completely received due to transmission delay when the first file is scanned the previous time, the fourth characteristic value may be different from the characteristic value calculated when the first file is scanned the previous time.
In one example, the MD5 value of the first file E, i.e. the fourth eigenvalue, may be calculated based on the MD5 algorithm.
S230, comparing the third characteristic value with the fourth characteristic value.
Here, since the fourth characteristic value may be different from the characteristic value calculated when the first file was scanned the previous time, it is necessary to recalculate the characteristic value at the time of the re-scanning, and compare it with the characteristic value of the first source file before transmission, that is, the third characteristic value, again based on the recalculated fourth characteristic value.
In one example, the MD5 value of the first file E may be compared with the MD5 value of the first source file E, i.e., the third feature value.
Based on this, in an alternative embodiment, after S230, the method may further include:
under the condition that the third characteristic value and the fourth characteristic value are inconsistent, acquiring the first scanning time and the second scanning time of the first file;
Calculating the time difference between the initial scanning time and the scanning time;
Under the condition that the time difference is larger than the preset time difference, acquiring the scanning times of the first file;
And storing the first file and the third file information to a second preset path under the condition that the scanning times are not more than the preset scanning times.
Here, in the case where the third characteristic value and the fourth characteristic value do not coincide, it may be determined whether or not to perform the next scanning on the first document based on the time difference between the first scanning time and the present scanning time and the number of times of scanning.
Specifically, the first scanning time and the second scanning time of the first file may be obtained, a time difference between the first scanning time and the second scanning time may be calculated, and then the time difference may be compared with a preset time difference. If the time difference is greater than the preset time difference, there are two possibilities, that is, first, the first file is completely received even if there is a transmission delay, so that the third characteristic value and the fourth characteristic value are inconsistent because the first file is inconsistent with the first source file due to an error in the transmission process, and second, the transmission delay is too serious, the first file is not completely received, so that the first file and the first source file may be consistent although the third characteristic value and the fourth characteristic value are inconsistent. Based on this, in order to avoid that the transmission delay is too serious, the first file is not completely received, so that the scanning result is wrong, the number of times the first file is scanned, that is, the number of times of scanning, and the preset number of times of scanning are compared to further determine whether the first file needs to be scanned next time, specifically, the first file needs to be scanned next time when the number of times of scanning is not greater than the preset number of times of scanning, so that the first file and the third file information are stored in the second preset path to wait for the next scanning.
In one example, under the condition that the MD5 value of the first file E is inconsistent with the MD5 value of the first source file E, the first scanning time 00:20:30 and the current scanning time 00:25:30 of the first file E are obtained, the time difference between the first scanning time and the current scanning time is calculated to be 5 minutes, then the time difference is compared with a preset time difference, the preset time difference may be 3 minutes, since the time difference between the first scanning time and the current scanning time is greater than the preset time difference, the scanning times of the first file E and the preset scanning times need to be further compared, and since the first file E is scanned only once before the current scanning, the scanning times are 1, the preset scanning times may be 3, the scanning times of the first file E are smaller than the preset scanning times, the first file E needs to be stored in the path M, and the next scanning is waited for.
Therefore, whether the first file needs to be scanned next time or not can be determined through two factors of the scanning time and the scanning times, and the scanning result caused by transmission delay is prevented from being wrong by the maximum strength.
In addition, in an optional embodiment, after the scanning number of the first file is acquired in a case that the time difference is greater than the preset time difference, the method may further include:
And under the condition that the scanning times are larger than the preset scanning times, sending third feedback information to the sender of the first file.
Here, in the case where the third characteristic value and the fourth characteristic value are inconsistent and the time difference between the first scanning time and the current scanning time is greater than the preset time difference, if the scanning number is greater than the preset scanning number, it may be indicated that the first file is inconsistent with the first source file, and third feedback information may be sent to the sender of the first file, where the third feedback information may be used to feedback information that the characteristic values of the first file and the first source file are inconsistent to the sender of the first file.
In one example, when the MD5 value of the first file F is inconsistent with the MD5 value of the first source file F and the time difference between the first scanning time of the first file F and the time of this scanning time is 1 minute (less than the preset time difference of 3 minutes), the number of scanning times of the first file F is obtained to be 4, and the preset number of scanning times may be 3, so that the number of scanning times of the first file F is greater than the preset number of scanning times, which may indicate that the first file F received by the receiving side is different from the first source file F before sending, and may feed back information that the first file F is inconsistent with the characteristic value of the first source file F to the sending side.
Therefore, under the condition that the scanning time and the scanning times exceed preset values, the first file and the first source file are determined to be inconsistent, and timely feedback to a sender is facilitated, so that the accurate file can be obtained again.
In addition, in an alternative embodiment, after calculating the time difference between the initial scan time and the current scan time, the method may further include:
And storing the first file and the third file information to a second preset path under the condition that the time difference is not larger than the preset time difference.
Here, if the time difference between the first scanning time and the second scanning time is not greater than the preset time difference, it may indicate that the first file may not be completely received due to the transmission delay, so that the first file and the third file information may be stored in the second preset path to wait for the next scanning.
In one example, the first file G has a first scanning time of 00:21:30, and a time difference from this scanning time of 00:22:30 is 1 minute, which is less than a preset time difference of 3 minutes, so that the first file G may not be completely received due to a transmission delay, and the first file G and the third file information may be stored in the path M to wait for the next scanning.
Therefore, when the time difference between the initial scanning time of the first file and the current scanning time is not larger than the preset time difference, the first file and the third file information are stored in the second preset path, so that the first file can be scanned again, and the error of a scanning result caused by transmission delay is avoided.
S240, comparing the third attribute information with the fourth attribute information of the first file when the third characteristic value and the fourth characteristic value are consistent.
Here, in addition to the case where the third characteristic value and the fourth characteristic value do not coincide, there is a case where the third characteristic value and the fourth characteristic value coincide. The attribute information may be further compared in case the third characteristic value and the fourth characteristic value coincide, specifically, fourth attribute information of the first file and third attribute information of the first source file are compared.
In one example, if the MD5 value of the first file H is consistent with the MD5 value of the first source file H, the attribute information of the first file H is compared with the attribute information of the first source file H.
S250, when the third attribute information and the fourth attribute information are consistent, recording the third file information into a database and moving the first file to a first preset path.
Here, if the fourth attribute information of the first file is consistent with the third attribute information of the first source file, it may indicate that the first file is consistent with the first source file, and the third file information may be recorded in the database and moved to the first preset path, so as to avoid being repeatedly scanned.
In one example, the attribute information of the first file H is consistent with the attribute information of the first source file H, which indicates that the first file H is consistent with the first source file H, the third file information of the first file H may be recorded in the database and moved to the path N.
Therefore, after scanning again, the first file consistent with the first source file is confirmed to be moved to the first preset path, so that the scanned first file is prevented from being scanned repeatedly, and the scanning efficiency is improved.
Additionally, in an alternative embodiment, the method may further comprise:
Comparing the third attribute information with the fourth attribute information of the first file under the condition that the third characteristic value is consistent with the fourth characteristic value;
And transmitting second feedback information to the sender of the first file in the case that the third attribute information and the fourth attribute information are inconsistent.
Here, the third attribute information of the first source file may be compared with the fourth attribute information of the first file when the third feature value and the fourth feature value are identical, and if the third attribute information and the fourth attribute information are not identical, it indicates that the first file and the first source file are not identical, and the second feedback information may be transmitted to the sender of the first file. The second feedback information may be used to feed back information that the attributes of the first file and the first source file are inconsistent to the sender of the first file.
In one example, when the MD5 value of the first file J is consistent with the MD5 value of the first source file J, the attribute information of the first file J is compared with the attribute information of the first source file J, if the attribute information of the first file J is inconsistent with the attribute information of the first source file J, it indicates that the first file J received by the receiving side is different from the first source file J before transmission, and the information that the attribute of the first file J is inconsistent with the attribute of the first source file J can be fed back to the transmitting side.
Thus, through the above process, when the characteristic values of the first file and the first source file are consistent, but the attribute information is inconsistent, the second feedback information is sent to the sender of the first file, so that the sender can resend the accurate file.
In addition to the method for triggering the scanning of the target file in the target folder by monitoring the size of the storage space occupied by the folder under the configuration path and monitoring the target folder with the changed size of the storage space, the embodiment of the application also provides a method for triggering the scanning of the file at fixed time by setting a fixed time task, and the specific fixed time scanning method comprises the following steps:
according to a preset time task, scanning the folder under the configuration path is triggered at fixed time, and recursively scanning is carried out to a second file in the folder;
Calculating a fifth characteristic value of the second file;
Comparing the fifth characteristic value with a sixth characteristic value of the second source file corresponding to the second file;
Comparing the fifth attribute information of the second file with the sixth attribute information of the second source file under the condition that the fifth characteristic value is consistent with the sixth characteristic value;
recording fourth file information of the second file in the database and moving the second file to a first preset path under the condition that the fifth attribute information and the sixth attribute information are consistent, wherein the fourth file information comprises the fifth characteristic value, the sixth characteristic value, the fifth attribute information, the sixth attribute information, the scanning time and the scanning times of the second file;
And transmitting fourth feedback information to the sender of the second file in case that the fifth attribute information and the sixth attribute information are not identical.
The timing scanning method further comprises the following steps:
And storing the second file and fourth file information of the second file to a second preset path when the fifth characteristic value is inconsistent with the sixth characteristic value, wherein the fourth file information comprises the fifth characteristic value, the sixth attribute information, the scanning time and the scanning times of the second file.
In one example, it may be set to scan the folder under the configuration path once every half an hour, recursively scan the folder to a second file Q in the folder, calculate an MD5 value of the second file Q, compare the MD5 value of the second file Q with the MD5 value of the second source file Q, further compare attribute information of the second file Q with attribute information of the second source file Q if the MD5 value of the second file Q is identical with the MD5 value of the second source file Q, and record the MD5 value of the second file Q, the MD5 value of the second source file Q, the attribute information of the second source file Q, the scanning time and the scanning number of times of the second file Q in the database if the attribute information of the second file Q is identical with the attribute information of the second source file Q, and move the second file Q to the path N to avoid being repeatedly scanned. If the attribute information of the second file Q is inconsistent with the attribute information of the second source file Q, feeding back the information that the attribute of the second file Q is inconsistent with the attribute of the second source file Q to the sender of the second file Q, so that the sender can resend the accurate file. If the MD5 value of the second file Q and the MD5 value of the second source file Q are not identical, the second file Q, the MD5 value of the second source file Q, the attribute information of the second source file Q, the scanning time and the scanning times of the second file Q are stored in the path M, and waiting for rescanning.
Based on the above, when three scanning processes for scanning the target file, the first file and the second file collide, the first file is preferentially scanned, the target file is scanned, and finally the second file is scanned. That is, when three scanning processes collide, the first file stored in the second preset path and needing to be scanned again is scanned preferentially, the target file in the target folder with the changed storage space is scanned again, and finally, the timing scanning task is executed, and all files in the configuration path are scanned.
In order to better describe the whole scheme, the document scanning method provided by the embodiment of the present application is described in the following in detail with reference to a specific example of the document scanning method in fig. 3 and the document scanning system in fig. 4 based on the above embodiments.
Fig. 3 shows a flowchart of a file scanning method according to an embodiment of the present application, where the file scanning method may be applied to the file scanning system shown in fig. 4, and the file scanning system may specifically include a transmission module 401, a standardization module 402, a file monitoring module 403, a file scanning module 404, a recording module 405, and a file moving module 406. As shown in FIG. 3, the file scanning method may include S301-S312, specifically as follows:
s301, file name and path standardization.
In one example, the transmission module 401 sends the received file Y, the MD5 value of the file Y, and the attribute information of the file Y to the normalization module 402, and the normalization module 402 names the file Y according to a preset naming rule "sender system name-source file name-file type-date-batch", determines that the file name of the file Y is "S1-Y-k-2021.08.05-2", parses the file name "S1-Y-k-2021.08.05-2", determines that the receiving path of the file Y is path X, and determines that the first preset path corresponding to the file Y is path Z according to the file name "S1-Y-k-2021.08.05-2". After determining that the reception path of the file Y is the path X, the file Y is stored under the path X.
S302, determining a folder x.
In one example, the file monitoring module 403 monitors the size of the storage space occupied by the folder under the configuration path in real time, determines a file x with a changed size of the storage space, indicates that the file stored in the file x is a newly received file, and sends the file Y, the MD5 value of the file Y, and attribute information of the file Y to the file scanning module 404.
S303, calculating a first MD5 value of the file Y.
In one example, the file scan module 404 calculates a first MD5 value for file Y from the received file Y.
S304, judging whether the first MD5 value of the file Y is consistent with the MD5 value of the file Y.
In one example, the document scanning module 404 determines whether the first MD5 value of the document Y is consistent with the MD5 value of the document Y, and if so, performs S310, and if not, performs S305.
S305, storing file Y and file information of the file Y.
In one example, if the first MD5 value of the file Y does not match the MD5 value of the file Y, the file moving module 406 stores the file information such as the first MD5 value of the file Y, the attribute information of the file Y, the scanning time and the scanning number of the file Y, and the file Y to the path M, and waits for the re-scanning. In addition, the recording module 405 records the first MD5 value of the file Y, the attribute information of the file Y, the scanning time and the scanning number of the file Y, and other file information into the database.
S306, calculating a second MD5 value of the file Y.
In one example, the file scanning module 404 obtains, from the path M, the file Y and the file information such as the first MD5 value of the file Y, the attribute information of the file Y, the scanning time and the scanning number of times of the file Y, and the like. Then, a second MD5 value of the file Y is calculated based on the file Y.
S307, it is determined whether the second MD5 value of the file Y is consistent with the MD5 value of the file Y.
In one example, the document scanning module 404 determines whether the second MD5 value of the document Y is consistent with the MD5 value of the document Y, and if so, performs S310, and if not, performs S308.
S308, judging whether the scanning time of the file Y is longer than the preset scanning time.
In one example, if the second MD5 value of the file Y is inconsistent with the MD5 value of the file Y, it is further determined whether the scanning time of the file Y is greater than the preset scanning time, if yes, S309 is executed, if not, S305 is returned to, and the file moving module 406 stores the first MD5 value of the file Y, the second MD5 value of the file Y, the MD5 value of the file Y, attribute information of the file Y, the file information such as the scanning time and the scanning number of times of each time of the file Y, and the file Y to the path M, and waits for the next scanning. In addition, the recording module 405 records the first MD5 value of the file Y, the second MD5 value of the file Y, the attribute information of the file Y, the scanning time and the scanning number of times of each time of the file Y, and other file information into the database.
S309, judging whether the scanning times of the file Y are larger than the preset scanning times.
In one example, if the scanning time of the file Y is greater than the preset scanning time, it is further determined whether the scanning number of times of the file Y is greater than the preset scanning number of times, if yes, S312 is executed, if not, S305 is returned, and the file moving module 406 stores the first MD5 value of the file Y, the second MD5 value of the file Y, the MD5 value of the file Y, attribute information of the file Y, file information such as the scanning time and the scanning number of times of each time of the file Y, and the file Y to the path M, and waits for the next scanning. In addition, the recording module 405 records the first MD5 value of the file Y, the second MD5 value of the file Y, the attribute information of the file Y, the scanning time and the scanning number of times of each time of the file Y, and other file information into the database.
S310, judging whether the attribute information of the file Y is consistent with the attribute information of the file Y.
In one example, if the first MD5 value of the file Y is identical to the MD5 value of the file Y, or if the second MD5 value of the file Y is identical to the MD5 value of the file Y, it is further determined whether the attribute information of the file Y is identical to the attribute information of the file Y, if so, S311 is executed, and if not, S312 is executed.
S311, record the file information of the file Y and move the file Y.
In one example, if the attribute information of the file Y matches the attribute information of the file Y, it indicates that the file Y matches the file Y, and the file moving module 406 moves the file Y to the path N, and the recording module 405 records the MD5 value of the file Y, the attribute information of the file Y, the scanning time and the scanning number of times of the attribute information of the file Y, and other file information calculated at each scanning into the database.
S312, feedback information is sent.
In one example, if the attribute information of the file Y is inconsistent with the attribute information of the file Y, the transmission module 401 sends feedback information of inconsistent attribute to the sender of the file Y, and if the number of scans of the file Y is greater than the preset number of scans, the transmission module 401 sends feedback information of inconsistent feature values to the sender of the file Y.
In this way, the size of the storage space occupied by the folder under the configuration path is monitored to obtain a target folder with the size of the storage space changed, a target file in the target folder, a first characteristic value of a target source file corresponding to the target file and first attribute information of the target source file are obtained, and then the target file is scanned according to the target file, the first characteristic value and the first attribute information to obtain a scanning result. Therefore, the granularity of monitoring is the folder level, not the file level, the number of monitoring objects is reduced, the monitoring efficiency can be improved, and the target folders with the changed storage space can be found conveniently in time, so that the target files in the target folders can be scanned in time.
Based on the same inventive concept, the application also provides a file scanning device. The following describes a document scanning device according to an embodiment of the present application in detail with reference to fig. 5.
Fig. 5 is a block diagram illustrating a structure of a document scanning apparatus according to an exemplary embodiment.
As shown in fig. 5, the document scanning apparatus may include:
The monitoring module 501 is configured to monitor the size of a storage space occupied by a folder in a configuration path, and obtain a target folder with a changed size of the storage space;
The obtaining module 502 is configured to obtain a target file in a target folder, a first feature value of a target source file corresponding to the target file, and first attribute information of the target source file;
The scanning module 503 is configured to scan the target file according to the target file, the first feature value and the first attribute information, so as to obtain a scanning result.
In one embodiment, the scanning module 503 may specifically include:
The first computing sub-module is used for computing a second characteristic value of the target file based on the target file;
The first comparison submodule is used for comparing the first characteristic value with the second characteristic value;
the second comparison sub-module is used for comparing the first attribute information with the second attribute information of the target file under the condition that the first characteristic value is consistent with the second characteristic value;
the first processing sub-module is used for recording first file information of the target file in the database and moving the target file to a first preset path under the condition that the first attribute information and the second attribute information are consistent, wherein the first file information comprises a first characteristic value, a second characteristic value, the first attribute information, the second attribute information, the scanning time and the scanning times of the target file.
In one embodiment, the scanning module 503 may further include:
the third comparison sub-module is used for comparing the first attribute information with the second attribute information of the target file under the condition that the first characteristic value is consistent with the second characteristic value;
and the first sending sub-module is used for sending the first feedback information to the sender of the target file under the condition that the first attribute information and the second attribute information are inconsistent.
In one embodiment, the scanning module 503 may further include:
The first storage sub-module is used for storing the target file and second file information of the target file to a second preset path under the condition that the first characteristic value is inconsistent with the second characteristic value after comparing the first characteristic value with the second characteristic value, wherein the second file information comprises the first characteristic value, the second characteristic value, the first attribute information, the scanning time and the scanning times of the target file.
In one embodiment, the document scanning apparatus may further include:
the naming module is used for naming the received files according to a preset naming rule before monitoring the size of the storage space occupied by the folders in the configuration path to obtain target folders with the changed storage space size, so as to obtain file names;
the analysis module is used for analyzing the file name and determining a receiving path;
and the storage module is used for storing the received file to a receiving path, and the configuration path comprises the receiving path.
In one embodiment, the scanning module 503 may further include:
The first obtaining sub-module is used for obtaining a first file and third file information of the first file from a second preset path after storing the second file information of the target file and the target file to the second preset path under the condition that the first characteristic value and the second characteristic value are inconsistent, wherein the third file information comprises the characteristic value of the first file calculated in each scanning process, the scanning time of the first file, the scanning times of the first file, the third characteristic value of a first source file corresponding to the first file and the third attribute information of the first source file;
the second computing sub-module is used for computing a fourth characteristic value of the first file based on the first file;
the fourth comparison sub-module is used for comparing the third characteristic value with the fourth characteristic value;
a fifth comparing sub-module, configured to compare the third attribute information with the fourth attribute information of the first file when the third feature value and the fourth feature value are consistent;
and the second processing sub-module is used for recording the third file information into the database and moving the first file to the first preset path under the condition that the third attribute information and the fourth attribute information are consistent.
In one embodiment, the document scanning apparatus may further include:
the fourth comparison module is used for comparing the third attribute information with the fourth attribute information of the first file under the condition that the third characteristic value is consistent with the fourth characteristic value;
and the second sending module is used for sending second feedback information to the sender of the first file when the third attribute information and the fourth attribute information are inconsistent.
In one embodiment, the scanning module 503 may further include:
the second acquisition sub-module is used for acquiring the initial scanning time and the scanning time of the first file under the condition that the third characteristic value is inconsistent with the fourth characteristic value after comparing the third characteristic value with the fourth characteristic value;
the third calculation sub-module is used for calculating the time difference between the initial scanning time and the scanning time;
the third acquisition sub-module is used for acquiring the scanning times of the first file under the condition that the time difference is larger than the preset time difference;
And the second storage sub-module is used for storing the first file and the third file information to a second preset path under the condition that the scanning times are not more than the preset scanning times.
In one embodiment, the scanning module 503 may further include:
And the second sending sub-module is used for sending third feedback information to the sender of the first file under the condition that the scanning times are larger than the preset scanning times after the scanning times of the first file are acquired under the condition that the time difference is larger than the preset time difference.
In one embodiment, the scanning module 503 may further include:
And the third storage sub-module is used for storing the first file and the third file information to a second preset path under the condition that the time difference is not larger than the preset time difference after calculating the time difference between the initial scanning time and the current scanning time.
The method comprises the steps of obtaining a target folder with the size of storage space changed by monitoring the size of storage space occupied by the folder under a configuration path, obtaining a target file in the target folder, a first characteristic value of a target source file corresponding to the target file and first attribute information of the target source file, and then scanning the target file according to the target file, the first characteristic value and the first attribute information to obtain a scanning result. Therefore, the granularity of monitoring is the folder level, not the file level, the number of monitoring objects is reduced, the monitoring efficiency can be improved, and the target folders with the changed storage space can be found conveniently in time, so that the target files in the target folders can be scanned in time.
Fig. 6 is a schematic diagram of an electronic device according to an exemplary embodiment.
As shown in fig. 6, the electronic device 6 is capable of implementing a structure diagram of an exemplary hardware architecture of the electronic device according to the file scanning method and the file scanning apparatus in the embodiment of the present application. The electronic device may refer to an electronic device in an embodiment of the present application.
The electronic device 6 may comprise a processor 601 and a memory 602 storing computer program instructions.
In particular, the processor 601 may include a Central Processing Unit (CPU), or an Application SPECIFIC INTEGRATED Circuit (ASIC), or may be configured as one or more integrated circuits that implement embodiments of the present application.
Memory 602 may include a mass storage for information or instructions. By way of example, and not limitation, memory 602 may include a hard disk drive (HARD DISK DRIVE, HDD), floppy disk drive, flash memory, optical disk, magneto-optical disk, magnetic tape, or universal serial bus (universal serial bus, USB) drive, or a combination of two or more of these. The memory 602 may include removable or non-removable (or fixed) media, where appropriate. The memory 602 may be internal or external to the integrated gateway device, where appropriate. In a particular embodiment, the memory 602 is a non-volatile solid state memory. In particular embodiments, memory 602 includes Read Only Memory (ROM). The ROM may be mask programmed ROM, programmable ROM (PROM), erasable PROM (EPROM), electrically Erasable PROM (EEPROM), electrically rewritable ROM (EAROM), or flash memory, or a combination of two or more of these, where appropriate.
The processor 601 reads and executes the computer program instructions stored in the memory 602 to implement the method in the embodiment shown in fig. 1 or fig. 4, and achieve the corresponding technical effects, which are not described herein for brevity.
In one embodiment, the electronic device 6 may also include a transceiver 603 and a bus 604. As shown in fig. 6, the processor 601, the memory 602, and the transceiver 603 are connected to each other through the bus 604 and perform communication with each other.
Bus 604 includes hardware, software, or both. By way of example, and not limitation, the buses may include an Accelerated Graphics Port (AGP) or other graphics bus, an Enhanced Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), a HyperTransport (HT) interconnect, an Industry Standard Architecture (ISA) bus, an infiniband interconnect, a Low Pin Count (LPC) bus, a memory bus, a micro channel architecture (MCa) bus, a Peripheral Control Interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a Serial Advanced Technology Attachment (SATA) bus, a video electronics standards association local (VLB) bus, or other suitable bus, or a combination of two or more of the above. Bus 604 may include one or more buses, where appropriate. Although embodiments of the application have been described and illustrated with respect to a particular bus, the application contemplates any suitable bus or interconnect.
The embodiment of the application also provides a computer storage medium, wherein the computer storage medium is stored with computer executable instructions, and the computer executable instructions are used for realizing the file scanning method described in the embodiment of the application.
In some possible embodiments, aspects of the method provided by the present application may also be implemented in the form of a program product, which includes a program code for causing a computer device to perform the steps of the method according to the various exemplary embodiments of the present application described in the present specification, when the program product is run on the computer device, for example, the computer device may perform the file scanning method described in the embodiments of the present application.
The program product may employ any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium can be, for example, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples (a non-exhaustive list) of a readable storage medium include an electrical connection having one or more wires, a portable disk, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus and computer program products according to the application. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable information processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable information processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable information processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable information processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
It will be apparent to those skilled in the art that various modifications and variations can be made to the present application without departing from the spirit or scope of the application. Thus, it is intended that the present application also include such modifications and alterations insofar as they come within the scope of the appended claims or the equivalents thereof.